From a711c3d7f3a41bb5ac20485723a0f629fbfde1b7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 3 Jul 2024 17:48:31 +0700 Subject: update code logic --- src/modules/result/components/Table.tsx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/modules/result/components/Table.tsx') diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx index 082f988..94ed5bf 100644 --- a/src/modules/result/components/Table.tsx +++ b/src/modules/result/components/Table.tsx @@ -78,7 +78,9 @@ const Table = () => { const recompute = async (productId: number, companyId: string) => { const response = await fetch(`/api/company/${companyId}/product/${productId}/compute-different`, { method: 'POST' }) + console.log("response",response) const stockOpname = await response.json() + console.log("stockOpname",stockOpname) toast(`Berhasil menghitung ulang status barang, hasilnya ${stockOpname.data.isDifferent ? 'selisih' : 'aman'}`) stockOpnames.refetch() } -- cgit v1.2.3 From 9a80c0a767c6a35a489b9d45654ae60f7ddc6794 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 4 Jul 2024 11:53:01 +0700 Subject: update stock opname logic --- src/modules/result/components/Table.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/modules/result/components/Table.tsx') diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx index 94ed5bf..fc40932 100644 --- a/src/modules/result/components/Table.tsx +++ b/src/modules/result/components/Table.tsx @@ -99,7 +99,8 @@ const Table = () => {
- + + @@ -109,7 +110,8 @@ const Table = () => { - + + {!isLoading && stockOpnames.data?.result.map((stockOpname: StockOpnameRes['result']) => ( <> -- cgit v1.2.3 From d0c00e30f3f850f8452397db05f41e0c0ecef3f9 Mon Sep 17 00:00:00 2001 From: Imanuel Marinao Date: Thu, 4 Jul 2024 13:40:28 +0700 Subject: update stock opname --- src/modules/result/components/Table.tsx | 278 ++++++++++++++++---------------- 1 file changed, 138 insertions(+), 140 deletions(-) (limited to 'src/modules/result/components/Table.tsx') diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx index fc40932..19a1e8b 100644 --- a/src/modules/result/components/Table.tsx +++ b/src/modules/result/components/Table.tsx @@ -1,9 +1,9 @@ "use client"; import { useResultStore } from "@/common/stores/useResultStore"; import { StockOpnameRes } from "@/common/types/stockOpname"; -import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Pagination, Skeleton, Spacer, Spinner } from "@nextui-org/react" +import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Pagination, Skeleton, Spacer, Spinner } from "@nextui-org/react"; import { keepPreviousData, useQuery } from "@tanstack/react-query"; -import styles from "./table.module.css" +import styles from "./table.module.css"; import clsxm from "@/common/libs/clsxm"; import DetailRow from "./DetailRow"; import { useDebounce } from "usehooks-ts"; @@ -16,169 +16,173 @@ import toast from "@/common/libs/toast"; import { Product } from "prisma/generated/client"; const Table = () => { - const credential = getClientCredential() + const credential = getClientCredential(); - const { filter: { company, search, show, page }, updateFilter } = useResultStore() - const debouncedSearch = useDebounce(search, 500) + const { + filter: { company, search, show, page }, + updateFilter, + } = useResultStore(); + const debouncedSearch = useDebounce(search, 500); useEffect(() => { - updateFilter('page', 1) - }, [company, debouncedSearch, show, updateFilter]) + updateFilter("page", 1); + }, [company, debouncedSearch, show, updateFilter]); const stockOpnames = useQuery({ - queryKey: ['stockOpnames', company, debouncedSearch, page, show], + queryKey: ["stockOpnames", company, debouncedSearch, page, show], queryFn: async () => { - const searchParams = new URLSearchParams() - if (!company) return null - searchParams.set('companyId', company) + const searchParams = new URLSearchParams(); + if (!company) return null; + searchParams.set("companyId", company); - const showValue = SHOWING_SELECTIONS.find((item) => item.key === show)?.value || '' - searchParams.set('show', showValue); + const showValue = SHOWING_SELECTIONS.find((item) => item.key === show)?.value || ""; + searchParams.set("show", showValue); - if (debouncedSearch) searchParams.set('search', debouncedSearch) + if (debouncedSearch) searchParams.set("search", debouncedSearch); - searchParams.set('page', page.toString()); + searchParams.set("page", page.toString()); - return await fetch(`/api/stock-opname?${searchParams}`) - .then(res => { - window.scrollTo({ top: 0, 'behavior': 'smooth' }) - return res.json() - }) + return await fetch(`/api/stock-opname?${searchParams}`).then((res) => { + window.scrollTo({ top: 0, behavior: "smooth" }); + return res.json(); + }); }, - placeholderData: keepPreviousData - }) + placeholderData: keepPreviousData, + }); - const { filter } = useResultStore() + const { filter } = useResultStore(); - const [exportLoad, setExportLoad] = useState(false) + const [exportLoad, setExportLoad] = useState(false); const exportResult = async () => { - setExportLoad(true) - const response = await fetch(`/api/stock-opname/export?companyId=${filter.company}`) - const buffer = await response.arrayBuffer() - console.log({ type: response.headers.get('type') }); - - const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) - const url = window.URL.createObjectURL(blob) - const a = document.createElement('a') - a.href = url - a.download = `export_${moment().format('MM_DD_HH_ss')}.xlsx` - document.body.appendChild(a) - a.click() - document.body.removeChild(a) - setExportLoad(false) - } + setExportLoad(true); + const response = await fetch(`/api/stock-opname/export?companyId=${filter.company}`); + const buffer = await response.arrayBuffer(); + console.log({ type: response.headers.get("type") }); + + const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); + const url = window.URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = `export_${moment().format("MM_DD_HH_ss")}.xlsx`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + setExportLoad(false); + }; const toggleDifferent = async (id: number) => { - const response = await fetch(`/api/product/${id}/toggle-different`, { method: 'POST' }) - const product: Product = await response.json() - toast(`Berhasil mengubah status barang ${product.itemCode} ${product.name} menjadi ${product.isDifferent ? 'selisih' : 'aman'}`, { duration: 10000 }) - stockOpnames.refetch() - } + const response = await fetch(`/api/product/${id}/toggle-different`, { method: "POST" }); + const product: Product = await response.json(); + toast(`Berhasil mengubah status barang ${product.itemCode} ${product.name} menjadi ${product.isDifferent ? "selisih" : "aman"}`, { duration: 10000 }); + stockOpnames.refetch(); + }; const recompute = async (productId: number, companyId: string) => { - const response = await fetch(`/api/company/${companyId}/product/${productId}/compute-different`, { method: 'POST' }) - console.log("response",response) - const stockOpname = await response.json() - console.log("stockOpname",stockOpname) - toast(`Berhasil menghitung ulang status barang, hasilnya ${stockOpname.data.isDifferent ? 'selisih' : 'aman'}`) - stockOpnames.refetch() - } + const response = await fetch(`/api/company/${companyId}/product/${productId}/compute-different`, { method: "POST" }); + console.log("response", response); + const stockOpname = await response.json(); + console.log("stockOpname", stockOpname); + toast(`Berhasil menghitung ulang status barang, hasilnya ${stockOpname.data.isDifferent ? "selisih" : "aman"}`); + stockOpnames.refetch(); + }; - const isLoading = stockOpnames.isLoading || stockOpnames.isRefetching + const isLoading = stockOpnames.isLoading || stockOpnames.isRefetching; - const COL_LENGTH = 9 + const COL_LENGTH = 9; return ( <>
STATUS NAMA PRODUK TIM HITUNG 1ON-HAND QTY GUDANG SELISIH
- - - - - - - - - - - - - + + + + + + + + + + + + + - {!isLoading && stockOpnames.data?.result.map((stockOpname: StockOpnameRes['result']) => ( - <> - - - - - - - - - - - - - - - ))} + {!isLoading && + stockOpnames.data?.result.map((stockOpname: StockOpnameRes["result"]) => ( + <> + + + + + + + + + + + + + + + ))} {!isLoading && stockOpnames.data?.result.length === 0 && ( - + )} @@ -195,19 +199,13 @@ const Table = () => { )}
STATUSNAMA PRODUKTIM HITUNG 1TIM HITUNG 2TIM HITUNG 3TIM VERIFIKASION-HAND QTYGUDANG SELISIH
STATUSNAMA PRODUKTIM HITUNG 1TIM HITUNG 2TIM HITUNG 3TIM VERIFIKASION-HAND QTYGUDANG SELISIH
-
- {stockOpname.isDifferent ? 'Selisih' : 'Aman'} -
-
- {stockOpname.itemCode ? `[${stockOpname.itemCode}] ` : ''} - {stockOpname.name} - {stockOpname.barcode ? ` [${stockOpname.barcode}]` : ''} - - {credential?.team == 'VERIFICATION' && typeof stockOpname.quantity.COUNT1 === 'number' ? stockOpname.quantity.COUNT1 : '-'} - - {credential?.team == 'VERIFICATION' && typeof stockOpname.quantity.COUNT2 === 'number' ? stockOpname.quantity.COUNT2 : '-'} - - {credential?.team == 'VERIFICATION' && typeof stockOpname.quantity.COUNT3 === 'number' ? stockOpname.quantity.COUNT3 : '-'} - - {credential?.team == 'VERIFICATION' && typeof stockOpname.quantity.VERIFICATION === 'number' ? stockOpname.quantity.VERIFICATION : '-'} - - {credential?.team == 'VERIFICATION' ? stockOpname.onhandQty : '-'} - - {credential?.team == 'VERIFICATION' ? stockOpname.differenceQty : '-'} - - {credential?.team == 'VERIFICATION' && ( - - - - - - recompute(stockOpname.id, company)}> - Re-compute - - toggleDifferent(stockOpname.id)}> - Tandai {stockOpname.isDifferent ? 'aman' : 'selisih'} - - - - )} -
+
+ {stockOpname.isDifferent ? "Selisih" : "Aman"} +
+
+ {stockOpname.itemCode ? `[${stockOpname.itemCode}] ` : ""} + {stockOpname.name} + {stockOpname.barcode ? ` [${stockOpname.barcode}]` : ""} + {credential?.team == "VERIFICATION" && typeof stockOpname.quantity.COUNT1 === "number" ? stockOpname.quantity.COUNT1 : "-"}{credential?.team == "VERIFICATION" && typeof stockOpname.quantity.COUNT2 === "number" ? stockOpname.quantity.COUNT2 : "-"}{credential?.team == "VERIFICATION" && typeof stockOpname.quantity.COUNT3 === "number" ? stockOpname.quantity.COUNT3 : "-"}{credential?.team == "VERIFICATION" && typeof stockOpname.quantity.VERIFICATION === "number" ? stockOpname.quantity.VERIFICATION : "-"}{credential?.team == "VERIFICATION" ? stockOpname.onhandQty : "-"}{credential?.team == "VERIFICATION" ? stockOpname.differenceQty : "-"} + {credential?.team == "VERIFICATION" && ( + + + + + + recompute(stockOpname.id, company)}> + Re-compute + + toggleDifferent(stockOpname.id)}> + Tandai {stockOpname.isDifferent ? "aman" : "selisih"} + + + + )} +
Belum ada data untuk ditampilkan + Belum ada data untuk ditampilkan +
-
- updateFilter('page', page)} - className="min-h-[36px] m-0 p-0" - /> + updateFilter("page", page)} className="min-h-[36px] m-0 p-0" /> - ) -} + ); +}; -export default Table \ No newline at end of file +export default Table; -- cgit v1.2.3 From 67d283bb61d7167e7c6460293f3c5669eacf3b63 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 4 Jul 2024 15:45:23 +0700 Subject: delete console log --- src/modules/result/components/Table.tsx | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/modules/result/components/Table.tsx') diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx index 19a1e8b..555c8af 100644 --- a/src/modules/result/components/Table.tsx +++ b/src/modules/result/components/Table.tsx @@ -58,7 +58,6 @@ const Table = () => { setExportLoad(true); const response = await fetch(`/api/stock-opname/export?companyId=${filter.company}`); const buffer = await response.arrayBuffer(); - console.log({ type: response.headers.get("type") }); const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); const url = window.URL.createObjectURL(blob); @@ -80,9 +79,7 @@ const Table = () => { const recompute = async (productId: number, companyId: string) => { const response = await fetch(`/api/company/${companyId}/product/${productId}/compute-different`, { method: "POST" }); - console.log("response", response); const stockOpname = await response.json(); - console.log("stockOpname", stockOpname); toast(`Berhasil menghitung ulang status barang, hasilnya ${stockOpname.data.isDifferent ? "selisih" : "aman"}`); stockOpnames.refetch(); }; -- cgit v1.2.3