From ae3207e9778c3f2fb01d64714ff15fc073ec093d Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 1 Dec 2023 10:16:12 +0700
Subject: Update compute different, result, and product list feature

---
 src/modules/result/components/DetailRow.tsx | 32 +++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

(limited to 'src/modules/result/components/DetailRow.tsx')

diff --git a/src/modules/result/components/DetailRow.tsx b/src/modules/result/components/DetailRow.tsx
index 18dcb8f..bb5b1ef 100644
--- a/src/modules/result/components/DetailRow.tsx
+++ b/src/modules/result/components/DetailRow.tsx
@@ -4,10 +4,11 @@ import { StockOpnameLocationRes } from '@/common/types/stockOpname';
 import { Skeleton } from '@nextui-org/react';
 import { useQuery } from '@tanstack/react-query'
 import styles from './table.module.css'
-import { CornerDownRightIcon } from 'lucide-react';
-import { User } from 'prisma/generated/client';
+import { CheckIcon, CornerDownRightIcon, XIcon } from 'lucide-react';
+import { Team, User } from 'prisma/generated/client';
 import clsxm from '@/common/libs/clsxm';
 import getClientCredential from '@/common/libs/getClientCredential';
+import _ from 'lodash';
 
 const DetailRow = ({ productId }: { productId: number }) => {
   const { filter } = useResultStore()
@@ -48,16 +49,16 @@ const DetailRow = ({ productId }: { productId: number }) => {
             </div>
           </td>
           <td className={styles.td}>
-            <QuantityColumn data={location.COUNT1} />
+            <Column team='COUNT1' data={location.COUNT1} />
           </td>
           <td className={styles.td}>
-            <QuantityColumn data={location.COUNT2} />
+            <Column team='COUNT2' data={location.COUNT2} />
           </td>
           <td className={styles.td}>
-            <QuantityColumn data={location.COUNT3} />
+            <Column team='COUNT3' data={location.COUNT3} />
           </td>
           <td className={styles.td}>
-            <QuantityColumn data={location.VERIFICATION} />
+            <Column team='VERIFICATION' data={location.VERIFICATION} />
           </td>
           <td className={styles.td} />
           <td className={styles.td} />
@@ -67,14 +68,29 @@ const DetailRow = ({ productId }: { productId: number }) => {
   )
 }
 
-const QuantityColumn = ({ data }: { data: { quantity?: number | undefined, user?: User } }) => {
+type Data = { quantity?: number | undefined, user?: User }
+
+const Column = ({ team, data }: { team: Team, data: Data }) => {
+  const credential = getClientCredential()
+
+  return credential?.team === team && credential.team !== 'VERIFICATION' ? (
+    <div className='flex justify-center'>
+      {_.isNumber(data.quantity) && <CheckIcon size={16} />}
+      {_.isUndefined(data.quantity) && <XIcon size={16} />}
+    </div>
+  ) : (
+    <QuantityColumn data={data} />
+  )
+}
+
+const QuantityColumn = ({ data }: { data: Data }) => {
   const credential = getClientCredential()
 
   if (!(credential?.team == "VERIFICATION")) return '-'
 
   return (
     <div className='grid grid-cols-1'>
-      {typeof data?.quantity !== 'number' && '-'}
+      {_.isUndefined(data.quantity) && '-'}
       {data.quantity !== null && (
         <>
           <span>{data.quantity}</span>
-- 
cgit v1.2.3

