diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-12-22 17:33:46 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-12-22 17:33:46 +0700 |
| commit | 89f32128f37d99b490de7590e2116a9cfd853f89 (patch) | |
| tree | feb74cc6bd0030b291fbf3dbba9b89a7afd6ea31 /src-migrate/modules/cart/components/CartDetail.tsx | |
| parent | c9366090153e8aba3a673b2b77cbc8acc24e59a5 (diff) | |
Update promotion program feature
Diffstat (limited to 'src-migrate/modules/cart/components/CartDetail.tsx')
| -rw-r--r-- | src-migrate/modules/cart/components/CartDetail.tsx | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src-migrate/modules/cart/components/CartDetail.tsx b/src-migrate/modules/cart/components/CartDetail.tsx deleted file mode 100644 index 734c61d3..00000000 --- a/src-migrate/modules/cart/components/CartDetail.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import React, { useEffect, useMemo } from 'react' -import { getAuth } from '~/common/libs/auth' -import { useCartStore } from '../stores/useCartStore' -import CartItem from '../ui/CartItem' -import style from '../styles/CartDetail.module.css' -import CartSummary from '../ui/CartSummary' -import { Button, Tooltip } from '@chakra-ui/react' - -const CartDetail = () => { - const auth = getAuth() - - const { loadCart, cart, summary } = useCartStore() - - useEffect(() => { - if (typeof auth === 'object' && !cart) loadCart(auth.id) - }, [auth, loadCart, cart]) - - const hasSelectedPromo = useMemo(() => { - if (!cart) return false - for (const item of cart.products) { - if (item.cart_type === 'promotion' && item.selected) return true - } - return false - }, [cart]) - - const hasSelected = useMemo(() => { - if (!cart) return false - for (const item of cart.products) { - if (item.selected) return true - } - return false - }, [cart]) - - return ( - <div className={style.wrapper}> - <div className='w-full md:w-3/4'> - {/* <div className='border border-gray-300 rounded-lg p-4 md:p-6'> */} - <div className=''> - <div className='text-h-lg font-semibold mb-6'>Keranjang Belanja</div> - <div className='grid grid-cols-1 gap-y-4'> - {!cart && <CartItem.Skeleton count={5} height='120px' />} - </div> - <div className='flex flex-col gap-y-8 border-t border-gray-300 pt-8'> - {cart?.products.map((item) => <CartItem key={item.id} item={item} />)} - </div> - </div> - </div> - - <div className='w-full md:w-1/4 pl-6'> - <div className='border border-gray-300 p-4 rounded-md sticky top-[180px]'> - <CartSummary {...summary} isLoaded={!!cart} /> - <div className='grid grid-cols-2 gap-x-3 mt-6'> - <Tooltip label={hasSelectedPromo ? 'Barang promo tidak dapat dibuat quotation' : ''}> - <Button - colorScheme='yellow' - w='full' - isDisabled={hasSelectedPromo || !hasSelected}> - Quotation - </Button> - </Tooltip> - <Tooltip label={hasSelected ? '' : 'Tidak ada item yang dipilih'}> - <Button - colorScheme='red' - w='full' - isDisabled={!hasSelected}> - Checkout - </Button> - </Tooltip> - </div> - </div> - </div> - </div> - ) -} - -export default CartDetail
\ No newline at end of file |
