Merge pull request #108 from beatz174-bit/codex/implement-styling-and-popup-changes-for-pick-list

Refine pick list item layout with popup controls
This commit is contained in:
beatz174-bit authored and GitHub committed 2025-11-24 08:57:31 +10:00
commit 8c80c14f3b
1 file changed
+101 -40
+101 -40
View File
@@ -1,4 +1,4 @@
import { Add, Delete, Inventory2, Remove } from '@mui/icons-material'; import { Add, Close, Delete, Inventory2, Remove } from '@mui/icons-material';
import { import {
Button, Button,
Checkbox, Checkbox,
@@ -36,6 +36,7 @@ export const PickItemRow = ({
onDelete, onDelete,
}: PickItemRowProps) => { }: PickItemRowProps) => {
const [isConfirmOpen, setIsConfirmOpen] = useState(false); const [isConfirmOpen, setIsConfirmOpen] = useState(false);
const [isControlsOpen, setIsControlsOpen] = useState(false);
const packagingLabel = item.is_carton const packagingLabel = item.is_carton
? product?.bulk_name ?? 'Carton' ? product?.bulk_name ?? 'Carton'
: product?.unit_type ?? 'Unit'; : product?.unit_type ?? 'Unit';
@@ -55,7 +56,22 @@ export const PickItemRow = ({
alignItems="center" alignItems="center"
justifyContent="space-between" justifyContent="space-between"
spacing={1.5} spacing={1.5}
sx={{ p: 1, borderRadius: 1, bgcolor: 'background.paper', boxShadow: 1 }} sx={{
p: 1,
borderRadius: 1,
bgcolor: 'background.paper',
boxShadow: 1,
cursor: 'pointer',
}}
onClick={() => setIsControlsOpen(true)}
role="button"
tabIndex={0}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
setIsControlsOpen(true);
}
}}
> >
<Stack direction="row" spacing={1} alignItems="center" flex={1} minWidth={0}> <Stack direction="row" spacing={1} alignItems="center" flex={1} minWidth={0}>
<Checkbox <Checkbox
@@ -63,52 +79,97 @@ export const PickItemRow = ({
checked={item.status === 'picked'} checked={item.status === 'picked'}
onChange={(event) => toggleStatus(event.target.checked)} onChange={(event) => toggleStatus(event.target.checked)}
inputProps={{ 'aria-label': 'Toggle picked status' }} inputProps={{ 'aria-label': 'Toggle picked status' }}
onClick={(event) => event.stopPropagation()}
/> />
<Stack spacing={0.25} minWidth={0} flex={1}> <Stack spacing={0.5} minWidth={0} flex={1}>
<Typography variant="subtitle1" noWrap> <Typography
{product?.name ?? 'Unknown product'} variant="subtitle1"
noWrap
sx={{ display: 'flex', alignItems: 'center', gap: 1 }}
>
<Typography
component="span"
variant="subtitle1"
noWrap
sx={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }}
>
{product?.name ?? 'Unknown product'}
</Typography>
<Typography
component="span"
variant="subtitle1"
sx={{ fontWeight: 700, whiteSpace: 'nowrap' }}
>
{item.quantity} {packagingLabel}
</Typography>
</Typography> </Typography>
<Typography variant="caption" color="text.secondary" noWrap> <Typography variant="caption" color="text.secondary" noWrap>
Qty: {item.quantity} {packagingLabel} Tap to adjust quantity and packaging
</Typography> </Typography>
</Stack> </Stack>
</Stack> </Stack>
<Stack direction="row" spacing={1} alignItems="center"> <Dialog
<IconButton open={isControlsOpen}
aria-label={`Switch to ${item.is_carton ? 'unit' : 'carton'} packaging`} onClose={() => setIsControlsOpen(false)}
color={item.is_carton ? 'primary' : 'default'} fullWidth
onClick={onToggleCarton} maxWidth="xs"
sx={{ aria-labelledby="item-controls-title"
boxShadow: item.is_carton >
? (theme) => `0 0 0 8px ${alpha(theme.palette.primary.main, 0.15)}` <DialogTitle
: 'none', id="item-controls-title"
}} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
> >
<Inventory2 /> <Typography variant="h6" noWrap sx={{ minWidth: 0, flex: 1 }}>
</IconButton> {product?.name ?? 'Unknown product'}
<IconButton </Typography>
aria-label="Decrease quantity" <IconButton aria-label="Close controls" onClick={() => setIsControlsOpen(false)}>
color="primary" <Close />
onClick={onDecrementQuantity} </IconButton>
> </DialogTitle>
<Remove /> <DialogContent>
</IconButton> <Stack spacing={2} alignItems="stretch">
<IconButton <Typography variant="subtitle1" sx={{ fontWeight: 700 }}>
aria-label="Increase quantity" Quantity: {item.quantity} {packagingLabel}
color="primary" </Typography>
onClick={onIncrementQuantity} <Stack direction="row" spacing={1} justifyContent="center" flexWrap="wrap">
> <IconButton
<Add /> aria-label={`Switch to ${item.is_carton ? 'unit' : 'carton'} packaging`}
</IconButton> color={item.is_carton ? 'primary' : 'default'}
<IconButton onClick={onToggleCarton}
color="error" sx={{
onClick={() => setIsConfirmOpen(true)} boxShadow: item.is_carton
aria-label="Delete item" ? (theme) => `0 0 0 8px ${alpha(theme.palette.primary.main, 0.15)}`
> : 'none',
<Delete /> }}
</IconButton> >
</Stack> <Inventory2 />
</IconButton>
<IconButton
aria-label="Decrease quantity"
color="primary"
onClick={onDecrementQuantity}
>
<Remove />
</IconButton>
<IconButton
aria-label="Increase quantity"
color="primary"
onClick={onIncrementQuantity}
>
<Add />
</IconButton>
<IconButton
color="error"
onClick={() => setIsConfirmOpen(true)}
aria-label="Delete item"
>
<Delete />
</IconButton>
</Stack>
</Stack>
</DialogContent>
</Dialog>
<Dialog <Dialog
open={isConfirmOpen} open={isConfirmOpen}