diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-09 10:51:10 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-09 10:51:10 +0700 |
| commit | e33a7e612a3c2c871f6a0a84d0d04d6f6ddc357a (patch) | |
| tree | 6843753e513b1ce5c671d5bde6f819df4a18091e /src-migrate | |
| parent | 616d8ffc973eba673069243ec8981b5234234fe5 (diff) | |
<iman> update template switch & delete console log
Diffstat (limited to 'src-migrate')
| -rw-r--r-- | src-migrate/hooks/useUtmSource.ts | 1 | ||||
| -rw-r--r-- | src-migrate/modules/product-card/components/ProductCard.tsx | 105 | ||||
| -rw-r--r-- | src-migrate/modules/product-detail/components/ProductDetail.tsx | 2 | ||||
| -rw-r--r-- | src-migrate/modules/product-detail/components/SimilarBottom.tsx | 1 | ||||
| -rw-r--r-- | src-migrate/services/product.ts | 13 | ||||
| -rw-r--r-- | src-migrate/types/productVariant.ts | 4 |
6 files changed, 65 insertions, 61 deletions
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<string>(); 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} </Link> - <div className='h-1.5' /> - {product?.flash_sale?.id > 0 ? (<div></div>) : - ( - <div className={style['price']}> - Rp {formatCurrency(product.lowest_price.price)} - </div> - ) - } - - <div className='h-1.5' /> - - {product?.flash_sale?.id > 0 && - product?.lowest_price?.discountPercentage > 0 ? ( + {product?.lowest_price.discountPercentage === undefined ? ( + <div> + {product?.flash_sale?.id > 0 && + product?.lowest_price.discount_percentage > 0 ? ( <> - {product?.lowest_price.discountPercentage > 0 && ( - <div className='flex gap-x-1 mb-1 items-center'> - <div className='badge-solid-red'> - {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}% - </div> - <div className='text-gray_r-11 line-through text-caption-2'> - {currencyFormat(product?.lowest_price?.price)} - </div> + <div className='flex gap-x-1 mb-1 items-center'> + <div className='text-gray_r-11 line-through text-[11px] sm:text-caption-2'> + {currencyFormat(product.lowest_price.price)} </div> - )} - + <div className='badge-solid-red'> + {Math.floor(product?.lowest_price.discount_percentage)}% + </div> + </div> <div className='text-danger-500 font-semibold mb-2'> - {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) ) : ( <a rel='noopener noreferrer' @@ -209,41 +200,49 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { </a> )} </div> - <div className='flex w-full items-center gap-x-1 '> - {product?.stockTotal > 0 && ( + </> + ) : ( + <div className='text-danger-500 font-semibold mb-2 min-h-[40px]'> + {product?.lowest_price.price > 0 ? ( + <> + {currencyFormat(product?.lowest_price.price)} + <div className='text-gray_r-9 text-[10px] font-normal mt-2'> + Inc. PPN:{' '} + {currencyFormat( + product.lowest_price.price * ppnNumber + )} + </div> + </> + ) : ( + <a + rel='noopener noreferrer' + target='_blank' + href={callForPriceWhatsapp} + > + Call for Inquiry + </a> + )} + </div> + )} + + <div className='flex w-full items-center gap-x-1 '> + {product?.stock_total > 0 && ( <div className='badge-solid-red'>Ready Stock</div> )} {/* <div className='badge-gray'>{product?.stockTotal > 5 ? '> 5' : '< 5'}</div> */} - {product?.qtySold > 0 && ( + {product?.qty_sold > 0 && ( <div className='text-gray_r-9 text-[11px]'> - {sellingProductFormat(product?.qtySold) + ' Terjual'} + {sellingProductFormat(product?.qty_sold) + ' Terjual'} </div> )} </div> - </> - ) : ( - <div> - <div className={style['price-inc']}> - Inc PPN: - Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))} - </div> - - <div className='h-1' /> - - <div className='flex items-center gap-x-2.5'> - {product.stock_total > 0 && ( - <div className={style['ready-stock']}> - Ready Stock - </div> - )} - {product.qty_sold > 0 && ( - <div className={style['sold']}> - {formatToShortText(product.qty_sold)} Terjual - </div> - )} - </div> - </div> - )} + </div> + ) : ( + <div> + + </div> + )} + </div> 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 ( <Skeleton isLoaded={!productSimilar.isLoading} diff --git a/src-migrate/services/product.ts b/src-migrate/services/product.ts index ec5435cd..2152ba26 100644 --- a/src-migrate/services/product.ts +++ b/src-migrate/services/product.ts @@ -57,21 +57,24 @@ export const getProductSimilar = async ({ dataflashSale = dataFlash.response.products.map((product: { qtySold: any; stockTotal: any; - flashSale: any; lowestPrice: any; -}) => ({ + 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; |
