summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-01-04 10:05:25 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-01-04 10:05:25 +0700
commit67398e6f10d6f7729d8f1ace7005ef13d32c5ddd (patch)
tree7d47ad6c1a7093e595e22bcecb40016a626162f6 /src-migrate/modules/cart
parent89f32128f37d99b490de7590e2116a9cfd853f89 (diff)
Update promotion program feature
Diffstat (limited to 'src-migrate/modules/cart')
-rw-r--r--src-migrate/modules/cart/components/Detail.tsx1
-rw-r--r--src-migrate/modules/cart/components/Item.tsx9
-rw-r--r--src-migrate/modules/cart/components/ItemPromo.tsx3
-rw-r--r--src-migrate/modules/cart/stores/useCartStore.ts3
-rw-r--r--src-migrate/modules/cart/styles/item-promo.module.css6
-rw-r--r--src-migrate/modules/cart/styles/item.module.css2
6 files changed, 12 insertions, 12 deletions
diff --git a/src-migrate/modules/cart/components/Detail.tsx b/src-migrate/modules/cart/components/Detail.tsx
index c9de086b..ccb0bb4d 100644
--- a/src-migrate/modules/cart/components/Detail.tsx
+++ b/src-migrate/modules/cart/components/Detail.tsx
@@ -38,7 +38,6 @@ const CartDetail = () => {
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'>
diff --git a/src-migrate/modules/cart/components/Item.tsx b/src-migrate/modules/cart/components/Item.tsx
index 92beda86..baf48bb6 100644
--- a/src-migrate/modules/cart/components/Item.tsx
+++ b/src-migrate/modules/cart/components/Item.tsx
@@ -3,6 +3,9 @@ import style from '../styles/item.module.css'
import Image from 'next/image'
import React from 'react'
import { Skeleton, SkeletonProps, Tooltip } from '@chakra-ui/react'
+import { InfoIcon } from 'lucide-react'
+
+import { PROMO_CATEGORY } from '~/constants/promotion'
import formatCurrency from '~/common/libs/formatCurrency'
import { CartItem as CartItemProps } from '~/common/types/cart'
@@ -10,8 +13,6 @@ import { CartItem as CartItemProps } from '~/common/types/cart'
import CartItemPromo from './ItemPromo'
import CartItemAction from './ItemAction'
import CartItemSelect from './ItemSelect'
-import { PROMO_CATEGORY } from '~/constants/promotion'
-import { InfoIcon } from 'lucide-react'
type Props = {
item: CartItemProps
@@ -37,7 +38,7 @@ const CartItem = ({ item, editable = true }: Props) => {
<div>
Selamat! Pembelian anda lebih hemat {' '}
<span className={style.savingAmt}>
- Rp {formatCurrency((item.package_price || 0) - item.subtotal)}
+ Rp{formatCurrency((item.package_price || 0) * item.quantity - item.subtotal)}
</span>
</div>
</div>
@@ -61,7 +62,7 @@ const CartItem = ({ item, editable = true }: Props) => {
Rp {formatCurrency((item.package_price || 0))}
</span>
<span className={style.price}>
- Rp {formatCurrency(item.subtotal)}
+ Rp {formatCurrency(item.price.price)}
</span>
</div>
)}
diff --git a/src-migrate/modules/cart/components/ItemPromo.tsx b/src-migrate/modules/cart/components/ItemPromo.tsx
index 951d4d6a..bb286e8b 100644
--- a/src-migrate/modules/cart/components/ItemPromo.tsx
+++ b/src-migrate/modules/cart/components/ItemPromo.tsx
@@ -5,7 +5,6 @@ import React from 'react'
import { CartProduct } from '~/common/types/cart'
-
type Props = {
product: CartProduct
}
@@ -19,7 +18,7 @@ const CartItemPromo = ({ product }: Props) => {
<div className={style.details}>
<div className={style.name}>{product.display_name}</div>
- <div className='flex'>
+ <div className='flex w-full'>
<div className="flex flex-col">
<div className={style.code}>{product.code}</div>
<div>
diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts
index d3eaadb7..0643b8e6 100644
--- a/src-migrate/modules/cart/stores/useCartStore.ts
+++ b/src-migrate/modules/cart/stores/useCartStore.ts
@@ -48,7 +48,8 @@ const computeSummary = (cart: CartProps) => {
if (!item.selected) continue;
let price = 0;
- if (item.cart_type === 'promotion') price = item?.package_price || 0;
+ if (item.cart_type === 'promotion')
+ price = (item?.package_price || 0) * item.quantity;
else if (item.cart_type === 'product')
price = item.price.price * item.quantity;
diff --git a/src-migrate/modules/cart/styles/item-promo.module.css b/src-migrate/modules/cart/styles/item-promo.module.css
index 17dbf1c7..5bc192c0 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-16 ml-12 mt-4 flex;
+ @apply md:ml-12 ml-8 mt-4 flex;
}
.imageWrapper {
@@ -14,7 +14,7 @@
}
.details {
- @apply ml-4 flex flex-col gap-y-1;
+ @apply ml-4 w-full flex flex-col gap-y-1;
}
.name {
@@ -27,5 +27,5 @@
}
.quantity {
- @apply w-12 min-w-[48px] py-2.5 bg-gray-100 border border-gray-300 h-fit my-auto rounded-md ml-auto font-medium text-center;
+ @apply w-12 min-w-[42px] py-2.5 bg-gray-100 border border-gray-300 h-fit my-auto rounded-md ml-auto font-medium text-center;
}
diff --git a/src-migrate/modules/cart/styles/item.module.css b/src-migrate/modules/cart/styles/item.module.css
index 6380cdad..dfbbf5e8 100644
--- a/src-migrate/modules/cart/styles/item.module.css
+++ b/src-migrate/modules/cart/styles/item.module.css
@@ -7,7 +7,7 @@
}
.badgeType {
- @apply min-w-fit p-2 flex gap-x-1.5 rounded-md border border-danger-500 text-danger-500;
+ @apply min-w-fit p-2 flex items-center gap-x-1.5 rounded-md border border-danger-500 text-danger-500;
}
.mainProdWrapper {