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/components/BottomPopup.js | 25 +++++++++++++ src/components/Filter.js | 13 ++----- src/components/Layout.js | 4 +- 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 +++++------ 7 files changed, 123 insertions(+), 25 deletions(-) create mode 100644 src/components/BottomPopup.js create mode 100644 src/pages/my/transactions/index.js diff --git a/src/components/BottomPopup.js b/src/components/BottomPopup.js new file mode 100644 index 00000000..b7f5f2de --- /dev/null +++ b/src/components/BottomPopup.js @@ -0,0 +1,25 @@ +import CloseIcon from "../icons/close.svg"; + +const BottomPopup = ({ + active = false, + title, + children, + closePopup = () => {} +}) => { + return ( + <> +
+
+
+

{ title }

+ +
+ { children } +
+ + ); +}; + +export default BottomPopup; \ No newline at end of file diff --git a/src/components/Filter.js b/src/components/Filter.js index 92a28e09..f2051ba8 100644 --- a/src/components/Filter.js +++ b/src/components/Filter.js @@ -1,6 +1,6 @@ import { useRouter } from "next/router"; import { useEffect, useState } from "react"; -import CloseIcon from "../icons/close.svg"; +import BottomPopup from "./BottomPopup"; const Filter = ({ isActive, @@ -104,14 +104,7 @@ const Filter = ({ return ( <> -
-
-
-

Filter Produk

- -
+
{(selectedBrand || selectedCategory || priceFrom || priceTo || orderBy) && (
-
+ ) }; diff --git a/src/components/Layout.js b/src/components/Layout.js index 24017c03..fd507963 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -8,9 +8,9 @@ export default function Layout({ children, ...pageProps }) { return children && ( 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)} />
-
- +
+