From fd8da0c7a30f0eb4cabb9cbf2894743ddeba047b Mon Sep 17 00:00:00 2001 From: beatz174-bit Date: Sun, 23 Nov 2025 12:45:09 +1000 Subject: [PATCH] Fix AddItemScreen quantity state --- src/screens/AddItemScreen.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/screens/AddItemScreen.tsx b/src/screens/AddItemScreen.tsx index ff22033..8b5cd98 100644 --- a/src/screens/AddItemScreen.tsx +++ b/src/screens/AddItemScreen.tsx @@ -1,11 +1,20 @@ -import { Autocomplete, Button, Container, InputAdornment, Stack, TextField, Typography } from '@mui/material'; +import { + Autocomplete, + Button, + Checkbox, + Container, + FormControlLabel, + InputAdornment, + Stack, + TextField, + Typography, +} from '@mui/material'; import SearchIcon from '@mui/icons-material/Search'; import { useEffect, useMemo, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { v4 as uuidv4 } from 'uuid'; import { usePickItems, useProducts } from '../hooks/dataHooks'; import { useDatabase } from '../context/DBProvider'; -import { NumericStepper } from '../components/NumericStepper'; export const AddItemScreen = () => { const { id } = useParams(); @@ -14,8 +23,8 @@ export const AddItemScreen = () => { const products = useProducts(); const [selectedProduct, setSelectedProduct] = useState(null); const [query, setQuery] = useState(''); - const [units, setUnits] = useState(0); - const [cartons, setCartons] = useState(0); + const [quantity, setQuantity] = useState(1); + const [isCarton, setIsCarton] = useState(false); const navigate = useNavigate(); const unitLabel = selectedProduct?.unit_type ?? 'Units'; const cartonLabel = selectedProduct?.bulk_name ?? 'Cartons'; @@ -38,8 +47,8 @@ export const AddItemScreen = () => { }, [filteredProducts, selectedProduct]); useEffect(() => { - setUnits(0); - setCartons(0); + setQuantity(1); + setIsCarton(false); }, [selectedProduct]); const packagingLabel = isCarton ? cartonLabel : unitLabel;