mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +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
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel (or oxc when used in rolldown-vite) for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])