From 6f4ecaa362c2333c59d08f775c13fa1c5bf5e13b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 9 Jan 2025 08:53:25 +0700 Subject: update tempo --- .../elements/Navbar/NavbarUserDropdown.jsx | 6 +- src/lib/auth/components/Menu.jsx | 5 +- src/lib/pengajuan-tempo/component/Stepper.jsx | 2 +- src/lib/tempo/components/Tempo.jsx | 194 +++++++++++++++++---- 4 files changed, 167 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx index 83407bfd..7ed269b8 100644 --- a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx +++ b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx @@ -22,9 +22,9 @@ const NavbarUserDropdown = () => { Daftar Pengiriman Invoice & Faktur Pajak {atuh && - (atuh.partnerTempo - ? atuh.partnerTempo?.toLowerCase().includes('tempo') - : '' || atuh.tempoProgres === 'review') && ( + atuh.partnerTempo && + (atuh.partnerTempo?.toLowerCase().includes('tempo') || + atuh.tempoProgres === 'review') && ( Pembayaran Tempo )} diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index 82a4de81..b562878d 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -63,8 +63,9 @@ const Menu = () => { {auth && - (auth?.partnerTempo.toLowerCase().includes('tempo') || - auth.tempoProgres == 'review') && ( + auth.partnerTempo && + (auth.partnerTempo?.toLowerCase().includes('tempo') || + auth.tempoProgres === 'review') && (
{ {isFirstStep(index) ? null : (
diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx index 6f0a2a8c..f2a9e650 100644 --- a/src/lib/tempo/components/Tempo.jsx +++ b/src/lib/tempo/components/Tempo.jsx @@ -29,18 +29,22 @@ import ProgressBar from '@ramonak/react-progress-bar'; import FooterBanner from '~/modules/footer-banner'; import Image from '~/components/ui/image'; import useDevice from '@/core/hooks/useDevice'; +import { Tooltip } from '@chakra-ui/react'; +import { InfoIcon } from 'lucide-react'; const Tempo = () => { const auth = getAuth(); const router = useRouter(); - const { q = '', page = 1, limit = 15 } = router.query; + const { q = '', page = 1, limit = 15, status = 0 } = router.query; const { isDesktop, isMobile } = useDevice(); const [pageNew, setPageNew] = useState(page); const [limitNew, setLimitNew] = useState(limit); + const [statusNew, setStatusNew] = useState(status); const query = { name: q, offset: (pageNew - 1) * limitNew, limit: limitNew, + status: statusNew, }; const { invoices } = useInvoices({ query }); const [isLoading, setIsLoading] = useState(true); @@ -71,7 +75,7 @@ const Tempo = () => { const limitTempo = Math.round( parseInt(tempo.amountDue + tempo.remainingLimit) ); - const amountDue = Math.round(parseInt(tempo.amountDue)); + const amountDue = Math.round(parseInt(tempo.amountDue + tempo.amountDueSale)); const getLabel = () => { if (Math.round((amountDue / limitTempo) * 100) >= 100) return 'Limit Tempo mencapai batas'; @@ -79,7 +83,13 @@ const Tempo = () => { return ''; }; const startItem = 1 + (pageNew - 1) * limitNew; - const endItem = Math.min(limitNew * pageNew, invoices?.data?.invoiceTotal); + const endItem = Math.min( + limitNew * pageNew, + invoices?.data?.invoiceTotal + + (statusNew === 0 || statusNew === 2 || statusNew === 4 + ? invoices?.data?.saleOrderTotal + : 0) + ); const getDueDate = (invoice) => { const [day, month, year] = invoice.split('/'); const dueDate = new Date(year, month - 1, day); // Konversi ke objek Date @@ -97,6 +107,13 @@ const Tempo = () => { return formattedDate; }; + + const handleClick = () => { + setStatusNew((prevStatus) => (prevStatus === 4 ? 0 : 4)); // Toggle antara 4 dan 0 + }; + const handleClickInvoice = () => { + setStatusNew((prevStatus) => (prevStatus === 1 ? 0 : 1)); // Toggle antara 4 dan 0 + }; return ( <> @@ -107,6 +124,27 @@ const Tempo = () => {

Pembayaran Tempo

+
+

+ Kredit Limit Anda + + {limitTempo ? currencyFormat(limitTempo) : '-'} + +

+ +
+ +
+
+

Status Detail Tempo Pembayaran Anda adalah{' '} {

-
-
-

Kredit Limit Terpakai

- - {amountDue ? currencyFormat(amountDue) : '-'} - -
+

Sisa Kredit Limit

{limitTempo && amountDue ? currencyFormat( @@ -148,31 +175,72 @@ const Tempo = () => { : '-'}
-
-

Kredit Limit

+
+
+

Kredit Limit Terpakai

+ + {amountDue ? currencyFormat(amountDue) : '-'} + +
+
+ {tempo.amountDueTotal + ? tempo.amountDueTotal + + tempo.amountDueSaleTotal + + ` Transaksi` + : ''} +
+
+
+
+

Jatuh Tempo

+ + {tempo.amountJatuhTempo + ? currencyFormat(tempo.amountJatuhTempo) + : '-'} + +
+
+ {tempo.amountJatuhTempoTotal + ? tempo.amountJatuhTempoTotal + ` Invoice` + : ''} +
+
+ {/*
+

Jatuh Tempo

- {limitTempo ? currencyFormat(limitTempo) : '-'} + {tempo.amountJatuhTempo + ? currencyFormat(tempo.amountJatuhTempo) + : '-'} -
+
*/}
- {getLabel()} @@ -187,7 +255,7 @@ const Tempo = () => { />
) : ( -
+
@@ -236,6 +320,48 @@ const Tempo = () => { Total + + {/* {invoices.isLoading && ( + + +
+ +
+ + + )} */} + {/* {!invoices.isLoading && + (!invoices?.data?.saleOrders || + invoices?.data?.saleOrders?.length == 0) && ( + + Tidak ada orders + + )} */} + {(statusNew == 0 || statusNew == 2 || statusNew == 4) && + invoices.data?.saleOrders?.map((orders) => ( + + {orders.salesOrder || '-'} + + + {orders.name} + + + {orders.sales} + {orders.dateOrder.split(' ')[0]} + - + + { +
+ Belum Jatuh Tempo +
+ } + + + {currencyFormat(orders.amountTotal)} + + + ))} + {invoices.isLoading && ( -- cgit v1.2.3