summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/cart')
-rw-r--r--src-migrate/modules/cart/components/CartSummaryMobile.tsx3
-rw-r--r--src-migrate/modules/cart/components/Summary.tsx3
-rw-r--r--src-migrate/modules/cart/stores/useCartStore.ts14
3 files changed, 13 insertions, 7 deletions
diff --git a/src-migrate/modules/cart/components/CartSummaryMobile.tsx b/src-migrate/modules/cart/components/CartSummaryMobile.tsx
index d9f72e0e..02258204 100644
--- a/src-migrate/modules/cart/components/CartSummaryMobile.tsx
+++ b/src-migrate/modules/cart/components/CartSummaryMobile.tsx
@@ -29,6 +29,7 @@ const CartSummaryMobile = ({
isLoaded = false,
}: Props) => {
const [showPopup, setShowPopup] = useState(false);
+ const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0;
return (
<>
<BottomPopup
@@ -63,7 +64,7 @@ const CartSummaryMobile = ({
</Skeleton>
<Skeleton isLoaded={isLoaded} className={style.line}>
- <span className={style.label}>Tax 11%</span>
+ <span className={style.label}>Tax {((PPN - 1) * 100).toFixed(0)}%</span>
<span className={style.value}>Rp {formatCurrency(tax || 0)}</span>
</Skeleton>
diff --git a/src-migrate/modules/cart/components/Summary.tsx b/src-migrate/modules/cart/components/Summary.tsx
index 2e55c8df..0af5ab18 100644
--- a/src-migrate/modules/cart/components/Summary.tsx
+++ b/src-migrate/modules/cart/components/Summary.tsx
@@ -25,6 +25,7 @@ const CartSummary = ({
grandTotal,
isLoaded = false,
}: Props) => {
+ const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0;
return (
<>
<div className='text-h-sm font-medium'>Ringkasan Pesanan</div>
@@ -50,7 +51,7 @@ const CartSummary = ({
</Skeleton>
<Skeleton isLoaded={isLoaded} className={style.line}>
- <span className={style.label}>Tax 11%</span>
+ <span className={style.label}>Tax {((PPN - 1) * 100).toFixed(0)}%</span>
<span className={style.value}>Rp {formatCurrency(tax || 0)}</span>
</Skeleton>
diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts
index c2ebf50f..e7d2cdd3 100644
--- a/src-migrate/modules/cart/stores/useCartStore.ts
+++ b/src-migrate/modules/cart/stores/useCartStore.ts
@@ -43,17 +43,20 @@ export const useCartStore = create<State & Action>((set, get) => ({
updateCartItem: (updatedCart) => {
const cart = get().cart;
if (!cart) return;
-
+
set({ cart: updatedCart });
const summary = computeSummary(updatedCart);
set({ summary });
},
-
+
}));
const computeSummary = (cart: CartProps) => {
let subtotal = 0;
let discount = 0;
+
+ const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0;
+
for (const item of cart?.products) {
if (!item.selected) continue;
@@ -67,8 +70,9 @@ const computeSummary = (cart: CartProps) => {
discount += price - item.price.price_discount * item.quantity;
}
let total = subtotal - discount;
- let tax = Math.round(total * 0.11);
- let grandTotal = total + tax;
+ let grandTotal = total * PPN;
+ let tax = grandTotal - total;
+ // let grandTotal = total + tax;
- return { subtotal, discount, total, tax, grandTotal };
+ return { subtotal, discount, total, grandTotal, tax };
}; \ No newline at end of file