From 6b4371c096030354f09465e3773200529cf727d1 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 21 Jan 2023 08:19:56 +0700 Subject: Detail transaction list --- src/pages/my/address/[id]/edit.js | 2 +- src/pages/my/menu.js | 6 ++- src/pages/my/transactions/index.js | 76 ++++++++++++++++++++++++++++++++++++++ src/pages/shop/checkout.js | 22 +++++------ 4 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 src/pages/my/transactions/index.js (limited to 'src/pages') diff --git a/src/pages/my/address/[id]/edit.js b/src/pages/my/address/[id]/edit.js index 13f166ab..e65ba699 100644 --- a/src/pages/my/address/[id]/edit.js +++ b/src/pages/my/address/[id]/edit.js @@ -37,7 +37,7 @@ export async function getServerSideProps( context ) { mobile: address.mobile, street: address.street, zip: address.zip, - city: address.city?.id, + city: address.city?.id || '', oldDistrict: address.district?.id || '', district: '', oldSubDistrict: address.sub_district?.id || '', diff --git a/src/pages/my/menu.js b/src/pages/my/menu.js index 0db6b011..f43c1fe9 100644 --- a/src/pages/my/menu.js +++ b/src/pages/my/menu.js @@ -43,7 +43,11 @@ export default function MyMenu() {

{ auth?.name }

-
Akun Bisnis
+ { auth?.company ? ( +
Akun Bisnis
+ ) : ( +
Akun Individu
+ ) }
diff --git a/src/pages/my/transactions/index.js b/src/pages/my/transactions/index.js new file mode 100644 index 00000000..eb5f99a1 --- /dev/null +++ b/src/pages/my/transactions/index.js @@ -0,0 +1,76 @@ +import { useRouter } from "next/router"; +import AppBar from "../../../components/AppBar"; +import BottomPopup from "../../../components/BottomPopup"; +import Layout from "../../../components/Layout"; +import WithAuth from "../../../components/WithAuth"; +import { useEffect, useState } from "react"; +import { useAuth } from "../../../helpers/auth"; +import apiOdoo from "../../../helpers/apiOdoo"; +import currencyFormat from "../../../helpers/currencyFormat"; +import { EllipsisVerticalIcon } from "@heroicons/react/24/outline"; + +export default function Transactions() { + const [ auth ] = useAuth(); + const router = useRouter(); + + const [ transactions, setTransactions ] = useState([]); + const [ activePopupId, setActivePopupId ] = useState(null); + + useEffect(() => { + const loadTransactions = async () => { + if (auth) { + const dataTransactions = await apiOdoo('GET', `/api/v1/sale_order?partner_id=${auth?.partner_id}`); + setTransactions(dataTransactions); + }; + } + loadTransactions(); + }, [ auth ]); + + return ( + + + + +
+ { transactions?.sale_orders?.map((transaction, index) => ( +
+
+
+ No. Transaksi +

{ transaction.name }

+
+
+
Pending
+ setActivePopupId(transaction.id)} /> +
+
+
+
+ Dilayani Oleh +

{ transaction.sales }

+
+
+ Total Harga +

{ currencyFormat(transaction.amount_total) }

+
+
+
+ )) } +
+ + { transactions?.sale_orders?.length > 0 && ( + setActivePopupId(null)} + > +
+

Download Quotation

+

Batalkan Transaksi

+
+
+ ) } +
+
+ ); +}; \ No newline at end of file diff --git a/src/pages/shop/checkout.js b/src/pages/shop/checkout.js index 7b37eaad..424b903d 100644 --- a/src/pages/shop/checkout.js +++ b/src/pages/shop/checkout.js @@ -122,8 +122,8 @@ export default function Checkout() { 'partner_invoice_id': selectedAddress.invoicing.id, 'order_line': JSON.stringify(productOrder) }; - if (auth?.company && (!poNumber || !poFile)) { - toast.error('Mohon isi nomor dan file PO', { + if (auth?.company && !poFile) { + toast.error('Mohon isi file PO', { position: 'bottom-center' }); return; @@ -301,15 +301,10 @@ export default function Checkout() {
-

- Purchase Order - - { ' (' + (auth?.company ? 'Wajib diisi' : 'Opsional') + ')' } - -

+

Purchase Order

-
+
setPoNumber(e.target.value)} />
-
- +
+