summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart/components/CartSummaryMobile.tsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-06-21 11:01:35 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-06-21 11:01:35 +0700
commit220190db66bcc1c6db78180c593f21e9cf8f363c (patch)
tree1517faa9636a6b3b2cc8d468a57b1fe476c229d7 /src-migrate/modules/cart/components/CartSummaryMobile.tsx
parent208b234320b6c42491a4e87a1c3db3abab9c1715 (diff)
parent1cf754b4d8da1aa28700ffc3dad67081f6daf9a5 (diff)
Merge branch 'promotion-program' into feature/all-promotion
Diffstat (limited to 'src-migrate/modules/cart/components/CartSummaryMobile.tsx')
-rw-r--r--src-migrate/modules/cart/components/CartSummaryMobile.tsx111
1 files changed, 111 insertions, 0 deletions
diff --git a/src-migrate/modules/cart/components/CartSummaryMobile.tsx b/src-migrate/modules/cart/components/CartSummaryMobile.tsx
new file mode 100644
index 00000000..d9f72e0e
--- /dev/null
+++ b/src-migrate/modules/cart/components/CartSummaryMobile.tsx
@@ -0,0 +1,111 @@
+import style from '../styles/summary.module.css';
+
+import React, { useState } from 'react';
+import formatCurrency from '~/libs/formatCurrency';
+import clsxm from '~/libs/clsxm';
+import { Button, Skeleton } from '@chakra-ui/react';
+import _ from 'lodash';
+import { ChevronDownIcon } from '@heroicons/react/24/outline';
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
+import useDevice from '@/core/hooks/useDevice';
+
+type Props = {
+ total?: number;
+ discount?: number;
+ subtotal?: number;
+ tax?: number;
+ shipping?: number;
+ grandTotal?: number;
+ isLoaded: boolean;
+};
+
+const CartSummaryMobile = ({
+ total,
+ discount,
+ subtotal,
+ tax,
+ shipping,
+ grandTotal,
+ isLoaded = false,
+}: Props) => {
+ const [showPopup, setShowPopup] = useState(false);
+ return (
+ <>
+ <BottomPopup
+ className=' !h-[35%]'
+ title='Ringkasan Pensanan'
+ active={showPopup}
+ close={() => setShowPopup(false)}
+ >
+ <div className='mt-4'>
+ <div className='flex flex-col gap-y-3'>
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.label}>Total Belanja</span>
+ <span className={style.value}>
+ Rp {formatCurrency(subtotal || 0)}
+ </span>
+ </Skeleton>
+
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.label}>Total Diskon</span>
+ <span className={clsxm(style.value, style.discount)}>
+ - Rp {formatCurrency(discount || 0)}
+ </span>
+ </Skeleton>
+
+ <div className={style.divider} />
+
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.label}>Subtotal</span>
+ <span className={style.value}>
+ Rp {formatCurrency(total || 0)}
+ </span>
+ </Skeleton>
+
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.label}>Tax 11%</span>
+ <span className={style.value}>Rp {formatCurrency(tax || 0)}</span>
+ </Skeleton>
+
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.label}>Biaya Kirim</span>
+ <span className={style.value}>
+ Rp {formatCurrency(shipping || 0)}
+ </span>
+ </Skeleton>
+
+ <div className={style.divider} />
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={clsxm(style.label, style.grandTotal)}>
+ Grand Total
+ </span>
+ <span className={style.value}>
+ Rp {formatCurrency(grandTotal || 0)}
+ </span>
+ </Skeleton>
+ </div>
+ </div>
+ </BottomPopup>
+ <div className='flex flex-col gap-y-3'>
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={clsxm(style.label, style.grandTotal)}>
+ Grand Total
+ </span>
+ <button
+ onClick={() => setShowPopup(true)}
+ className='bg-gray-300 w-6 h-6 items-center justify-center cursor-pointer hover:bg-red-400 md:hidden '
+ >
+ <ChevronDownIcon className='h-6 w-6 text-white' />
+ </button>
+ </Skeleton>
+ <Skeleton isLoaded={isLoaded} className={style.line}>
+ <span className={style.value}>
+ Rp {formatCurrency(grandTotal || 0)}
+ </span>
+ </Skeleton>
+ </div>
+ </>
+ );
+};
+
+export default CartSummaryMobile;