mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 12:29:36 +01:00
feat(production): Batch bei Produktionsstart automatisch erstellen (#73)
- BatchNumber in allen ProductionOrder-Endpoints via BatchRepository auflösen - BatchCreationFailed Error-Variante statt generischem ValidationFailure - bestBeforeDate-Berechnung als Recipe.calculateBestBeforeDate() in die Domain verschoben
This commit is contained in:
parent
26adf21162
commit
600d0f9f06
20 changed files with 356 additions and 397 deletions
|
|
@ -20,7 +20,7 @@ const STATUS_COLORS: Record<string, string> = {
|
|||
CANCELLED: 'red',
|
||||
};
|
||||
|
||||
type Mode = 'view' | 'menu' | 'start-batch-input' | 'reschedule-input';
|
||||
type Mode = 'view' | 'menu' | 'reschedule-input';
|
||||
|
||||
export function ProductionOrderDetailScreen() {
|
||||
const { params, back } = useNavigation();
|
||||
|
|
@ -31,7 +31,6 @@ export function ProductionOrderDetailScreen() {
|
|||
const { recipeName } = useRecipeNameLookup();
|
||||
const [mode, setMode] = useState<Mode>('view');
|
||||
const [menuIndex, setMenuIndex] = useState(0);
|
||||
const [batchId, setBatchId] = useState('');
|
||||
const [newDate, setNewDate] = useState('');
|
||||
const [success, setSuccess] = useState<string | null>(null);
|
||||
const [batch, setBatch] = useState<BatchDTO | null>(null);
|
||||
|
|
@ -80,12 +79,11 @@ export function ProductionOrderDetailScreen() {
|
|||
};
|
||||
|
||||
const handleStart = async () => {
|
||||
if (!batchId.trim()) return;
|
||||
const result = await startProductionOrder(orderId, { batchId: batchId.trim() });
|
||||
const result = await startProductionOrder(orderId);
|
||||
if (result) {
|
||||
setSuccess('Produktion gestartet.');
|
||||
const bn = result.batchNumber ? ` Charge: ${result.batchNumber}` : '';
|
||||
setSuccess(`Produktion gestartet.${bn}`);
|
||||
setMode('view');
|
||||
setBatchId('');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -107,11 +105,6 @@ export function ProductionOrderDetailScreen() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (mode === 'start-batch-input') {
|
||||
if (key.escape) setMode('menu');
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === 'menu') {
|
||||
if (key.upArrow) setMenuIndex((i) => Math.max(0, i - 1));
|
||||
if (key.downArrow) setMenuIndex((i) => Math.min(menuItems.length - 1, i + 1));
|
||||
|
|
@ -122,10 +115,7 @@ export function ProductionOrderDetailScreen() {
|
|||
setMode('reschedule-input');
|
||||
setNewDate('');
|
||||
}
|
||||
if (action === 'start') {
|
||||
setMode('start-batch-input');
|
||||
setBatchId('');
|
||||
}
|
||||
if (action === 'start') void handleStart();
|
||||
}
|
||||
if (key.escape) setMode('view');
|
||||
return;
|
||||
|
|
@ -218,22 +208,6 @@ export function ProductionOrderDetailScreen() {
|
|||
</Box>
|
||||
)}
|
||||
|
||||
{mode === 'start-batch-input' && (
|
||||
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
|
||||
<Text color="yellow" bold>Chargen-ID eingeben:</Text>
|
||||
<Box>
|
||||
<Text color="gray"> › </Text>
|
||||
<TextInput
|
||||
value={batchId}
|
||||
onChange={setBatchId}
|
||||
onSubmit={() => void handleStart()}
|
||||
focus={true}
|
||||
/>
|
||||
</Box>
|
||||
<Text color="gray" dimColor>Enter bestätigen · Escape abbrechen</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{mode === 'reschedule-input' && (
|
||||
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
|
||||
<Text color="yellow" bold>Neues Datum (YYYY-MM-DD):</Text>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue