summaryrefslogtreecommitdiff
path: root/src/pages/my/invoices.js
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-06 16:15:14 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-06 16:15:14 +0700
commite561175d7167da3f6ac25200ad3cce63ea38e20b (patch)
tree0ad04bc66ef2b5ca23f35bfa9614731e1240d9f3 /src/pages/my/invoices.js
parent620223f151700bbd91a33d32e2a4c29d4c287e9d (diff)
no message
Diffstat (limited to 'src/pages/my/invoices.js')
-rw-r--r--src/pages/my/invoices.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/pages/my/invoices.js b/src/pages/my/invoices.js
index a86ddffc..ed9ba660 100644
--- a/src/pages/my/invoices.js
+++ b/src/pages/my/invoices.js
@@ -6,6 +6,7 @@ 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";
@@ -54,6 +55,45 @@ export default function Invoices() {
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) => (
+ <div className="flex flex-col gap-y-6">
+ <button
+ className="text-left disabled:opacity-60"
+ onClick={() => downloadInvoice(data)}
+ >
+ Download Faktur Pembelian
+ </button>
+ <button
+ className="text-left disabled:opacity-60"
+ disabled={!data?.efaktur}
+ onClick={() => downloadTaxInvoice(data)}
+ >
+ Download Faktur Pajak
+ </button>
+ </div>
+ );
+
+ const {
+ closePopup,
+ openPopup,
+ BottomPopup
+ } = useBottomPopup({
+ title: 'Lainnya',
+ children: childrenPopup
+ });
+
return (
<WithAuth>
<Layout>
@@ -91,7 +131,7 @@ export default function Invoices() {
) : (
<div className="badge-solid-green h-fit ml-auto">Lunas</div>
) }
- <EllipsisVerticalIcon className="w-5 h-5" onClick={() => {}} />
+ <EllipsisVerticalIcon className="w-5 h-5" onClick={() => openPopup(invoice)} />
</div>
</div>
<Link href={`/my/invoice/${invoice.id}`}>
@@ -129,6 +169,7 @@ export default function Invoices() {
</div>
)) }
</div>
+ { BottomPopup }
</Layout>
</WithAuth>
);