diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2024-03-12 15:07:56 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2024-03-12 15:07:56 +0700 |
| commit | 5234b7c85ac984bc76d8945934a90b75f4a0d8c0 (patch) | |
| tree | 31ca8dba20a86eeaed486971fdd83c38c3732fcc | |
| parent | 9cd749a76fee161b8f7f9bc1fd6af9659400e5d9 (diff) | |
feeback review
| -rw-r--r-- | src-migrate/pages/shop/cart/cart.module.css | 4 | ||||
| -rw-r--r-- | src-migrate/pages/shop/cart/index.tsx | 129 |
2 files changed, 82 insertions, 51 deletions
diff --git a/src-migrate/pages/shop/cart/cart.module.css b/src-migrate/pages/shop/cart/cart.module.css index 353b131a..98a6ac86 100644 --- a/src-migrate/pages/shop/cart/cart.module.css +++ b/src-migrate/pages/shop/cart/cart.module.css @@ -3,11 +3,11 @@ } .content { - @apply flex flex-wrap; + @apply flex flex-wrap ; } .item-wrapper { - @apply w-full md:w-3/4; + @apply w-full md:w-3/4 min-h-screen; } .item-skeleton { diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index d1a6a6ff..4b4de92b 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -1,59 +1,57 @@ -import style from './cart.module.css' +import style from './cart.module.css'; -import React, { useEffect, useMemo } from 'react' -import Link from 'next/link' -import { Button, Tooltip } from '@chakra-ui/react' +import React, { useEffect, useMemo } from 'react'; +import Link from 'next/link'; +import { Button, Tooltip } from '@chakra-ui/react'; -import { getAuth } from '~/libs/auth' -import { useCartStore } from '~/modules/cart/stores/useCartStore' +import { getAuth } from '~/libs/auth'; +import { useCartStore } from '~/modules/cart/stores/useCartStore'; -import CartItem from '~/modules/cart/components/Item' -import CartSummary from '~/modules/cart/components/Summary' -import clsxm from '~/libs/clsxm' -import useDevice from '@/core/hooks/useDevice' -import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile' -import Image from '~/components/ui/image' +import CartItem from '~/modules/cart/components/Item'; +import CartSummary from '~/modules/cart/components/Summary'; +import clsxm from '~/libs/clsxm'; +import useDevice from '@/core/hooks/useDevice'; +import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile'; +import Image from '~/components/ui/image'; const CartPage = () => { - const auth = getAuth() + const auth = getAuth(); + + const { loadCart, cart, summary } = useCartStore(); - const { loadCart, cart, summary } = useCartStore() - const useDivvice = useDevice(); useEffect(() => { - if (typeof auth === 'object' && !cart) loadCart(auth.id) - }, [auth, loadCart, cart]) + if (typeof auth === 'object' && !cart) loadCart(auth.id); + }, [auth, loadCart, cart]); const hasSelectedPromo = useMemo(() => { - if (!cart) return false + if (!cart) return false; for (const item of cart.products) { - if (item.cart_type === 'promotion' && item.selected) return true + if (item.cart_type === 'promotion' && item.selected) return true; } - return false - }, [cart]) + return false; + }, [cart]); const hasSelected = useMemo(() => { - if (!cart) return false + if (!cart) return false; for (const item of cart.products) { - if (item.selected) return true + if (item.selected) return true; } - return false - }, [cart]) + return false; + }, [cart]); const hasSelectNoPrice = useMemo(() => { - if (!cart) return false + if (!cart) return false; for (const item of cart.products) { - if (item.selected && item.price.price_discount == 0) return true + if (item.selected && item.price.price_discount == 0) return true; } - return false - }, [cart]) + return false; + }, [cart]); return ( <> - <div className={style['title']}> - Keranjang Belanja - </div> + <div className={style['title']}>Keranjang Belanja</div> <div className='h-6' /> @@ -64,26 +62,57 @@ const CartPage = () => { </div> <div className={style['items']}> - {cart?.products.map((item) => <CartItem key={item.id} item={item} />)} + {cart?.products.map((item) => ( + <CartItem key={item.id} item={item} /> + ))} {cart?.products?.length === 0 && ( <div className='flex flex-col items-center'> - <Image src='/images/empty_cart.svg' alt='Empty Cart' width={450} height={450} /> - <div className='text-title-sm md:text-title-lg text-center font-semibold'>Keranjangnya masih kosong nih</div> - <div className='text-body-2 md:text-body-1 text-center mt-3'>Yuk, tambahin barang-barang yang kamu mau ke keranjang sekarang!<br />Ada banyak potongan belanjanya pakai kode voucher</div> - <Link href='/' className='btn-solid-red rounded-full text-body-1 mt-6'>Mulai Belanja</Link> + <Image + src='/images/empty_cart.svg' + alt='Empty Cart' + width={450} + height={450} + /> + <div className='text-title-sm md:text-title-lg text-center font-semibold'> + Keranjangnya masih kosong nih + </div> + <div className='text-body-2 md:text-body-1 text-center mt-3'> + Yuk, tambahin barang-barang yang kamu mau ke keranjang + sekarang! + <br /> + Ada banyak potongan belanjanya pakai kode voucher + </div> + <Link + href='/' + className='btn-solid-red rounded-full text-body-1 mt-6' + > + Mulai Belanja + </Link> </div> )} </div> </div> - - <div className={style['summary-wrapper']}> + <div + className={`${style['summary-wrapper']} ${ + useDivvice.isMobile && cart?.product_total === 0 ? 'hidden' : '' + }`} + > <div className={style['summary']}> - {useDivvice.isMobile && <CartSummaryMobile {...summary} isLoaded={!!cart} />} - {!useDivvice.isMobile && <CartSummary {...summary} isLoaded={!!cart} />} + {useDivvice.isMobile && ( + <CartSummaryMobile {...summary} isLoaded={!!cart} /> + )} + {!useDivvice.isMobile && ( + <CartSummary {...summary} isLoaded={!!cart} /> + )} <div className={style['summary-buttons']}> - <Tooltip label={hasSelectedPromo && 'Barang promo tidak dapat dibuat quotation'}> + <Tooltip + label={ + hasSelectedPromo && + 'Barang promo tidak dapat dibuat quotation' + } + > <Button colorScheme='yellow' w='full' @@ -95,10 +124,12 @@ const CartPage = () => { </Button> </Tooltip> - <Tooltip label={clsxm({ - 'Tidak ada item yang dipilih': !hasSelected, - 'Terdapat item yang tidak ada harga': hasSelectNoPrice - })}> + <Tooltip + label={clsxm({ + 'Tidak ada item yang dipilih': !hasSelected, + 'Terdapat item yang tidak ada harga': hasSelectNoPrice, + })} + > <Button colorScheme='red' w='full' @@ -114,7 +145,7 @@ const CartPage = () => { </div> </div> </> - ) -} + ); +}; -export default CartPage
\ No newline at end of file +export default CartPage; |
