From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src/pages/my/invoices.js | 180 ----------------------------------------------- 1 file changed, 180 deletions(-) delete mode 100644 src/pages/my/invoices.js (limited to 'src/pages/my/invoices.js') diff --git a/src/pages/my/invoices.js b/src/pages/my/invoices.js deleted file mode 100644 index 9b2e77dc..00000000 --- a/src/pages/my/invoices.js +++ /dev/null @@ -1,180 +0,0 @@ -import WithAuth from "@/components/auth/WithAuth" -import Alert from "@/components/elements/Alert" -import Link from "@/components/elements/Link" -import Pagination from "@/components/elements/Pagination" -import AppBar from "@/components/layouts/AppBar" -import Layout from "@/components/layouts/Layout" -import apiOdoo from "@/core/utils/apiOdoo" -import { useAuth } from "@/core/utils/auth" -import currencyFormat from "@/core/utils/currencyFormat" -import useBottomPopup from "@/lib/elements/hooks/useBottomPopup" -import { CheckIcon, ClockIcon, EllipsisVerticalIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline" -import { useRouter } from "next/router" -import { useEffect, useRef, useState } from "react" - -export default function Invoices() { - const [ auth ] = useAuth() - const router = useRouter() - const { - q, - page = 1 - } = router.query - - const [ invoices, setInvoices ] = useState([]) - - const [ pageCount, setPageCount ] = useState(0) - const [ isLoading, setIsLoading ] = useState(true) - - const searchQueryRef = useRef() - - useEffect(() => { - const loadInvoices = async () => { - if (auth) { - const limit = 10 - let offset = (page - 1) * 10 - let queryParams = [`limit=${limit}`, `offset=${offset}`] - if (q) queryParams.push(`name=${q}`) - queryParams = queryParams.join('&') - queryParams = queryParams ? '?' + queryParams : '' - - const dataInvoices = await apiOdoo('GET', `/api/v1/partner/${auth.partner_id}/invoice${queryParams}`) - setInvoices(dataInvoices) - setPageCount(Math.ceil(dataInvoices.sale_order_total / limit)) - setIsLoading(false) - } - } - loadInvoices() - }, [ auth, q, page ]) - - const actionSearch = (e) => { - e.preventDefault() - let queryParams = [] - if (searchQueryRef.current.value) queryParams.push(`q=${searchQueryRef.current.value}`) - queryParams = queryParams.join('&') - queryParams = queryParams ? `?${queryParams}` : '' - router.push(`/my/invoices${queryParams}`) - } - - const downloadInvoice = (data) => { - const url = `${process.env.ODOO_HOST}/api/v1/download/invoice/${data.id}/${data.token}` - window.open(url, 'download') - closePopup() - } - - const downloadTaxInvoice = (data) => { - const url = `${process.env.ODOO_HOST}/api/v1/download/tax-invoice/${data.id}/${data.token}` - window.open(url, 'download') - closePopup() - } - - const childrenPopup = (data) => ( -
- - -
- ) - - const { - closePopup, - openPopup, - BottomPopup - } = useBottomPopup({ - title: 'Lainnya', - children: childrenPopup - }) - - return ( - - - - -
- - -
- -
- { invoices?.invoice_total === 0 && !isLoading && ( - - Invoice tidak ditemukan - - ) } - { invoices?.invoices?.map((invoice, index) => ( -
-
- - No. Invoice -

{ invoice.name }

- -
- { invoice.amount_residual > 0 ? ( -
Belum Lunas
- ) : ( -
Lunas
- ) } - openPopup(invoice)} /> -
-
- -
-

- { invoice.invoice_date } -

-

- { invoice.payment_term } -

-
-
-
-
- No. Purchase Order -

{ invoice.purchase_order_name || '-' }

-
-
- Total Invoice -

{ currencyFormat(invoice.amount_total) }

-
-
- - { invoice.efaktur ? ( -
- - Faktur Pajak -
- ) : ( -
- - Faktur Pajak -
- ) } -
- )) } -
- -
- -
- { BottomPopup } -
-
- ) -} \ No newline at end of file -- cgit v1.2.3