From 07819844d5ef7e323fd956eacfedecb2f4f4bb80 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Nov 2023 15:16:23 +0700 Subject: Update result feature --- src/modules/stock-opname/index.tsx | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/modules/stock-opname') diff --git a/src/modules/stock-opname/index.tsx b/src/modules/stock-opname/index.tsx index 0a5c848..eb8b796 100644 --- a/src/modules/stock-opname/index.tsx +++ b/src/modules/stock-opname/index.tsx @@ -10,7 +10,8 @@ import { useMutation } from "@tanstack/react-query"; import { useEffect, useState } from "react"; import toast from "@/common/libs/toast"; import Scanner from "@/common/components/Scanner"; -import { AlertCircleIcon, ScanIcon, ScanLineIcon } from "lucide-react"; +import { AlertCircleIcon, ScanLineIcon } from "lucide-react"; +import Link from "next/link"; type ActiveScanner = "product" | "location" | null type ScannerOption = { value: number, label: string } @@ -116,7 +117,7 @@ const StockOpname = () => { onChange={handleSelectChange} className="flex-1" /> - @@ -137,7 +138,7 @@ const StockOpname = () => { onChange={handleSelectChange} className="flex-1" /> - @@ -179,6 +180,8 @@ const StockOpname = () => { > {saveMutation.isPending ? : 'Simpan'} + + @@ -195,7 +198,7 @@ const StockOpname = () => { <>
{scannerOptions.map((option) => ( - handleScannerOptionPress(option)}> + handleScannerOptionPress(option)}> {option.label} ))} @@ -245,17 +248,11 @@ const loadProduct = async (inputValue: string) => { const response = await fetch(`/api/product?search=${inputValue}`) const data: { products: Product[] } = await response.json() || [] - return data?.products.map((product) => { - let label = '' - if (product.itemCode) label += `[${product.itemCode}]` - label += ` ${product.name}` - if (product.barcode) label += ` [${product.barcode}]` - - return { - value: product.id, - label - } - }) + return data?.products.map((product) => ({ + value: product.id, + label: `${product.itemCode ? `[${product.itemCode}]` : ''} ${product.name} ${product.barcode ? ` [${product.barcode}]` : ''}` + } + )) } export default StockOpname \ No newline at end of file -- cgit v1.2.3