From ebc09c5062cc7996b0f2aaf879062fc950c2e1c2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 25 Jan 2023 11:17:37 +0700 Subject: Transaction detail and variant card component --- src/pages/my/transactions/[id].js | 124 +++++++++++++++++++++++++++++++++++ src/pages/my/transactions/[slug].js | 126 ------------------------------------ src/pages/shop/checkout.js | 30 ++------- 3 files changed, 130 insertions(+), 150 deletions(-) create mode 100644 src/pages/my/transactions/[id].js delete mode 100644 src/pages/my/transactions/[slug].js (limited to 'src/pages') diff --git a/src/pages/my/transactions/[id].js b/src/pages/my/transactions/[id].js new file mode 100644 index 00000000..79337a29 --- /dev/null +++ b/src/pages/my/transactions/[id].js @@ -0,0 +1,124 @@ +import AppBar from "@/components/layouts/AppBar"; +import Layout from "@/components/layouts/Layout"; +import LineDivider from "@/components/elements/LineDivider"; +import WithAuth from "@/components/auth/WithAuth"; +import { useEffect, useState } from "react"; +import apiOdoo from "@/core/utils/apiOdoo"; +import { useRouter } from "next/router"; +import { useAuth } from "@/core/utils/auth"; +import VariantCard from "@/components/variants/VariantCard"; +import currencyFormat from "@/core/utils/currencyFormat"; +import Disclosure from "@/components/elements/Disclosure"; +import DescriptionRow from "@/components/elements/DescriptionRow"; +import { CustomerSection } from "@/components/transactions/TransactionDetail"; + +export default function DetailTransactions() { + const router = useRouter(); + const { id } = router.query; + const [ auth ] = useAuth(); + const [ transaction, setTransaction ] = useState(null); + const [ activeSection, setActiveSection ] = useState({ + purchase: false, + shipping: false, + invoice: false, + }); + + const toggleSection = ( name ) => { + setActiveSection({ + ...activeSection, + [name]: !activeSection[name] + }); + }; + + useEffect(() => { + if (auth) { + const loadTransaction = async () => { + const dataTransaction = await apiOdoo('GET', `/api/v1/partner/${auth?.partner_id}/sale_order/${id}`); + setTransaction(dataTransaction); + } + loadTransaction(); + } + }, [ auth, id ]); + + return ( + + + + +
+ + Pending Quotation + + + { transaction?.name } + + + { transaction?.po_name || '-' } + + + { transaction?.payment_term } + + + { transaction?.sales } + + + { transaction?.date_order } + +
+ + + + + +
+ { transaction?.products?.map((product, index) => ( + + )) } +
+

Total Belanja

+

{ currencyFormat(transaction?.amount_total || 0) }

+
+
+ + + + + toggleSection('purchase')} + /> + { activeSection.purchase && ( + + ) } + + + + toggleSection('shipping')} + /> + { activeSection.shipping && ( + + ) } + + + + toggleSection('invoice')} + /> + { activeSection.invoice && ( + + ) } +
+
+ ); +} \ No newline at end of file diff --git a/src/pages/my/transactions/[slug].js b/src/pages/my/transactions/[slug].js deleted file mode 100644 index a76b0c4d..00000000 --- a/src/pages/my/transactions/[slug].js +++ /dev/null @@ -1,126 +0,0 @@ -import { ArrowDownOnSquareIcon, ArrowDownTrayIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon } from "@heroicons/react/24/outline"; -import AppBar from "@/components/layouts/AppBar"; -import Layout from "@/components/layouts/Layout"; -import LineDivider from "@/components/elements/LineDivider"; -import WithAuth from "@/components/auth/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 - Download - 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/shop/checkout.js b/src/pages/shop/checkout.js index 1849e0fe..49d1a848 100644 --- a/src/pages/shop/checkout.js +++ b/src/pages/shop/checkout.js @@ -17,6 +17,7 @@ import { useRouter } from "next/router"; import WithAuth from "@/components/auth/WithAuth"; import { toast } from "react-hot-toast"; import getFileBase64 from "@/core/utils/getFileBase64"; +import VariantCard from "@/components/variants/VariantCard"; export default function Checkout() { const router = useRouter(); @@ -201,30 +202,11 @@ export default function Checkout() {
{products.map((product, index) => ( -
-
- {product.parent.name} -
-
-

- {product.parent.name} -

-

- {product.code || '-'} - {product.attributes.length > 0 ? ` | ${product.attributes.join(', ')}` : ''} -

-

- {currencyFormat(product.price.price_discount)} × {product.quantity} Barang -

-

- {currencyFormat(product.quantity * product.price.price_discount)} -

-
-
+ ))}
-- cgit v1.2.3