summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/modules/cart/components/Detail.tsx83
-rw-r--r--src-migrate/modules/cart/components/ItemSelect.tsx3
-rw-r--r--src-migrate/modules/cart/styles/detail.module.css3
-rw-r--r--src-migrate/modules/cart/styles/item-promo.module.css2
-rw-r--r--src-migrate/pages/shop/cart.module.css31
-rw-r--r--src-migrate/pages/shop/cart.tsx91
6 files changed, 125 insertions, 88 deletions
diff --git a/src-migrate/modules/cart/components/Detail.tsx b/src-migrate/modules/cart/components/Detail.tsx
deleted file mode 100644
index ccb0bb4d..00000000
--- a/src-migrate/modules/cart/components/Detail.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import style from '../styles/detail.module.css'
-
-import React, { useEffect, useMemo } from 'react'
-import Link from 'next/link'
-import { Button, Tooltip } from '@chakra-ui/react'
-
-import { getAuth } from '~/common/libs/auth'
-import { useCartStore } from '../stores/useCartStore'
-
-import CartItem from './Item'
-import CartSummary from './Summary'
-
-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=''>
- <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 md:pl-6 mt-6 md:mt-0'>
- <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}
- as={Link}
- href='/shop/checkout'
- >
- Checkout
- </Button>
- </Tooltip>
- </div>
- </div>
- </div>
- </div>
- )
-}
-
-export default CartDetail \ No newline at end of file
diff --git a/src-migrate/modules/cart/components/ItemSelect.tsx b/src-migrate/modules/cart/components/ItemSelect.tsx
index 96e7c713..10d7493a 100644
--- a/src-migrate/modules/cart/components/ItemSelect.tsx
+++ b/src-migrate/modules/cart/components/ItemSelect.tsx
@@ -27,10 +27,11 @@ const CartItemSelect = ({ item }: Props) => {
}
return (
- <div className='w-5 my-auto'>
+ <div className='w-6 my-auto'>
{isLoad && (
<Spinner className='my-auto' size='sm' />
)}
+
{!isLoad && (
<Checkbox
borderColor='gray.600'
diff --git a/src-migrate/modules/cart/styles/detail.module.css b/src-migrate/modules/cart/styles/detail.module.css
deleted file mode 100644
index 42d492bb..00000000
--- a/src-migrate/modules/cart/styles/detail.module.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.wrapper {
- @apply flex flex-wrap;
-}
diff --git a/src-migrate/modules/cart/styles/item-promo.module.css b/src-migrate/modules/cart/styles/item-promo.module.css
index 5bc192c0..15bf8146 100644
--- a/src-migrate/modules/cart/styles/item-promo.module.css
+++ b/src-migrate/modules/cart/styles/item-promo.module.css
@@ -1,5 +1,5 @@
.wrapper {
- @apply md:ml-12 ml-8 mt-4 flex;
+ @apply md:ml-16 ml-8 mt-4 flex;
}
.imageWrapper {
diff --git a/src-migrate/pages/shop/cart.module.css b/src-migrate/pages/shop/cart.module.css
new file mode 100644
index 00000000..d523a55a
--- /dev/null
+++ b/src-migrate/pages/shop/cart.module.css
@@ -0,0 +1,31 @@
+.title {
+ @apply text-h-lg font-semibold;
+}
+
+.content {
+ @apply flex flex-wrap;
+}
+
+.item-wrapper {
+ @apply w-full md:w-3/4;
+}
+
+.item-skeleton {
+ @apply grid grid-cols-1 gap-y-4;
+}
+
+.items {
+ @apply flex flex-col gap-y-6 border-t border-gray-300 pt-6;
+}
+
+.summary-wrapper {
+ @apply w-full md:w-1/4 md:pl-6 mt-6 md:mt-0;
+}
+
+.summary {
+ @apply border border-gray-300 p-4 rounded-md sticky top-[180px];
+}
+
+.summary-buttons {
+ @apply grid grid-cols-2 gap-x-3 mt-6;
+}
diff --git a/src-migrate/pages/shop/cart.tsx b/src-migrate/pages/shop/cart.tsx
new file mode 100644
index 00000000..5016c9b5
--- /dev/null
+++ b/src-migrate/pages/shop/cart.tsx
@@ -0,0 +1,91 @@
+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 { getAuth } from '~/common/libs/auth'
+import { useCartStore } from '~/modules/cart/stores/useCartStore'
+
+import CartItem from '~/modules/cart/components/Item'
+import CartSummary from '~/modules/cart/components/Summary'
+
+const CartPage = () => {
+ 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['title']}>
+ Keranjang Belanja
+ </div>
+
+ <div className='h-6' />
+
+ <div className={style['content']}>
+ <div className={style['item-wrapper']}>
+ <div className={style['item-skeleton']}>
+ {!cart && <CartItem.Skeleton count={5} height='120px' />}
+ </div>
+
+ <div className={style['items']}>
+ {cart?.products.map((item) => <CartItem key={item.id} item={item} />)}
+ </div>
+ </div>
+
+ <div className={style['summary-wrapper']}>
+ <div className={style['summary']}>
+ <CartSummary {...summary} isLoaded={!!cart} />
+
+ <div className={style['summary-buttons']}>
+ <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}
+ as={Link}
+ href='/shop/checkout'
+ >
+ Checkout
+ </Button>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ </div>
+ </>
+ )
+}
+
+export default CartPage \ No newline at end of file