Restore product edit and delete controls
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
Card,
|
Card,
|
||||||
CardActions,
|
|
||||||
CardContent,
|
CardContent,
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -10,7 +11,6 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
Button,
|
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import DeleteIcon from '@mui/icons-material/Delete';
|
import DeleteIcon from '@mui/icons-material/Delete';
|
||||||
import EditIcon from '@mui/icons-material/Edit';
|
import EditIcon from '@mui/icons-material/Edit';
|
||||||
@@ -89,7 +89,7 @@ export const ProductRow = ({ product, categories, onSave, onDelete }: ProductRow
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="outlined" sx={{ mb: 1 }}>
|
<Card variant="outlined" sx={{ mb: 1 }}>
|
||||||
<CardContent>
|
<CardContent sx={{ p: 1.25, '&:last-child': { pb: 1.25 } }}>
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<TextField label="Name" value={formState.name} onChange={handleChange('name')} size="small" />
|
<TextField label="Name" value={formState.name} onChange={handleChange('name')} size="small" />
|
||||||
@@ -133,44 +133,51 @@ export const ProductRow = ({ product, categories, onSave, onDelete }: ProductRow
|
|||||||
Scan Barcode
|
Scan Barcode
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
<Stack direction="row" spacing={0.5} justifyContent="flex-end" alignItems="center">
|
||||||
) : (
|
<IconButton
|
||||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
aria-label={`Delete ${product.name}`}
|
||||||
<div>
|
onClick={() => onDelete(product.id)}
|
||||||
<Typography variant="subtitle1">{product.name}</Typography>
|
size="small"
|
||||||
<Typography variant="caption" color="text.secondary">
|
color="error"
|
||||||
{product.category} • {product.unit_type || DEFAULT_UNIT_TYPE}
|
>
|
||||||
</Typography>
|
<DeleteIcon fontSize="small" />
|
||||||
</div>
|
</IconButton>
|
||||||
{product.barcode ? (
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
|
||||||
Barcode: {product.barcode}
|
|
||||||
</Typography>
|
|
||||||
) : null}
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
|
||||||
<CardActions sx={{ justifyContent: 'flex-end', pt: 0 }}>
|
|
||||||
{isEditing ? (
|
|
||||||
<>
|
|
||||||
<IconButton aria-label="Save product" onClick={handleSave} disabled={!formState.name} color="primary">
|
<IconButton aria-label="Save product" onClick={handleSave} disabled={!formState.name} color="primary">
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton aria-label="Cancel edit" onClick={handleCancel}>
|
<IconButton aria-label="Cancel edit" onClick={handleCancel}>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</>
|
</Stack>
|
||||||
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<Stack direction="row" alignItems="center" spacing={1} justifyContent="space-between">
|
||||||
<IconButton aria-label={`Edit ${product.name}`} onClick={() => setIsEditing(true)}>
|
<Stack direction="row" spacing={1.5} alignItems="center" sx={{ flex: 1, minWidth: 0 }}>
|
||||||
<EditIcon />
|
<Stack spacing={0.25} sx={{ minWidth: 0 }}>
|
||||||
|
<Typography variant="subtitle1" noWrap>
|
||||||
|
{product.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" color="text.secondary" noWrap>
|
||||||
|
{product.category} • {product.unit_type || DEFAULT_UNIT_TYPE}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
{product.barcode ? (
|
||||||
|
<Typography variant="caption" color="text.secondary" noWrap>
|
||||||
|
Barcode: {product.barcode}
|
||||||
|
</Typography>
|
||||||
|
) : null}
|
||||||
|
</Stack>
|
||||||
|
<Box display="flex" alignItems="center" gap={0.5} sx={{ ml: 1 }}>
|
||||||
|
<IconButton aria-label={`Edit ${product.name}`} onClick={() => setIsEditing(true)} size="small">
|
||||||
|
<EditIcon fontSize="small" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton aria-label={`Delete ${product.name}`} onClick={() => onDelete(product.id)}>
|
<IconButton aria-label={`Delete ${product.name}`} onClick={() => onDelete(product.id)} size="small">
|
||||||
<DeleteIcon />
|
<DeleteIcon fontSize="small" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</>
|
</Box>
|
||||||
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</CardActions>
|
</CardContent>
|
||||||
<Dialog open={isScannerOpen} onClose={() => setIsScannerOpen(false)} fullWidth>
|
<Dialog open={isScannerOpen} onClose={() => setIsScannerOpen(false)} fullWidth>
|
||||||
<DialogTitle>Scan Barcode</DialogTitle>
|
<DialogTitle>Scan Barcode</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user