From 9622bff4d4902fcef81214236cc7ff035163e5e7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 13 Nov 2024 16:46:14 +0700 Subject: pengajuan tempo --- src/lib/tempo/components/Tempo.jsx | 277 +++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 src/lib/tempo/components/Tempo.jsx (limited to 'src/lib/tempo/components') diff --git a/src/lib/tempo/components/Tempo.jsx b/src/lib/tempo/components/Tempo.jsx new file mode 100644 index 00000000..9b68251c --- /dev/null +++ b/src/lib/tempo/components/Tempo.jsx @@ -0,0 +1,277 @@ +import { + CheckIcon, + ClockIcon, + EllipsisVerticalIcon, + MagnifyingGlassIcon, +} from '@heroicons/react/24/outline'; +import { toQuery } from 'lodash-contrib'; +import _ from 'lodash'; +import { useRouter } from 'next/router'; +import { useState } from 'react'; +import useInvoices from '../hooks/useInvoices'; +import Spinner from '@/core/components/elements/Spinner/Spinner'; +import Alert from '@/core/components/elements/Alert/Alert'; +import Pagination from '@/core/components/elements/Pagination/Pagination'; +import Link from '@/core/components/elements/Link/Link'; +import currencyFormat from '@/core/utils/currencyFormat'; +import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +import { downloadInvoice, downloadTaxInvoice } from '../utils/invoices'; +import MobileView from '@/core/components/views/MobileView'; +import DesktopView from '@/core/components/views/DesktopView'; +import Menu from '@/lib/auth/components/Menu'; + +const Tempo = () => { + const router = useRouter(); + const { q = '', page = 1 } = router.query; + + const limit = 15; + + const query = { + name: q, + offset: (page - 1) * limit, + limit, + }; + const { invoices } = useInvoices({ query }); + + const [inputQuery, setInputQuery] = useState(q); + const [toOthers, setToOthers] = useState(null); + + const pageCount = Math.ceil(invoices?.data?.invoiceTotal / limit); + let pageQuery = _.omit(query, ['limit', 'offset']); + pageQuery = _.pickBy(pageQuery, _.identity); + pageQuery = toQuery(pageQuery); + + const handleSubmit = (e) => { + e.preventDefault(); + router.push(`/my/invoices?q=${inputQuery}`); + }; + + return ( + <> + +
+
+ setInputQuery(e.target.value)} + /> + +
+ + {invoices.isLoading && ( +
+ +
+ )} + + {!invoices.isLoading && invoices.data?.invoices?.length === 0 && ( + + Tidak ada invoice + + )} + + {invoices.data?.invoices?.map((invoice, index) => ( +
+
+ + + No. Invoice + +

{invoice.name}

+ +
+ {invoice.amountResidual > 0 ? ( +
+ Belum Lunas +
+ ) : ( +
Lunas
+ )} + setToOthers(invoice)} + /> +
+
+ +
+

{invoice.invoiceDate}

+

{invoice.paymentTerm}

+
+
+
+
+ + No. Purchase Order + +

+ {invoice.purchaseOrderName || '-'} +

+
+
+ + Total Invoice + +

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ + {invoice.efaktur ? ( +
+ + Faktur Pajak +
+ ) : ( +
+ + Faktur Pajak +
+ )} +
+ ))} + + + + setToOthers(null)} + > +
+ + +
+
+
+
+ + +
+
+ +
+
+
+

+ Invoice & Faktur Pajak{' '} + {invoices?.data?.invoices + ? `(${invoices?.data?.invoices.length})` + : ''} +

+
+ setInputQuery(e.target.value)} + /> + +
+
+ + + + + + + + + + + + + + {invoices.isLoading && ( + + + + )} + {!invoices.isLoading && + (!invoices?.data?.invoices || + invoices?.data?.invoices?.length == 0) && ( + + + + )} + {invoices.data?.invoices?.map((invoice) => ( + + + + + + + + + ))} + +
No. InvoiceNo. POTanggalSalespersonStatusTotal
+
+ +
+
Tidak ada invoice
+ + {invoice.name} + + {invoice.purchaseOrderName || '-'}{invoice.invoiceDate}{invoice.sales} + {invoice.amountResidual > 0 ? ( +
+ Belum Lunas +
+ ) : ( +
+ Lunas +
+ )} +
+ {currencyFormat(invoice.amountTotal)} +
+ + +
+
+
+ + ); +}; + +export default Tempo; -- cgit v1.2.3