summaryrefslogtreecommitdiff
path: root/src/modules/stock-opname/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/stock-opname/index.tsx')
-rw-r--r--src/modules/stock-opname/index.tsx27
1 files changed, 12 insertions, 15 deletions
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"
/>
- <Button type="button" className={styles.scanButton} variant="flat" onClick={() => setActiveScanner('location')}>
+ <Button type="button" className={styles.scanButton} variant="flat" onPress={() => setActiveScanner('location')}>
<ScanLineIcon size={20} />
</Button>
</div>
@@ -137,7 +138,7 @@ const StockOpname = () => {
onChange={handleSelectChange}
className="flex-1"
/>
- <Button type="button" className={styles.scanButton} variant="flat" onClick={() => setActiveScanner('product')}>
+ <Button type="button" className={styles.scanButton} variant="flat" onPress={() => setActiveScanner('product')}>
<ScanLineIcon size={20} />
</Button>
</div>
@@ -179,6 +180,8 @@ const StockOpname = () => {
>
{saveMutation.isPending ? <Spinner color="white" size="sm" /> : 'Simpan'}
</Button>
+
+ <Button as={Link} href="/result" variant="flat">Lihat hasil</Button>
</form>
<Modal isOpen={!!activeScanner} onOpenChange={closeModal}>
@@ -195,7 +198,7 @@ const StockOpname = () => {
<>
<div className="max-h-[60vh] overflow-auto grid grid-cols-1 gap-y-4">
{scannerOptions.map((option) => (
- <Card key={option.value} isPressable shadow="none" className="border border-default-300" onPress={() => handleScannerOptionPress(option)}>
+ <Card key={option.value} isPressable shadow="none" className="bg-default-50 border border-default-300" onPress={() => handleScannerOptionPress(option)}>
<CardBody>{option.label}</CardBody>
</Card>
))}
@@ -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