import { Add, Close, Delete, Inventory2, Remove } from '@mui/icons-material'; import { Button, Checkbox, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Stack, Typography, } from '@mui/material'; import { alpha } from '@mui/material/styles'; import { useState } from 'react'; import { PickItem } from '../models/PickItem'; import { Product } from '../models/Product'; interface PickItemRowProps { item: PickItem; product?: Product | null; onIncrementQuantity: () => void; onDecrementQuantity: () => void; onToggleCarton: () => void; onStatusChange: (status: PickItem['status']) => void; onDelete: () => void; } export const PickItemRow = ({ item, product, onIncrementQuantity, onDecrementQuantity, onToggleCarton, onStatusChange, onDelete, }: PickItemRowProps) => { const [isConfirmOpen, setIsConfirmOpen] = useState(false); const [isControlsOpen, setIsControlsOpen] = useState(false); const packagingLabel = item.is_carton ? product?.bulk_name ?? 'Carton' : product?.unit_type ?? 'Unit'; const toggleStatus = (checked: boolean) => { onStatusChange(checked ? 'picked' : 'pending'); }; const handleConfirmDelete = () => { onDelete(); setIsConfirmOpen(false); }; return ( setIsControlsOpen(true)} role="button" tabIndex={0} onKeyDown={(event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); setIsControlsOpen(true); } }} > toggleStatus(event.target.checked)} inputProps={{ 'aria-label': 'Toggle picked status' }} onClick={(event) => event.stopPropagation()} /> {product?.name ?? 'Unknown product'} {item.quantity} {packagingLabel} Tap to adjust quantity and packaging setIsControlsOpen(false)} fullWidth maxWidth="xs" aria-labelledby="item-controls-title" > {product?.name ?? 'Unknown product'} setIsControlsOpen(false)}> Quantity: {item.quantity} {packagingLabel} `0 0 0 8px ${alpha(theme.palette.primary.main, 0.15)}` : 'none', }} > setIsConfirmOpen(true)} aria-label="Delete item" > setIsConfirmOpen(false)} aria-labelledby="confirm-delete-title" aria-describedby="confirm-delete-description" > Delete item {`Are you sure you want to delete ${product?.name ?? 'this product'} from the pick list?`} ); };