summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/my/address/[id]/edit.js2
-rw-r--r--src/pages/my/menu.js6
-rw-r--r--src/pages/my/transactions/index.js76
-rw-r--r--src/pages/shop/checkout.js22
4 files changed, 93 insertions, 13 deletions
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() {
</div>
<div>
<h2>{ auth?.name }</h2>
- <div className="badge-red font-normal text-xs">Akun Bisnis</div>
+ { auth?.company ? (
+ <div className="badge-red font-normal text-xs">Akun Bisnis</div>
+ ) : (
+ <div className="badge-gray font-normal text-xs">Akun Individu</div>
+ ) }
</div>
</div>
<Link href="/my/profile">
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 (
+ <WithAuth>
+ <Layout>
+ <AppBar title="Daftar Transaksi" />
+
+ <div className="p-4 flex flex-col gap-y-4">
+ { transactions?.sale_orders?.map((transaction, index) => (
+ <div className="p-4 border border-gray_r-7 rounded-md" key={index}>
+ <div className="flex justify-between">
+ <div>
+ <span className="text-caption-2 text-gray_r-11">No. Transaksi</span>
+ <h2 className="text-red_r-11 mt-1">{ transaction.name }</h2>
+ </div>
+ <div className="flex gap-x-1">
+ <div className="badge-green h-fit">Pending</div>
+ <EllipsisVerticalIcon className="w-5 h-5" onClick={() => setActivePopupId(transaction.id)} />
+ </div>
+ </div>
+ <div className="flex mt-2 justify-between">
+ <div>
+ <span className="text-caption-2 text-gray_r-11">Dilayani Oleh</span>
+ <p className="mt-1 font-medium">{ transaction.sales }</p>
+ </div>
+ <div className="text-right">
+ <span className="text-caption-2 text-gray_r-11">Total Harga</span>
+ <p className="mt-1 font-medium">{ currencyFormat(transaction.amount_total) }</p>
+ </div>
+ </div>
+ </div>
+ )) }
+ </div>
+
+ { transactions?.sale_orders?.length > 0 && (
+ <BottomPopup
+ title="Lainnya"
+ active={activePopupId}
+ closePopup={() => setActivePopupId(null)}
+ >
+ <div className="flex flex-col gap-y-4">
+ <p>Download Quotation</p>
+ <p>Batalkan Transaksi</p>
+ </div>
+ </BottomPopup>
+ ) }
+ </Layout>
+ </WithAuth>
+ );
+}; \ 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() {
<LineDivider/>
<div className="p-4">
- <h2>
- Purchase Order
- <span className="font-normal text-gray_r-11">
- { ' (' + (auth?.company ? 'Wajib diisi' : 'Opsional') + ')' }
- </span>
- </h2>
+ <h2>Purchase Order</h2>
<div className="mt-4 flex gap-x-3">
- <div className="w-8/12">
+ <div className="w-6/12">
<label className="form-label font-normal">Nomor PO</label>
<input
type="text"
@@ -318,8 +313,13 @@ export default function Checkout() {
onChange={(e) => setPoNumber(e.target.value)}
/>
</div>
- <div className="w-4/12">
- <label className="form-label font-normal">File PO</label>
+ <div className="w-6/12">
+ <label className="form-label font-normal">
+ File PO
+ {auth?.company && (
+ <span className="font-normal text-gray_r-11 ml-1">(Wajib diisi)</span>
+ )}
+ </label>
<input
type="file"
className="form-input mt-2 h-12"