From cf92e065f057737071e6cd7c666a4f1c475bb613 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 15 Nov 2024 14:21:17 +0700 Subject: update pengajuan tempo --- src/lib/tempo/components/Tempo.jsx | 305 ++++++++++++++++++++++++------------- 1 file changed, 201 insertions(+), 104 deletions(-) (limited to 'src/lib') diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx index 3f6e36d1..ef516c64 100644 --- a/src/lib/tempo/components/Tempo.jsx +++ b/src/lib/tempo/components/Tempo.jsx @@ -4,6 +4,7 @@ import { EllipsisVerticalIcon, MagnifyingGlassIcon, } from '@heroicons/react/24/outline'; +import { Skeleton } from '@chakra-ui/react'; import { div, toQuery } from 'lodash-contrib'; import _ from 'lodash'; import { useRouter } from 'next/router'; @@ -25,33 +26,37 @@ import Menu from '@/lib/auth/components/Menu'; import odooApi from '@/core/api/odooApi'; import { getAuth } from '@/core/utils/auth'; import ProgressBar from '@ramonak/react-progress-bar'; +import FooterBanner from '~/modules/footer-banner'; const Tempo = () => { const auth = getAuth(); const router = useRouter(); - const { q = '', page = 1 } = router.query; + const { q = '', page = 1, limit = 15 } = router.query; - const limit = 15; + const [pageNew, setPageNew] = useState(page); + const [limitNew, setLimitNew] = useState(limit); const query = { name: q, - offset: (page - 1) * limit, - limit, + offset: (pageNew - 1) * limitNew, + limit: limitNew, }; const { invoices } = useInvoices({ query }); - + console.log('invoices', invoices); const [isLoading, setIsLoading] = useState(true); const [tempo, setTempo] = useState([]); const [inputQuery, setInputQuery] = useState(q); const [toOthers, setToOthers] = useState(null); - const pageCount = Math.ceil(invoices?.data?.invoiceTotal / limit); - let pageQuery = _.omit(query, ['limit', 'offset']); + const pageCount = Math.ceil(invoices?.data?.invoiceTotal / limitNew); + let pageQuery = _.omit(query, ['limitNew', 'offset']); + console.log('pageQuery1', pageQuery); pageQuery = _.pickBy(pageQuery, _.identity); + console.log('pageQuery2', pageQuery); pageQuery = toQuery(pageQuery); - + console.log('pageQuery3', pageQuery); const handleSubmit = (e) => { e.preventDefault(); - router.push(`/my/invoices?q=${inputQuery}`); + router.push(`/my/tempo?q=${inputQuery}`); }; useEffect(() => { const loadTempo = async () => { @@ -76,6 +81,8 @@ const Tempo = () => { if (Math.round((amountDue / limitTempo) * 100) >= 50) return 'Hampir Habis'; return ''; }; + const startItem = 1 + (pageNew - 1) * limitNew; + const endItem = Math.min(limitNew * pageNew, invoices?.data?.invoiceTotal); return ( <> @@ -83,26 +90,44 @@ const Tempo = () => {
-
+

Pembayaran Tempo

-

- Jenis Tempo Pembayaran Anda adalah :{' '} - {!isLoading && ( - - {tempo.paymentTerm} - - )} +

+ Jenis Tempo Pembayaran Anda adalah{' '} + + {' '} + {tempo.paymentTerm} +

Limit Tempo Terpakai

-

{!isLoading && currencyFormat(amountDue)}

+ + {currencyFormat(amountDue)} +

Limit Tempo

-

{!isLoading && currencyFormat(limitTempo)}

+ + {currencyFormat(limitTempo)} +
@@ -122,102 +147,174 @@ const Tempo = () => { {getLabel()}
+
+
+
+ + setInputQuery(e.target.value)} + /> +
+ {!invoices.isLoading && ( +
+

+ Menampilkan {startItem}-{endItem} dari{' '} + {invoices?.data?.invoiceTotal} +

+ +
+ )} +
-
-
- - setInputQuery(e.target.value)} - /> -
-
- - - - - - - - - - - - - - - {invoices.isLoading && ( +
No. InvoiceNo. TransaksiSalespersonTanggalJatuh TempoStatusTotal
+ - + + + + + + + - )} - {!invoices.isLoading && - (!invoices?.data?.invoices || - invoices?.data?.invoices?.length == 0) && ( + + + {invoices.isLoading && ( - + )} - {invoices.data?.invoices?.map((invoice) => ( - - - - - - - - - - ))} - -
-
- -
-
No. InvoiceNo. TransaksiSalespersonTanggalJatuh TempoStatusTotal
Tidak ada invoice +
+ +
+
- - {invoice.name} - - {invoice.purchaseOrderName || '-'}{invoice.sales}{invoice.invoiceDate} - {invoice.amountResidual > 0 ? ( -
- Belum Lunas -
- ) : ( -
- Lunas -
- )} -
- {invoice.amountResidual > 0 ? ( -
- Belum Lunas -
- ) : ( -
- Lunas -
- )} -
- {currencyFormat(invoice.amountTotal)} -
+ {!invoices.isLoading && + (!invoices?.data?.invoices || + invoices?.data?.invoices?.length == 0) && ( + + Tidak ada invoice + + )} + {invoices.data?.invoices?.map((invoice) => ( + + + + {invoice.name} + + + {invoice.salesOrder || '-'} + {invoice.sales} + {invoice.invoiceDate} + {invoice.invoiceDateDue} + + {invoice.amountResidual > 0 ? ( +
+ Belum Lunas +
+ ) : ( +
+ Lunas +
+ )} + + + {currencyFormat(invoice.amountTotal)} + + + ))} + + - + +
+
+ +
+
+
+

+ Jenis Tempo Pembayaran Anda adalah{' '} + + {' '} + {tempo.paymentTerm} + +

+
+
+
+

Limit Tempo Terpakai

+ + {currencyFormat(amountDue)} + +
+
+

Limit Tempo

+ + {currencyFormat(limitTempo)} + +
+
+
+
+ + + {getLabel()} + +
{ -- cgit v1.2.3