mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 13:59:36 +01:00
feat(tui): Stock-Suche mit Namensanzeige für Bestände
StockPicker-Komponente für Bestandssuche nach Artikel-/Lagerort-Namen. StockBatchEntryScreen nutzt StockPicker statt manueller UUID-Eingabe. StockListScreen mit Suchfilter [s] und Namensanzeige statt IDs. StockDetailScreen zeigt Artikel-/Lagerort-Namen im Header.
This commit is contained in:
parent
376557925a
commit
e25d4437d9
5 changed files with 281 additions and 47 deletions
37
frontend/apps/cli/src/hooks/useStockNameLookup.ts
Normal file
37
frontend/apps/cli/src/hooks/useStockNameLookup.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { useEffect, useMemo, useCallback } from 'react';
|
||||
import { useArticles } from './useArticles.js';
|
||||
import { useStorageLocations } from './useStorageLocations.js';
|
||||
|
||||
export function useStockNameLookup() {
|
||||
const { articles, fetchArticles } = useArticles();
|
||||
const { storageLocations, fetchStorageLocations } = useStorageLocations();
|
||||
|
||||
useEffect(() => {
|
||||
void fetchArticles();
|
||||
void fetchStorageLocations();
|
||||
}, [fetchArticles, fetchStorageLocations]);
|
||||
|
||||
const articleNames = useMemo(() => {
|
||||
const map = new Map<string, string>();
|
||||
for (const a of articles) map.set(a.id, a.name);
|
||||
return map;
|
||||
}, [articles]);
|
||||
|
||||
const locationNames = useMemo(() => {
|
||||
const map = new Map<string, string>();
|
||||
for (const l of storageLocations) map.set(l.id, l.name);
|
||||
return map;
|
||||
}, [storageLocations]);
|
||||
|
||||
const articleName = useCallback(
|
||||
(id: string) => articleNames.get(id) ?? id.substring(0, 8) + '…',
|
||||
[articleNames],
|
||||
);
|
||||
|
||||
const locationName = useCallback(
|
||||
(id: string) => locationNames.get(id) ?? id.substring(0, 8) + '…',
|
||||
[locationNames],
|
||||
);
|
||||
|
||||
return { articleName, locationName };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue