1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 10:39:35 +01:00

feat: TUI-Screens für Inventar und Produktion + API-Client Typ-Migration

Neue TUI-Features:
- Inventar: Lageorte auflisten, anlegen, bearbeiten, (de-)aktivieren
- Produktion: Rezepte auflisten, anlegen, Detail-Ansicht
- Navigation erweitert (Hauptmenü, Routing)

API-Client auf generierte OpenAPI-Typen umgestellt:
- 6 neue Alias-Dateien in @effigenix/types (supplier, category, article,
  customer, inventory, production)
- api-client Re-Exports direkt von @effigenix/types statt via Resources
- Backend: @Schema(requiredProperties) auf 16 Response-Records
- Backend: OpenApiCustomizer für application-layer DTOs (UserDTO, RoleDTO)

Hinweis: Backend-Endpoints für GET /api/recipes und
GET /api/inventory/storage-locations/{id} fehlen noch (separate Issues).
This commit is contained in:
Sebastian Frick 2026-02-19 13:45:35 +01:00
parent bee3f28b5f
commit c26d72fbe7
48 changed files with 2090 additions and 474 deletions

View file

@ -0,0 +1,103 @@
import React, { useCallback, useEffect, useState } from 'react';
import { Box, Text, useInput } from 'ink';
import type { RecipeDTO, RecipeType } from '@effigenix/api-client';
import { RECIPE_TYPE_LABELS } from '@effigenix/api-client';
import { useNavigation } from '../../state/navigation-context.js';
import { LoadingSpinner } from '../shared/LoadingSpinner.js';
import { ErrorDisplay } from '../shared/ErrorDisplay.js';
import { client } from '../../utils/api-client.js';
function errorMessage(err: unknown): string {
return err instanceof Error ? err.message : 'Unbekannter Fehler';
}
export function RecipeDetailScreen() {
const { params, back } = useNavigation();
const recipeId = params['recipeId'] ?? '';
const [recipe, setRecipe] = useState<RecipeDTO | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const loadRecipe = useCallback(() => {
setLoading(true);
setError(null);
client.recipes.getById(recipeId)
.then((r) => { setRecipe(r); setLoading(false); })
.catch((err: unknown) => { setError(errorMessage(err)); setLoading(false); });
}, [recipeId]);
useEffect(() => { if (recipeId) loadRecipe(); }, [loadRecipe, recipeId]);
useInput((_input, key) => {
if (loading) return;
if (key.backspace || key.escape) back();
});
if (loading) return <LoadingSpinner label="Lade Rezept..." />;
if (error && !recipe) return <ErrorDisplay message={error} onDismiss={back} />;
if (!recipe) return <Text color="red">Rezept nicht gefunden.</Text>;
const typeName = RECIPE_TYPE_LABELS[recipe.type as RecipeType] ?? recipe.type;
return (
<Box flexDirection="column" gap={1}>
<Text color="cyan" bold>Rezept: {recipe.name}</Text>
{error && <ErrorDisplay message={error} onDismiss={() => setError(null)} />}
<Box flexDirection="column" borderStyle="round" borderColor="gray" paddingX={2} paddingY={1}>
<Box gap={2}>
<Text color="gray">Status:</Text>
<Text bold>{recipe.status}</Text>
</Box>
<Box gap={2}>
<Text color="gray">Typ:</Text>
<Text>{typeName}</Text>
</Box>
<Box gap={2}>
<Text color="gray">Version:</Text>
<Text>{recipe.version}</Text>
</Box>
{recipe.description && (
<Box gap={2}>
<Text color="gray">Beschreibung:</Text>
<Text>{recipe.description}</Text>
</Box>
)}
<Box gap={2}>
<Text color="gray">Ausbeute:</Text>
<Text>{recipe.yieldPercentage}%</Text>
</Box>
{recipe.shelfLifeDays !== null && (
<Box gap={2}>
<Text color="gray">Haltbarkeit:</Text>
<Text>{recipe.shelfLifeDays} Tage</Text>
</Box>
)}
<Box gap={2}>
<Text color="gray">Ausgabemenge:</Text>
<Text>{recipe.outputQuantity} {recipe.outputUom}</Text>
</Box>
{recipe.ingredients.length > 0 && (
<Box flexDirection="column" marginTop={1}>
<Text color="gray">Zutaten:</Text>
{recipe.ingredients.map((ing) => (
<Box key={ing.id} paddingLeft={2} gap={1}>
<Text color="yellow">{ing.position}.</Text>
<Text>{ing.quantity} {ing.uom}</Text>
<Text color="gray">(Artikel: {ing.articleId})</Text>
{ing.substitutable && <Text color="green">[austauschbar]</Text>}
</Box>
))}
</Box>
)}
</Box>
<Box marginTop={1}>
<Text color="gray" dimColor>Backspace Zurück</Text>
</Box>
</Box>
);
}