From be0f537dc4fe384eef09436833c6407e6482c16d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 9 Nov 2023 15:40:16 +0700 Subject: Initial commit --- src/modules/result/components/DetailRow.tsx | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/modules/result/components/DetailRow.tsx (limited to 'src/modules/result/components/DetailRow.tsx') diff --git a/src/modules/result/components/DetailRow.tsx b/src/modules/result/components/DetailRow.tsx new file mode 100644 index 0000000..99ccb01 --- /dev/null +++ b/src/modules/result/components/DetailRow.tsx @@ -0,0 +1,81 @@ +"use client"; +import { useResultStore } from '@/common/stores/useResultStore'; +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/client'; +import clsxm from '@/common/libs/clsxm'; + +const DetailRow = ({ productId }: { productId: number }) => { + const { filter } = useResultStore() + + const detailLocation = useQuery({ + queryKey: ['detailLocation', productId, filter.company], + queryFn: async () => { + const searchParams = new URLSearchParams() + if (!filter?.company) return null + searchParams.set('companyId', filter.company) + searchParams.set('productId', productId.toString()) + return await fetch(`/api/stock-opname/location?${searchParams}`) + .then(res => res.json()) + } + }) + + if (detailLocation.isLoading) { + return ( + + +
+ + +
+ + + ) + } + + return ( + <> + {detailLocation.data?.map((location: StockOpnameLocationRes) => ( + + + +
+ + {location.name} +
+ + + + + + + + + + + + + + ))} + + ) +} + +const QuantityColumn = ({ data }: { data: { quantity?: number | undefined, user?: User } }) => ( +
+ {typeof data?.quantity !== 'number' && '-'} + {data.quantity !== null && ( + <> + {data.quantity} +
+ {data.user?.name} +
+ + )} +
+) + +export default DetailRow \ No newline at end of file -- cgit v1.2.3