From 94a96e371f554c7d87e2a6edbc6bdb7fe9228fd6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:19:45 +0700 Subject: add CR tambahin info jumlah barang ready stock yang bisa di pick up --- src-migrate/modules/cart/components/Item.tsx | 17 ++++++++++------- .../product-detail/components/PriceAction.tsx | 22 ++++++++++++++++++++-- src-migrate/types/cart.ts | 1 + src/lib/checkout/components/Checkout.jsx | 1 + src/lib/transaction/components/Transaction.jsx | 6 +++++- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src-migrate/modules/cart/components/Item.tsx b/src-migrate/modules/cart/components/Item.tsx index 6ffbb524..ab2e7ce1 100644 --- a/src-migrate/modules/cart/components/Item.tsx +++ b/src-migrate/modules/cart/components/Item.tsx @@ -36,26 +36,29 @@ const CartItem = ({ item, editable = true, selfPicking}: Props) => { )}
- Selamat! Pembelian anda lebih hemat {' '} + Selamat! Pembelian anda lebih hemat{' '} - Rp{formatCurrency((item.package_price || 0) * item.quantity - item.subtotal)} + Rp + {formatCurrency( + (item.package_price || 0) * item.quantity - item.subtotal + )}
)}
- {editable && ( - - )} + {editable && }
- {(item.is_in_bu) && (item.on_hand_qty >= item.quantity) && ( + {item?.available_quantity > 0 && (
- *Barang ini bisa di pickup maksimal pukul 16.00 + {item.quantity <= item?.available_quantity + ? '*Barang ini bisa di pickup maksimal pukul 16.00' + : `*${item?.available_quantity} Barang ini bisa di pickup maksimal pukul 16.00`}
)} diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 3544fa26..5171308c 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -2,11 +2,12 @@ import style from '../styles/price-action.module.css'; import Image from 'next/image'; import Link from 'next/link'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import formatCurrency from '~/libs/formatCurrency'; import { IProductDetail } from '~/types/product'; import { useProductDetail } from '../stores/useProductDetail'; import AddToCart from './AddToCart'; +import odooApi from '~/libs/odooApi'; type Props = { product: IProductDetail; @@ -25,7 +26,7 @@ const PriceAction = ({ product }: Props) => { selectedVariant, sla, } = useProductDetail(); - + const [qtyPickUp, setQtyPickUp] = useState(0); useEffect(() => { setActive(selectedVariant); if (product.variants.length > 2 && product.variants[0].price.price === 0) { @@ -39,6 +40,18 @@ const PriceAction = ({ product }: Props) => { } }, [product, setActive, selectedVariant]); + useEffect(() => { + const fetchData = async () => { + const qty_available = await odooApi( + 'GET', + `/api/v1/product_variant/${selectedVariant.id}/qty_available` + ); + + setQtyPickUp(qty_available?.qty); + }; + fetchData(); + }, [selectedVariant]); + let voucherPastiHemat = 0; if ( @@ -143,6 +156,11 @@ const PriceAction = ({ product }: Props) => { )}
+ {qtyPickUp > 0 && ( +
+ * {qtyPickUp} barang bisa di pickup +
+ )}
diff --git a/src-migrate/types/cart.ts b/src-migrate/types/cart.ts index a3115103..05fdcadb 100644 --- a/src-migrate/types/cart.ts +++ b/src-migrate/types/cart.ts @@ -34,6 +34,7 @@ export type CartItem = { stock: number; is_in_bu: boolean; on_hand_qty: number; + available_quantity: number; weight: number; attributes: string[]; parent: { diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 4c7e852f..e872b7f6 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -442,6 +442,7 @@ const Checkout = () => { const productOrder = products.map((product) => ({ product_id: product.id, quantity: product.quantity, + available_quantity: product?.availableQuantity, })); let data = { // partner_shipping_id: auth.partnerId, diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 4d401037..d001c7f4 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -778,6 +778,10 @@ const Transaction = ({ id }) => { ? `| ${product?.attributes.join(', ')}` : ''}
+
+ {product.availableQuantity} barang ini bisa di + pickup maksimal pukul 16.00 +
{/* @@ -879,7 +883,7 @@ const Transaction = ({ id }) => {
- )} + )} {transaction?.data?.productsRejectLine.length > 0 && (
-- cgit v1.2.3 From 6d89fa79c9fdbb1961b15a463250f28e5c684b4a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:33:00 +0700 Subject: delete console log --- src/lib/product/components/Product/ProductDesktopVariant.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 55effdfb..2e005eea 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -36,8 +36,6 @@ const ProductDesktopVariant = ({ const auth = useAuth(); const { slug } = router.query; - console.log('ini product variant', product); - const [lowestPrice, setLowestPrice] = useState(null); const [addCartAlert, setAddCartAlert] = useState(false); -- cgit v1.2.3 From fc77794a015f8fed5e8af4c9a320ca8b0fbb7d23 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:42:39 +0700 Subject: update tampilan mobile --- src/lib/variant/components/VariantCard.jsx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 68cdf54f..08b7a97e 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -103,30 +103,42 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => {
-
-

{product.parent.name}

+

+ {product.parent.name} +

{product.code || '-'} - {product.attributes.length > 0 ? ` ・ ${product.attributes.join(', ')}` : ''} + {product.attributes.length > 0 + ? ` ・ ${product.attributes.join(', ')}` + : ''}

Berat Item : {product?.weight} Kg x {product?.quantity} Barang

+

+ {product.availableQuantity} barang ini bisa di pickup maksimal pukul + 16.00 +

{product.hasFlashsale && ( <>

{currencyFormat(product.price.price)}

- {product.price.discountPercentage}% + + {product.price.discountPercentage}% + )}

{product.price.priceDiscount > 0 - ? currencyFormat(product.price.priceDiscount) + ' × ' + product.quantity + ' Barang' + ? currencyFormat(product.price.priceDiscount) + + ' × ' + + product.quantity + + ' Barang' : ''}

-- cgit v1.2.3 From c64472c479ec282af9b606a76358922b25752be0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 25 Oct 2024 15:03:53 +0700 Subject: update revisi CR --- .../product-detail/components/PriceAction.tsx | 20 ++++++++++++++++---- .../components/Product/ProductDesktopVariant.jsx | 8 +++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 5171308c..a87f8ae0 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -8,6 +8,7 @@ import { IProductDetail } from '~/types/product'; import { useProductDetail } from '../stores/useProductDetail'; import AddToCart from './AddToCart'; import odooApi from '~/libs/odooApi'; +import { Button, Skeleton } from '@chakra-ui/react'; type Props = { product: IProductDetail; @@ -52,6 +53,10 @@ const PriceAction = ({ product }: Props) => { fetchData(); }, [selectedVariant]); + useEffect(() => { + setQuantityInput('1'); + }, [selectedVariant]); + let voucherPastiHemat = 0; if ( @@ -137,10 +142,17 @@ const PriceAction = ({ product }: Props) => {

- - {' '} + Stock : {sla?.qty}{' '} - + + {/* + {' '} + */}
{product?.is_in_bu && ( @@ -157,7 +169,7 @@ const PriceAction = ({ product }: Props) => {
{qtyPickUp > 0 && ( -
+
* {qtyPickUp} barang bisa di pickup
)} diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 2e005eea..32ce345e 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -364,14 +364,16 @@ const ProductDesktopVariant = ({
- - {' '} Stock : {product?.sla?.qty}{' '} - +
{product?.sla?.qty > 0 && ( -- cgit v1.2.3 From fdd6902a19ee050d97937252ef70bafa8fbe44d9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 25 Oct 2024 16:19:56 +0700 Subject: update code --- .../modules/product-detail/components/Information.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src-migrate/modules/product-detail/components/Information.tsx b/src-migrate/modules/product-detail/components/Information.tsx index 8655517d..b3311cb5 100644 --- a/src-migrate/modules/product-detail/components/Information.tsx +++ b/src-migrate/modules/product-detail/components/Information.tsx @@ -56,13 +56,15 @@ const Information = ({ product }: Props) => { }; useEffect(() => { - getsla(); - setInputValue( - selectedVariant?.code + - (selectedVariant?.attributes[0] - ? ' - ' + selectedVariant?.attributes[0] - : '') - ); + if (selectedVariant) { + getsla(); + setInputValue( + selectedVariant?.code + + (selectedVariant?.attributes[0] + ? ' - ' + selectedVariant?.attributes[0] + : '') + ); + } }, [selectedVariant]); const handleOnChange = (vals: any) => { -- cgit v1.2.3