From 91fae67a9fdece78f0d0fbf4230472577b6260c6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 11 Jul 2024 14:58:55 +0700
Subject: <iman> add key && update reject button by status quotation && add
 image reject

---
 src/lib/transaction/components/Transaction.jsx | 149 +++++++++++++------------
 1 file changed, 79 insertions(+), 70 deletions(-)

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

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 8e7cede0..b099ffa7 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -1,4 +1,6 @@
 import Spinner from '@/core/components/elements/Spinner/Spinner';
+import NextImage from 'next/image';
+import rejectImage from "../../../../public/images/reject.png"
 import useTransaction from '../hooks/useTransaction';
 import TransactionStatusBadge from './TransactionStatusBadge';
 import Divider from '@/core/components/elements/Divider/Divider';
@@ -646,85 +648,85 @@ const Transaction = ({ id }) => {
               <div className='text-h-sm font-semibold mt-4 mb-4'>
                 Rincian Pembelian
               </div>
-              {transaction?.data?.products?.length > 0? (
-                <table className='table-data'>
-                  <thead>
-                    <tr>
-                      <th>Nama Produk</th>
-                      {/* <th>Diskon</th> */}
-                      <th>Jumlah</th>
-                      <th>Harga</th>
-                      <th>Subtotal</th>
-                      <th></th>
-                    </tr>
-                  </thead>
-                  <tbody>
-                  {transaction?.data?.products?.map((product) => (
-                    <tr key={product.id}>
-                      <td className='flex'>
-                        <Link
-                          href={createSlug(
-                            '/shop/product/',
-                            product?.parent.name,
-                            product?.parent.id
-                          )}
-                          className='w-[20%] flex-shrink-0'
-                        >
-                          <Image
-                            src={product?.parent?.image}
-                            alt={product?.name}
-                            className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
-                          />
-                        </Link>
-                        <div className='px-2 text-left'>
+                {transaction?.data?.products?.length > 0? (
+                  <table className='table-data'>
+                    <thead>
+                      <tr>
+                        <th>Nama Produk</th>
+                        {/* <th>Diskon</th> */}
+                        <th>Jumlah</th>
+                        <th>Harga</th>
+                        <th>Subtotal</th>
+                        <th></th>
+                      </tr>
+                    </thead>
+                    <tbody>
+                    {transaction?.data?.products?.map((product) => (
+                      <tr key={product.id}>
+                        <td className='flex'>
                           <Link
                             href={createSlug(
                               '/shop/product/',
                               product?.parent.name,
                               product?.parent.id
                             )}
-                            className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
+                            className='w-[20%] flex-shrink-0'
                           >
-                            {product?.parent?.name}
+                            <Image
+                              src={product?.parent?.image}
+                              alt={product?.name}
+                              className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
+                            />
                           </Link>
-                          <div className='text-gray_r-11 mt-2'>
-                            {product?.code}{' '}
-                            {product?.attributes.length > 0
-                              ? `| ${product?.attributes.join(', ')}`
-                              : ''}
-                          </div>
-                        </div>
-                      </td>
-                      {/* <td>
-                        {product.price.discountPercentage > 0
-                          ? `${product.price.discountPercentage}%`
-                          : ''}
-                      </td> */}
-                      <td>{product.quantity}</td>
-                      <td>
-                        {/* {product.price.discountPercentage > 0 && (
-                          <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
-                            {currencyFormat(product.price.price)}
+                          <div className='px-2 text-left'>
+                            <Link
+                              href={createSlug(
+                                '/shop/product/',
+                                product?.parent.name,
+                                product?.parent.id
+                              )}
+                              className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
+                            >
+                              {product?.parent?.name}
+                            </Link>
+                            <div className='text-gray_r-11 mt-2'>
+                              {product?.code}{' '}
+                              {product?.attributes.length > 0
+                                ? `| ${product?.attributes.join(', ')}`
+                                : ''}
+                            </div>
                           </div>
-                        )} */}
-                        <div>{currencyFormat(product.price.priceDiscount)}</div>
-                      </td>
-                      <td>{currencyFormat(product.price.subtotal)}</td>
-                      {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
-                      {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/"))  && (
+                        </td>
+                        {/* <td>
+                          {product.price.discountPercentage > 0
+                            ? `${product.price.discountPercentage}%`
+                            : ''}
+                        </td> */}
+                        <td>{product.quantity}</td>
                         <td>
-                          <button
-                            className="bg-red-500 text-white py-1 px-3 rounded"
-                            onClick={() => openModal(product)}
-                          >
-                            Reject
-                          </button>
+                          {/* {product.price.discountPercentage > 0 && (
+                            <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
+                              {currencyFormat(product.price.price)}
+                            </div>
+                          )} */}
+                          <div>{currencyFormat(product.price.priceDiscount)}</div>
                         </td>
-                      )}
-                    </tr>
-                  ))}
-                </tbody>
-              </table>
+                        <td>{currencyFormat(product.price.subtotal)}</td>
+                        {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
+                        {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) &&  (router.asPath.includes("/my/quotations/"))  && transaction.data?.status == 'draft' && (
+                          <td>
+                            <button
+                              className="bg-red-500 text-white py-1 px-3 rounded"
+                              onClick={() => openModal(product)}
+                            >
+                              Reject
+                            </button>
+                          </td>
+                        )}
+                      </tr>
+                    ))}
+                  </tbody>
+                </table>
               ) : (
                 <div className='badge-red text-sm'>Semua produk telah di reject</div>
               )}
@@ -856,13 +858,20 @@ const Transaction = ({ id }) => {
                             )} */}
                             <div>{currencyFormat(product.price.priceDiscount)}</div>
                           </td>
-                          <td>{currencyFormat(product.quantity * product.price.priceDiscount)}</td>
+                          <td className='flex justify-center'>
+                            <NextImage
+                              src={rejectImage}
+                              alt='Reject'
+                              width={90}
+                              height={30}
+                            /> 
+                          </td>
                         </tr>
                       ))}
                     </tbody>
                   </table>
               )}
-              
+                           
             </div>
           </div>
         </DesktopView>
-- 
cgit v1.2.3

