diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-24 15:20:35 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-24 15:20:35 +0700 |
| commit | f356538cd4ad808f90c363e6d7df2a19c4993713 (patch) | |
| tree | d853152d8cd0eec8ed02ebb6599d0d93e7fb0bcd | |
| parent | 6ece17db36fe86c91d560c2bc5921bf60d5b7694 (diff) | |
<Miqdad> Fake Stock
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktopVariant.jsx | 14 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductMobileVariant.jsx | 10 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 59fa2032..44ae04bd 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -296,6 +296,11 @@ const ProductDesktopVariant = ({ fetchData(); }, [product]); + const [fakeStock] = useState(() => { + // inisialisasi sekali doang pas pertama kali komponen dibuat + return Math.floor(Math.random() * 100) + 1; + }); + useEffect(() => { const fetchData = async () => { const qty_available = await odooApi( @@ -530,7 +535,7 @@ const ProductDesktopVariant = ({ </div> <div> - <Skeleton + {/* <Skeleton isLoaded={!isLoadingSLA} h='21px' // w={16} @@ -539,6 +544,13 @@ const ProductDesktopVariant = ({ } > Stock : {product?.sla?.qty}{' '} + </Skeleton> */} + <Skeleton + isLoaded={!isLoadingSLA} + h='21px' + className={fakeStock < 10 ? 'text-red-600 font-medium' : ''} + > + Stock : {fakeStock}{' '} </Skeleton> </div> <div> diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index cab8e9be..4cfc63ca 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -176,6 +176,11 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { fetchData(); }, [product]); + const [fakeStock] = useState(() => { + // inisialisasi sekali doang pas pertama kali komponen dibuat + return Math.floor(Math.random() * 100) + 1; + }); + return ( <MobileView> {/* PRICE & ACTIONS: tetap punyamu, hanya hapus input number lama */} @@ -245,7 +250,8 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { product?.sla?.qty < 10 ? 'text-red-600 font-medium' : '' }`} > - Stock : {activeVariant?.stock ?? 0} + {/* Stock : {activeVariant?.stock ?? 0} */} + Stock : {fakeStock}{' '} </div> {qtyPickUp > 0 && ( <div className='text-[16px] mt-0.5 text-red-500 italic'> @@ -291,7 +297,7 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { </div> </div> - <div className='h4'/> + <div className='h4' /> {/* TOMBOL AKSI */} <div className='flex gap-2 mt-3'> {/* Tombol Dokumen */} |
