From 50d7157be3871f671ddfabc699a21733fa74a1b8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 21 Jan 2023 13:06:19 +0700 Subject: Detail transaction page --- src/components/AppBar.js | 4 +- src/pages/my/transactions/[slug].js | 128 ++++++++++++++++++++++++++++++++++++ src/pages/my/transactions/index.js | 21 +++--- src/pages/shop/checkout.js | 3 +- 4 files changed, 142 insertions(+), 14 deletions(-) create mode 100644 src/pages/my/transactions/[slug].js diff --git a/src/components/AppBar.js b/src/components/AppBar.js index aeffdf12..4cac8ce5 100644 --- a/src/components/AppBar.js +++ b/src/components/AppBar.js @@ -1,4 +1,4 @@ -import { ArrowLeftIcon, HeartIcon, HomeIcon } from "@heroicons/react/24/outline"; +import { ChevronLeftIcon, HeartIcon, HomeIcon } from "@heroicons/react/24/outline"; import Head from "next/head"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; @@ -35,7 +35,7 @@ const AppBar = ({ title }) => { {/* --- Start Title */}

{ title }

diff --git a/src/pages/my/transactions/[slug].js b/src/pages/my/transactions/[slug].js new file mode 100644 index 00000000..91b686d6 --- /dev/null +++ b/src/pages/my/transactions/[slug].js @@ -0,0 +1,128 @@ +import { ArrowDownOnSquareIcon, ArrowDownTrayIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon } from "@heroicons/react/24/outline"; +import AppBar from "../../../components/AppBar"; +import Layout from "../../../components/Layout"; +import LineDivider from "../../../components/LineDivider"; +import WithAuth from "../../../components/WithAuth"; +import { useState } from "react"; + +const Row = ({ label, children }) => ( +
+

{ label }

+
+ { children } +
+
+); + +const Section = ({ children }) => ( +
+ { children } +
+); + +const TitleRow = ({ label, active, onClick }) => ( +
+

{ label }

+ { onClick && ( active ? ( + + ) : ( + + ) ) } +
+); + +export default function DetailTransactions() { + const [ activeSection, setActiveSection ] = useState({ + purchase: false, + shipping: false, + invoice: false, + }); + + const toggleSection = ( name ) => { + setActiveSection({ + ...activeSection, + [name]: !activeSection[name] + }); + }; + + return ( + + + + +
+
+ + Pending Quotation + + SO/2023/03212 + + PO/2023/02123 + + + BCA Transfer + Cash Before Delivery + Rafi Zadanly + 01 Januari 2023 +
+ + + + toggleSection('purchase')} + /> + { activeSection.purchase && ( +
+ John Doe + johndoe@gmail.com + 081223538754 + Jalan Bandengan Utara No 85A, Kel. Penjaringan, Kec. Penjaringan, Jakarta Utara +
+ ) } + + + + toggleSection('shipping')} + /> + { activeSection.shipping && ( +
+ John Doe + johndoe@gmail.com + 081223538754 + Jalan Bandengan Utara No 85A, Kel. Penjaringan, Kec. Penjaringan, Jakarta Utara +
+ ) } + + + + toggleSection('invoice')} + /> + { activeSection.invoice && ( +
+ John Doe + johndoe@gmail.com + 081223538754 + Jalan Bandengan Utara No 85A, Kel. Penjaringan, Kec. Penjaringan, Jakarta Utara +
+ ) } + + + + + +
+
+
+ ); +} \ No newline at end of file diff --git a/src/pages/my/transactions/index.js b/src/pages/my/transactions/index.js index eb5f99a1..7792c647 100644 --- a/src/pages/my/transactions/index.js +++ b/src/pages/my/transactions/index.js @@ -8,6 +8,7 @@ import { useAuth } from "../../../helpers/auth"; import apiOdoo from "../../../helpers/apiOdoo"; import currencyFormat from "../../../helpers/currencyFormat"; import { EllipsisVerticalIcon } from "@heroicons/react/24/outline"; +import Link from "../../../components/Link"; export default function Transactions() { const [ auth ] = useAuth(); @@ -19,7 +20,7 @@ export default function Transactions() { useEffect(() => { const loadTransactions = async () => { if (auth) { - const dataTransactions = await apiOdoo('GET', `/api/v1/sale_order?partner_id=${auth?.partner_id}`); + const dataTransactions = await apiOdoo('GET', `/api/v1/partner/${auth.partner_id}/sale_order`); setTransactions(dataTransactions); }; } @@ -29,31 +30,31 @@ export default function Transactions() { return ( - +
{ transactions?.sale_orders?.map((transaction, index) => (
-
-
+
+ No. Transaksi

{ transaction.name }

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

{ transaction.sales }

+

{ transaction.sales }

Total Harga -

{ currencyFormat(transaction.amount_total) }

+

{ currencyFormat(transaction.amount_total) }

-
+
)) }
diff --git a/src/pages/shop/checkout.js b/src/pages/shop/checkout.js index 424b903d..0f9619cf 100644 --- a/src/pages/shop/checkout.js +++ b/src/pages/shop/checkout.js @@ -117,7 +117,6 @@ export default function Checkout() { } let productOrder = products.map((product) => ({ 'product_id': product.id, 'quantity': product.quantity })); let data = { - 'partner_id': auth.partner_id, 'partner_shipping_id': selectedAddress.shipping.id, 'partner_invoice_id': selectedAddress.invoicing.id, 'order_line': JSON.stringify(productOrder) @@ -131,7 +130,7 @@ export default function Checkout() { if (poNumber) data.po_number = poNumber; if (poFile) data.po_file = await getFileBase64(poFile); - const checkoutToOdoo = await apiOdoo('POST', '/api/v1/sale_order/checkout', data); + const checkoutToOdoo = await apiOdoo('POST', `/api/v1/partner/${auth.partner_id}/sale_order/checkout`, data); for (const product of products) { deleteItemCart(product.id); } -- cgit v1.2.3