diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-15 13:54:30 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-15 13:54:30 +0700 |
| commit | c42f03768e4c009a247d5cacbecaf4ac952752c9 (patch) | |
| tree | 9199f9b7fae77e1988724159380567b8046c94a9 /src-migrate/modules/product-detail/components/PriceAction.tsx | |
| parent | f62b2345f463695ef0f8f79830cd76b6e0332821 (diff) | |
Improve product detail performance
Diffstat (limited to 'src-migrate/modules/product-detail/components/PriceAction.tsx')
| -rw-r--r-- | src-migrate/modules/product-detail/components/PriceAction.tsx | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 8189e5bd..cfb596fa 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -6,13 +6,21 @@ import { formatToShortText } from '~/libs/formatNumber' import { IProductDetail } from '~/types/product' import { useProductDetail } from '../stores/useProductDetail' import AddToCart from './AddToCart' +import Link from 'next/link' type Props = { product: IProductDetail } const PriceAction = ({ product }: Props) => { - const { activePrice, setActive, activeVariantId, quantityInput, setQuantityInput } = useProductDetail() + const { + activePrice, + setActive, + activeVariantId, + quantityInput, + setQuantityInput, + askAdminUrl + } = useProductDetail() useEffect(() => { setActive(product.variants[0]) @@ -26,18 +34,28 @@ const PriceAction = ({ product }: Props) => { </div> )} <div className='h-2' /> - <div className={style['main-price']}> - Rp {formatCurrency(activePrice?.price || 0)} - </div> - <div className='h-1' /> - <div className={style['secondary-text']}> - {!!activePrice && ( - <> + + {!!activePrice && activePrice.price > 0 && ( + <> + <div className={style['main-price']}> + Rp {formatCurrency(activePrice.price || 0)} + </div> + <div className='h-1' /> + <div className={style['secondary-text']}> Termasuk PPN: {' '} - Rp {formatCurrency(Math.round(activePrice?.price * 1.11))} - </> - )} - </div> + Rp {formatCurrency(Math.round(activePrice.price * 1.11))} + </div> + </> + )} + + {!!activePrice && activePrice.price === 0 && ( + <span> + Hubungi kami untuk dapatkan harga terbaik,{' '} + <Link href={askAdminUrl} target='_blank' className={style['contact-us']}> + klik disini + </Link> + </span> + )} <div className='h-4' /> |
