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/Table.tsx | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/modules/result/components/Table.tsx (limited to 'src/modules/result/components/Table.tsx') diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx new file mode 100644 index 0000000..d2e5af4 --- /dev/null +++ b/src/modules/result/components/Table.tsx @@ -0,0 +1,106 @@ +"use client"; +import { useResultStore } from "@/common/stores/useResultStore"; +import { StockOpnameRes } from "@/common/types/stockOpname"; +import { Badge, Pagination, Spacer } from "@nextui-org/react" +import { useQuery } from "@tanstack/react-query"; +import { useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; +import styles from "./table.module.css" +import clsxm from "@/common/libs/clsxm"; +import DetailRow from "./DetailRow"; +import { useDebounce } from "usehooks-ts"; + +const Table = () => { + const params = useSearchParams() + const router = useRouter() + const page = params.get('page') ?? '1' + + const { filter: { company, search } } = useResultStore() + const debouncedSearch = useDebounce(search, 500) + + const stockOpnames = useQuery({ + queryKey: ['stockOpnames', company, debouncedSearch, page], + queryFn: async () => { + const searchParams = new URLSearchParams() + if (!company) return null + searchParams.set('companyId', company) + searchParams.set('page', page); + if (debouncedSearch) searchParams.set('search', debouncedSearch) + + return await fetch(`/api/stock-opname?${searchParams}`) + .then(res => res.json()) + }, + }) + + return ( + <> +
+ + + + + + + + + + + + {stockOpnames.data?.result.map((stockOpname: StockOpnameRes['result']) => ( + <> + + + + + + + + + + + + + ))} + + {stockOpnames.data?.result.length === 0 && ( + + + + )} + +
STATUSNAMA PRODUKTIM HITUNG 1TIM HITUNG 2TIM VERIFIKASION-HAND QTYGUDANG SELISIH
+
+ {stockOpname.isDifferent ? 'Tidak Sesuai' : 'Sesuai'} +
+
+ {stockOpname.itemCode ? `[${stockOpname.itemCode}] ` : ''} + {stockOpname.name} + {stockOpname.barcode ? ` [${stockOpname.barcode}]` : ''} + + {stockOpname.quantity.COUNT1 || '-'} + + {stockOpname.quantity.COUNT2 || '-'} + + {stockOpname.quantity.VERIFICATION || '-'} + + {stockOpname.onhandQty} + + {stockOpname.differenceQty} +
Belum ada data untuk ditampilkan
+ + + router.push(`?page=${page}`)} + /> +
+ + ) +} + +export default Table \ No newline at end of file -- cgit v1.2.3