Add filter controls for pick list cartons and units
This commit is contained in:
1 parent
903875d8b6
commit
289f915639
1 file changed
+34
-1
@@ -2,7 +2,11 @@ import {
|
|||||||
Autocomplete,
|
Autocomplete,
|
||||||
Button,
|
Button,
|
||||||
Container,
|
Container,
|
||||||
|
FormControl,
|
||||||
|
FormControlLabel,
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
Stack,
|
Stack,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
@@ -27,6 +31,7 @@ export const ActivePickListScreen = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [selectedProduct, setSelectedProduct] = useState<Product | null>(null);
|
const [selectedProduct, setSelectedProduct] = useState<Product | null>(null);
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
|
const [itemFilter, setItemFilter] = useState<'all' | 'cartons' | 'units'>('all');
|
||||||
|
|
||||||
const areaName = useMemo(
|
const areaName = useMemo(
|
||||||
() => areas.find((area) => area.id === pickList?.area_id)?.name ?? 'Area',
|
() => areas.find((area) => area.id === pickList?.area_id)?.name ?? 'Area',
|
||||||
@@ -50,6 +55,18 @@ export const ActivePickListScreen = () => {
|
|||||||
}
|
}
|
||||||
}, [filteredProducts, selectedProduct]);
|
}, [filteredProducts, selectedProduct]);
|
||||||
|
|
||||||
|
const visibleItems = useMemo(() => {
|
||||||
|
if (itemFilter === 'cartons') {
|
||||||
|
return items.filter((item) => item.is_carton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemFilter === 'units') {
|
||||||
|
return items.filter((item) => !item.is_carton);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}, [itemFilter, items]);
|
||||||
|
|
||||||
const handleIncrementQuantity = async (itemId: string) => {
|
const handleIncrementQuantity = async (itemId: string) => {
|
||||||
const existing = await db.pickItems.get(itemId);
|
const existing = await db.pickItems.get(itemId);
|
||||||
if (!existing) return;
|
if (!existing) return;
|
||||||
@@ -177,6 +194,22 @@ export const ActivePickListScreen = () => {
|
|||||||
<Typography variant="caption" color="text.secondary">
|
<Typography variant="caption" color="text.secondary">
|
||||||
Selecting a product immediately adds it to the pick list.
|
Selecting a product immediately adds it to the pick list.
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<FormControl>
|
||||||
|
<Typography variant="subtitle2" color="text.secondary" sx={{ mb: 0.5 }}>
|
||||||
|
Filter list by packaging
|
||||||
|
</Typography>
|
||||||
|
<RadioGroup
|
||||||
|
row
|
||||||
|
value={itemFilter}
|
||||||
|
onChange={(event) =>
|
||||||
|
setItemFilter(event.target.value as 'all' | 'cartons' | 'units')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FormControlLabel value="all" control={<Radio />} label="All" />
|
||||||
|
<FormControlLabel value="cartons" control={<Radio />} label="Cartons" />
|
||||||
|
<FormControlLabel value="units" control={<Radio />} label="Units" />
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
{pickList?.notes ? (
|
{pickList?.notes ? (
|
||||||
@@ -185,7 +218,7 @@ export const ActivePickListScreen = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
) : null}
|
) : null}
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
{items.map((item) => (
|
{visibleItems.map((item) => (
|
||||||
<PickItemRow
|
<PickItemRow
|
||||||
key={item.id}
|
key={item.id}
|
||||||
item={item}
|
item={item}
|
||||||
|
|||||||
Reference in new issue
Block a user