From e33a7e612a3c2c871f6a0a84d0d04d6f6ddc357a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 9 Aug 2024 10:51:10 +0700 Subject: update template switch & delete console log --- src-migrate/hooks/useUtmSource.ts | 1 - .../product-card/components/ProductCard.tsx | 105 ++++++++++----------- .../product-detail/components/ProductDetail.tsx | 2 +- .../product-detail/components/SimilarBottom.tsx | 1 - src-migrate/services/product.ts | 13 ++- src-migrate/types/productVariant.ts | 4 + 6 files changed, 65 insertions(+), 61 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/hooks/useUtmSource.ts b/src-migrate/hooks/useUtmSource.ts index a72fae36..41a5f41c 100644 --- a/src-migrate/hooks/useUtmSource.ts +++ b/src-migrate/hooks/useUtmSource.ts @@ -7,7 +7,6 @@ const useUtmSource = () => { const [source, setSource] = useState(); useEffect(() => { - console.log(router.pathname); if (router.pathname) { setSource(UTM_SOURCE[router.pathname as keyof typeof UTM_SOURCE]); diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx index 3e34d5c3..931f8f2f 100644 --- a/src-migrate/modules/product-card/components/ProductCard.tsx +++ b/src-migrate/modules/product-card/components/ProductCard.tsx @@ -24,6 +24,9 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { const utmSource = useUtmSource() const router = useRouter(); + const ppnString = process.env.NEXT_PUBLIC_PPN; + const ppnNumber = ppnString !== undefined ? Number(ppnString) : 0; + const id = product.id.toString () const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, @@ -169,36 +172,24 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { > {product.name} -
- {product?.flash_sale?.id > 0 ? (
) : - ( -
- Rp {formatCurrency(product.lowest_price.price)} -
- ) - } - -
- - {product?.flash_sale?.id > 0 && - product?.lowest_price?.discountPercentage > 0 ? ( + {product?.lowest_price.discountPercentage === undefined ? ( +
+ {product?.flash_sale?.id > 0 && + product?.lowest_price.discount_percentage > 0 ? ( <> - {product?.lowest_price.discountPercentage > 0 && ( -
-
- {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}% -
-
- {currencyFormat(product?.lowest_price?.price)} -
+
+
+ {currencyFormat(product.lowest_price.price)}
- )} - +
+ {Math.floor(product?.lowest_price.discount_percentage)}% +
+
- {product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount > 0 ? ( - currencyFormat(product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount) + {product?.lowest_price.price_discount > 0 ? ( + currencyFormat(product?.lowest_price.price_discount) ) : ( { )}
-
- {product?.stockTotal > 0 && ( + + ) : ( +
+ {product?.lowest_price.price > 0 ? ( + <> + {currencyFormat(product?.lowest_price.price)} +
+ Inc. PPN:{' '} + {currencyFormat( + product.lowest_price.price * ppnNumber + )} +
+ + ) : ( + + Call for Inquiry + + )} +
+ )} + +
+ {product?.stock_total > 0 && (
Ready Stock
)} {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} - {product?.qtySold > 0 && ( + {product?.qty_sold > 0 && (
- {sellingProductFormat(product?.qtySold) + ' Terjual'} + {sellingProductFormat(product?.qty_sold) + ' Terjual'}
)}
- - ) : ( -
-
- Inc PPN: - Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))} -
- -
- -
- {product.stock_total > 0 && ( -
- Ready Stock -
- )} - {product.qty_sold > 0 && ( -
- {formatToShortText(product.qty_sold)} Terjual -
- )} -
-
- )} +
+ ) : ( +
+ +
+ )} +
diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index f5feae76..de0522d5 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -37,7 +37,7 @@ const ProductDetail = ({ product }: Props) => { const router = useRouter() const auth = getAuth() const { setAskAdminUrl, askAdminUrl, activeVariantId, setIsApproval, isApproval } = useProductDetail() - + useEffect(() => { gtagProductDetail(product); },[product]) diff --git a/src-migrate/modules/product-detail/components/SimilarBottom.tsx b/src-migrate/modules/product-detail/components/SimilarBottom.tsx index ab33f106..8ff0a6bf 100644 --- a/src-migrate/modules/product-detail/components/SimilarBottom.tsx +++ b/src-migrate/modules/product-detail/components/SimilarBottom.tsx @@ -16,7 +16,6 @@ const SimilarBottom = ({ product, source }: Props) => { }) const products = productSimilar.data?.products || [] - return ( ({ + flashSale: any; + lowestPrice: any; + }) => ({ ...product, - lowest_price: product.lowestPrice, + lowest_price: { + discount_percentage: product.lowestPrice.discountPercentage, + price: product.lowestPrice.price, + price_discount: product.lowestPrice.priceDiscount, + }, flash_sale: product.flashSale, stock_total: product.stockTotal, qty_sold: product.qtySold, - lowestPrice: undefined })); if (source === 'bottom') { dataflashSale = dataflashSale.slice('2', '4') } else { dataflashSale = dataflashSale } - console.log("dataflashSale",dataflashSale) } const query = [ `q=${name}`, diff --git a/src-migrate/types/productVariant.ts b/src-migrate/types/productVariant.ts index 861b216a..5f6bded5 100644 --- a/src-migrate/types/productVariant.ts +++ b/src-migrate/types/productVariant.ts @@ -8,6 +8,10 @@ export interface IProductVariantDetail { remaining_time: number; is_flashsale: boolean; }; + categories: { + id: string; + name: string; + }[]; price: { price: number; price_discount: number; -- cgit v1.2.3