mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-12 00:45:39 +02:00
Three independent cleanups inside PrintersPage.tsx noticed during the
architectural audit for the upcoming printer-card customization feature
(modular widgets + tile-layout dashboard). All three are pure refactor -
no behavior change, no UI change.
1. getStatusDisplay i18n fix
The function returned hardcoded English regardless of locale -
"Printing" / "Paused" / "Finished" / "Failed" / "Idle". A latent bug
that surfaced as German/French/etc. printer cards rendering English
status text. Now takes `t` as its first arg and returns
t('printers.status.X') keys. printers.status.{idle,printing,paused,
finished} already existed in all 8 locales; only `failed` was missing
- added natively across en/de/fr/it/ja/pt-BR/zh-CN/zh-TW.
2. resolveSlotFill utility extraction
The ~80-line "Spoolman tag -> slot assignment -> inventory -> AMS
remain" fill-level chain was triply duplicated - once for regular AMS
slots, once for HT AMS slots, once for external spool, with `*` /
`ht*` / `ext*` variable prefixes. Pulled into
utils/amsHelpers.ts::resolveSlotFill() as a single typed helper. Call
sites now destructure { effectiveFill, fillSource, slotSpoolForFill,
linkedSpool, slotAssignmentForFill } - last two are needed for
downstream FilamentHoverCard link/unlink/assign wiring. Saves 43
lines net (7,441 -> 7,398).
3. Delete-confirm aligned with the rest
The inline delete confirmation used <div className="fixed inset-0
..."> directly inside <CardContent> - the only confirmation in the
file that wasn't using the shared ConfirmModal. Migrated to
ConfirmModal with the "also delete archives" checkbox passed via a
new optional `children` prop slot (rendered between message and
buttons). The new prop generalizes ConfirmModal for any future
confirm that needs a checkbox or extra inline form.
Verification: npm run build clean; PrintersPageFillLevel.test.ts
(10 tests) and PrinterQueueWidget.test.tsx (7 tests) pass.
PR 1b (sub-component file moves + 2 modal extractions) and PR 1c (the
4,055-line PrinterCard extraction itself) are deferred to dedicated
sessions because moving that much inline JSX is too risky to bundle
with anything else.# modified: frontend/src/utils/amsHelpers.ts