diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-22 22:57:48 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-22 22:57:48 +0700 |
| commit | 321e0c09be4b26d72b470407217262d10c88089d (patch) | |
| tree | 999e3db07ef3d5897cd6a585a6a4fc8aea120c72 /src/lib/cart/components | |
| parent | c6a489da2f3df46b867891c12a3c5f4121f920b0 (diff) | |
fix
Diffstat (limited to 'src/lib/cart/components')
| -rw-r--r-- | src/lib/cart/components/Cart.jsx | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index 2d94ac0b..af2bec78 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -103,7 +103,7 @@ const Cart = () => { const selectedProduct = () => { if (!products) return [] - return products.filter((product) => product.selected == true) + return products?.filter((product) => product.selected == true) } const deleteProduct = (productId) => { @@ -115,27 +115,27 @@ const Cart = () => { } return ( - <div className='pt-6'> + <div className='pt-4'> <div className='flex justify-between mb-4 px-4'> <h1 className='font-semibold'>Daftar Produk Belanja</h1> <Link href='/'>Cari Produk Lain</Link> </div> - <div className='flex flex-col gap-y-4 px-4'> + <div className='flex flex-col gap-y-4 h-screen'> {cart.isLoading && ( <div className='flex justify-center my-4'> <Spinner className='w-6 text-gray_r-12/50 fill-gray_r-12' /> </div> )} - {!cart.isLoading && !products && ( - <Alert className='text-center my-2' type='info'> + {!cart.isLoading && (!products || products?.length == 0) && ( + <Alert className='text-center my-2 mx-4' type='info'> Keranjang belanja anda masih kosong </Alert> )} {products?.map((product) => ( - <div key={product?.id} className='flex'> + <div key={product?.id} className='flex mx-4'> <button type='button' className='flex items-center mr-2' @@ -214,37 +214,37 @@ const Cart = () => { </div> </div> ))} - </div> - <div className='sticky bottom-0 left-0 w-full p-4 mt-6 border-t border-gray_r-6 bg-white'> - <div className='flex justify-between mb-4'> - <div className='text-gray_r-11'> - Total: - <span className='text-red_r-11 font-semibold'> - - {selectedProduct().length > 0 - ? currencyFormat(totalPriceBeforeTax - totalDiscountAmount + totalTaxAmount) - : '-'} - </span> + <div className='sticky bottom-0 left-0 w-full p-4 mt-auto border-t border-gray_r-6 bg-white'> + <div className='flex justify-between mb-4'> + <div className='text-gray_r-11'> + Total: + <span className='text-red_r-11 font-semibold'> + + {selectedProduct().length > 0 + ? currencyFormat(totalPriceBeforeTax - totalDiscountAmount + totalTaxAmount) + : '-'} + </span> + </div> + </div> + <div className='flex gap-x-3'> + <button + type='button' + className='btn-yellow flex-1' + disabled={selectedProduct().length == 0} + onClick={() => router.push('/shop/quotation')} + > + Quotation + </button> + <button + type='button' + className='btn-solid-red flex-1' + disabled={selectedProduct().length == 0} + onClick={() => router.push('/shop/checkout')} + > + Checkout + </button> </div> - </div> - <div className='flex gap-x-3'> - <button - type='button' - className='btn-yellow flex-1' - disabled={selectedProduct().length == 0} - onClick={() => router.push('/shop/quotation')} - > - Quotation - </button> - <button - type='button' - className='btn-solid-red flex-1' - disabled={selectedProduct().length == 0} - onClick={() => router.push('/shop/checkout')} - > - Checkout - </button> </div> </div> |
