summaryrefslogtreecommitdiff
path: root/src/modules/result/components/DetailRow.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/result/components/DetailRow.tsx')
-rw-r--r--src/modules/result/components/DetailRow.tsx32
1 files changed, 24 insertions, 8 deletions
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>