From 0a548e87febeab3d25ba7d5270b73b757f130b26 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 26 Apr 2023 11:39:23 +0700 Subject: fix bug on update qty cart and create quotation page --- src/lib/auth/components/Menu.jsx | 7 +++++-- src/lib/cart/components/Cart.jsx | 6 +++--- src/lib/invoice/components/Invoices.jsx | 6 +++--- src/lib/transaction/components/Transaction.jsx | 2 +- src/lib/transaction/components/Transactions.jsx | 15 +++++++------- src/pages/my/invoice/[id].jsx | 27 ------------------------- src/pages/my/invoices.jsx | 24 ---------------------- src/pages/my/invoices/[id].jsx | 27 +++++++++++++++++++++++++ src/pages/my/invoices/index.jsx | 24 ++++++++++++++++++++++ src/pages/my/quotations/[id].jsx | 27 +++++++++++++++++++++++++ src/pages/my/quotations/index.jsx | 26 ++++++++++++++++++++++++ src/pages/my/transaction/[id].jsx | 27 ------------------------- src/pages/my/transactions.jsx | 26 ------------------------ src/pages/my/transactions/[id].jsx | 27 +++++++++++++++++++++++++ src/pages/my/transactions/index.jsx | 26 ++++++++++++++++++++++++ 15 files changed, 177 insertions(+), 120 deletions(-) delete mode 100644 src/pages/my/invoice/[id].jsx delete mode 100644 src/pages/my/invoices.jsx create mode 100644 src/pages/my/invoices/[id].jsx create mode 100644 src/pages/my/invoices/index.jsx create mode 100644 src/pages/my/quotations/[id].jsx create mode 100644 src/pages/my/quotations/index.jsx delete mode 100644 src/pages/my/transaction/[id].jsx delete mode 100644 src/pages/my/transactions.jsx create mode 100644 src/pages/my/transactions/[id].jsx create mode 100644 src/pages/my/transactions/index.jsx (limited to 'src') diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index 9a73609d..8a8e2e8a 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -9,10 +9,13 @@ const Menu = () => { return (
Menu
- + + Daftar Quotation + + Daftar Transaksi - + Invoice & Faktur Pajak diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index d0685fe3..b0de5168 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -72,7 +72,7 @@ const Cart = () => { }, [products]) useEffect(() => { - const LoadProductSImilar = async () => { + const LoadProductSimilar = async () => { const randProductIndex = Math.floor(Math.random() * products.length) const productLoad = await productSearchApi({ query: `q=${products?.[randProductIndex].parent.name}&limit=10` @@ -80,8 +80,8 @@ const Cart = () => { setProductRecomendation(productLoad) } - if (products?.length > 0) LoadProductSImilar() - }, [products]) + if (products?.length > 0 && !productRecomendation) LoadProductSimilar() + }, [products, productRecomendation]) const updateQuantity = (value, productId, operation = '') => { let productIndex = products.findIndex((product) => product.id == productId) diff --git a/src/lib/invoice/components/Invoices.jsx b/src/lib/invoice/components/Invoices.jsx index 6f7d54a0..8918fae4 100644 --- a/src/lib/invoice/components/Invoices.jsx +++ b/src/lib/invoice/components/Invoices.jsx @@ -78,7 +78,7 @@ const Invoices = () => { {invoices.data?.invoices?.map((invoice, index) => (
- + No. Invoice

{invoice.name}

@@ -91,7 +91,7 @@ const Invoices = () => { setToOthers(invoice)} />
- +

{invoice.invoiceDate}

{invoice.paymentTerm}

@@ -214,7 +214,7 @@ const Invoices = () => { {invoices.data?.invoices?.map((invoice) => ( - {invoice.name} + {invoice.name} {invoice.purchaseOrderName || '-'} {invoice.invoiceDate} diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 3e3f2cc7..30bb454a 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -2,7 +2,7 @@ import Spinner from '@/core/components/elements/Spinner/Spinner' import useTransaction from '../hooks/useTransaction' import TransactionStatusBadge from './TransactionStatusBadge' import Divider from '@/core/components/elements/Divider/Divider' -import { useEffect, useMemo, useRef, useState } from 'react' +import { useMemo, useRef, useState } from 'react' import { downloadPurchaseOrder, downloadQuotation } from '../utils/transactions' import BottomPopup from '@/core/components/elements/Popup/BottomPopup' import uploadPoApi from '../api/uploadPoApi' diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index 13417707..54316c3d 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -19,7 +19,7 @@ import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import Menu from '@/lib/auth/components/Menu' -const Transactions = () => { +const Transactions = ({ context = '' }) => { const router = useRouter() const { q = '', page = 1 } = router.query @@ -28,6 +28,7 @@ const Transactions = () => { const query = { name: q, offset: (page - 1) * limit, + context, limit } const { transactions } = useTransactions({ query }) @@ -54,7 +55,7 @@ const Transactions = () => { const handleSubmit = (e) => { e.preventDefault() - router.push(`/my/transactions?q=${inputQuery}`) + router.push(`${router.pathname}?q=${inputQuery}`) } return ( @@ -89,7 +90,7 @@ const Transactions = () => { {transactions.data?.saleOrders?.map((saleOrder, index) => (
- + No. Transaksi

{saleOrder.name}

@@ -101,7 +102,7 @@ const Transactions = () => { />
- +
No. Purchase Order @@ -135,7 +136,7 @@ const Transactions = () => { @@ -249,7 +250,7 @@ const Transactions = () => { {transactions.data?.saleOrders?.map((saleOrder) => ( - {saleOrder.name} + {saleOrder.name} - {saleOrder.sales} @@ -267,7 +268,7 @@ const Transactions = () => {
diff --git a/src/pages/my/invoice/[id].jsx b/src/pages/my/invoice/[id].jsx deleted file mode 100644 index 740819cc..00000000 --- a/src/pages/my/invoice/[id].jsx +++ /dev/null @@ -1,27 +0,0 @@ -import AppLayout from '@/core/components/layouts/AppLayout' -import BasicLayout from '@/core/components/layouts/BasicLayout' -import DesktopView from '@/core/components/views/DesktopView' -import MobileView from '@/core/components/views/MobileView' -import IsAuth from '@/lib/auth/components/IsAuth' -import InvoiceComponent from '@/lib/invoice/components/Invoice' -import { useRouter } from 'next/router' - -export default function Invoice() { - const router = useRouter() - - return ( - - - - - - - - - - - - - - ) -} diff --git a/src/pages/my/invoices.jsx b/src/pages/my/invoices.jsx deleted file mode 100644 index 59059b2e..00000000 --- a/src/pages/my/invoices.jsx +++ /dev/null @@ -1,24 +0,0 @@ -import AppLayout from '@/core/components/layouts/AppLayout' -import BasicLayout from '@/core/components/layouts/BasicLayout' -import DesktopView from '@/core/components/views/DesktopView' -import MobileView from '@/core/components/views/MobileView' -import IsAuth from '@/lib/auth/components/IsAuth' -import InvoicesComponent from '@/lib/invoice/components/Invoices' - -export default function Invoices() { - return ( - - - - - - - - - - - - - - ) -} diff --git a/src/pages/my/invoices/[id].jsx b/src/pages/my/invoices/[id].jsx new file mode 100644 index 00000000..5972b382 --- /dev/null +++ b/src/pages/my/invoices/[id].jsx @@ -0,0 +1,27 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import InvoiceComponent from '@/lib/invoice/components/Invoice' +import { useRouter } from 'next/router' + +export default function MyInvoice() { + const router = useRouter() + + return ( + + + + + + + + + + + + + + ) +} diff --git a/src/pages/my/invoices/index.jsx b/src/pages/my/invoices/index.jsx new file mode 100644 index 00000000..73c7b9fe --- /dev/null +++ b/src/pages/my/invoices/index.jsx @@ -0,0 +1,24 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import InvoicesComponent from '@/lib/invoice/components/Invoices' + +export default function MyInvoices() { + return ( + + + + + + + + + + + + + + ) +} diff --git a/src/pages/my/quotations/[id].jsx b/src/pages/my/quotations/[id].jsx new file mode 100644 index 00000000..1fbbf34a --- /dev/null +++ b/src/pages/my/quotations/[id].jsx @@ -0,0 +1,27 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import TransactionComponent from '@/lib/transaction/components/Transaction' +import { useRouter } from 'next/router' + +export default function MyQuotation() { + const router = useRouter() + + return ( + + + + + + + + + + + + + + ) +} diff --git a/src/pages/my/quotations/index.jsx b/src/pages/my/quotations/index.jsx new file mode 100644 index 00000000..bd91d9d0 --- /dev/null +++ b/src/pages/my/quotations/index.jsx @@ -0,0 +1,26 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import dynamic from 'next/dynamic' + +const TransactionsComponent = dynamic(() => import('@/lib/transaction/components/Transactions')) + +export default function MyQuotations() { + return ( + + + + + + + + + + + + + + ) +} diff --git a/src/pages/my/transaction/[id].jsx b/src/pages/my/transaction/[id].jsx deleted file mode 100644 index c3283783..00000000 --- a/src/pages/my/transaction/[id].jsx +++ /dev/null @@ -1,27 +0,0 @@ -import AppLayout from '@/core/components/layouts/AppLayout' -import BasicLayout from '@/core/components/layouts/BasicLayout' -import DesktopView from '@/core/components/views/DesktopView' -import MobileView from '@/core/components/views/MobileView' -import IsAuth from '@/lib/auth/components/IsAuth' -import TransactionComponent from '@/lib/transaction/components/Transaction' -import { useRouter } from 'next/router' - -export default function Transaction() { - const router = useRouter() - - return ( - - - - - - - - - - - - - - ) -} diff --git a/src/pages/my/transactions.jsx b/src/pages/my/transactions.jsx deleted file mode 100644 index a8ca78b8..00000000 --- a/src/pages/my/transactions.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import AppLayout from '@/core/components/layouts/AppLayout' -import BasicLayout from '@/core/components/layouts/BasicLayout' -import DesktopView from '@/core/components/views/DesktopView' -import MobileView from '@/core/components/views/MobileView' -import IsAuth from '@/lib/auth/components/IsAuth' -import dynamic from 'next/dynamic' - -const TransactionsComponent = dynamic(() => import('@/lib/transaction/components/Transactions')) - -export default function Transactions() { - return ( - - - - - - - - - - - - - - ) -} diff --git a/src/pages/my/transactions/[id].jsx b/src/pages/my/transactions/[id].jsx new file mode 100644 index 00000000..e36c1ca4 --- /dev/null +++ b/src/pages/my/transactions/[id].jsx @@ -0,0 +1,27 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import TransactionComponent from '@/lib/transaction/components/Transaction' +import { useRouter } from 'next/router' + +export default function MyTransaction() { + const router = useRouter() + + return ( + + + + + + + + + + + + + + ) +} diff --git a/src/pages/my/transactions/index.jsx b/src/pages/my/transactions/index.jsx new file mode 100644 index 00000000..91482a39 --- /dev/null +++ b/src/pages/my/transactions/index.jsx @@ -0,0 +1,26 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' +import MobileView from '@/core/components/views/MobileView' +import IsAuth from '@/lib/auth/components/IsAuth' +import dynamic from 'next/dynamic' + +const TransactionsComponent = dynamic(() => import('@/lib/transaction/components/Transactions')) + +export default function MyTransactions() { + return ( + + + + + + + + + + + + + + ) +} -- cgit v1.2.3