From 0a548e87febeab3d25ba7d5270b73b757f130b26 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 26 Apr 2023 11:39:23 +0700
Subject: fix bug on update qty cart and create quotation page

---
 src/lib/transaction/components/Transactions.jsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'src/lib/transaction/components/Transactions.jsx')

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) => (
             <div className='p-4 shadow border border-gray_r-3 rounded-md' key={index}>
               <div className='grid grid-cols-2'>
-                <Link href={`/my/transaction/${saleOrder.id}`}>
+                <Link href={`${router.pathname}/${saleOrder.id}`}>
                   <span className='text-caption-2 text-gray_r-11'>No. Transaksi</span>
                   <h2 className='text-danger-500 mt-1'>{saleOrder.name}</h2>
                 </Link>
@@ -101,7 +102,7 @@ const Transactions = () => {
                   />
                 </div>
               </div>
-              <Link href={`/my/transaction/${saleOrder.id}`}>
+              <Link href={`${router.pathname}/${saleOrder.id}`}>
                 <div className='grid grid-cols-2 mt-3'>
                   <div>
                     <span className='text-caption-2 text-gray_r-11'>No. Purchase Order</span>
@@ -135,7 +136,7 @@ const Transactions = () => {
           <Pagination
             pageCount={pageCount}
             currentPage={parseInt(page)}
-            url={`/my/transactions${pageQuery}`}
+            url={router.pathname + pageQuery}
             className='mt-2 mb-2'
           />
 
@@ -249,7 +250,7 @@ const Transactions = () => {
                 {transactions.data?.saleOrders?.map((saleOrder) => (
                   <tr key={saleOrder.id}>
                     <td>
-                      <Link href={`/my/transaction/${saleOrder.id}`}>{saleOrder.name}</Link>
+                      <Link href={`${router.pathname}/${saleOrder.id}`}>{saleOrder.name}</Link>
                     </td>
                     <td>-</td>
                     <td className='!text-left'>{saleOrder.sales}</td>
@@ -267,7 +268,7 @@ const Transactions = () => {
             <Pagination
               pageCount={pageCount}
               currentPage={parseInt(page)}
-              url={`/my/transactions${pageQuery}`}
+              url={router.pathname + pageQuery}
               className='mt-2 mb-2'
             />
           </div>
-- 
cgit v1.2.3

