From df9e7c5541005b38cf6ee0091ff1ef40f3d19222 Mon Sep 17 00:00:00 2001 From: clawd Date: Fri, 20 Feb 2026 10:11:54 +0000 Subject: [PATCH] =?UTF-8?q?v0.2.1=20=E2=80=94=20Code=20Review=20Fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: - CRITICAL: compareVersions used string comparison, fails for 1.10 vs 1.9 (now numeric) - CRITICAL: Double CloseDatabase() in main.go (defer + OnShutdown) - CRITICAL: Tailwind v4 in package.json but v3 config/syntax (downgraded to v3) - CRITICAL: react-router-dom v7 with v5 types (switched to v6, removed deprecated types) - IMPORTANT: UpdatePlanEntry hook signature mismatch (7 args vs Go's 4) - IMPORTANT: AllergenPicker hidden checkbox inaccessible to screenreaders (sr-only) - IMPORTANT: weekHelper getWeekFromDate returned wrong ISO year for edge cases - IMPORTANT: getWeeksInYear bug for years where Dec 31 is in week 1 of next year - IMPORTANT: getDateFromWeek off-by-one for some years (use Jan 4 anchor) - IMPORTANT: ProductSearch click-outside missed dropdown (use container ref) - IMPORTANT: seed.go LastInsertId=0 on INSERT OR IGNORE skip - IMPORTANT: SQLite missing PRAGMA foreign_keys=ON and WAL mode - IMPORTANT: AdditivePicker ADDITIVE_NAMES used numeric IDs but data uses letters - IMPORTANT: Missing role=dialog/aria-modal on all modal dialogs - IMPORTANT: Missing Escape key handler on ProductForm modal - IMPORTANT: Sidebar NavLink aria-current used function instead of string - IMPORTANT: useProducts searchProducts null safety for allergens/additives - NICE-TO-HAVE: Added aria-live=polite to WeekPlanner for dynamic updates - NICE-TO-HAVE: Added postcss.config.js for Tailwind v3 - NICE-TO-HAVE: Updated model comments to match actual day/meal conventions - NICE-TO-HAVE: Modernized vite/typescript/plugin versions --- db.go | 4 +++ frontend/package.json | 15 ++++----- frontend/postcss.config.js | 2 +- frontend/src/components/AdditivePicker.tsx | 31 ++---------------- frontend/src/components/AllergenPicker.tsx | 2 +- frontend/src/components/ProductForm.tsx | 18 ++++++++++- frontend/src/components/ProductSearch.tsx | 5 +-- frontend/src/components/Sidebar.tsx | 10 ++++-- frontend/src/components/SpecialDayDialog.tsx | 8 ++++- frontend/src/components/WeekPlanner.tsx | 2 +- frontend/src/hooks/useProducts.ts | 8 ++--- frontend/src/hooks/useWeekPlan.ts | 5 +-- frontend/src/lib/weekHelper.ts | 34 +++++++++++--------- main.go | 7 ---- models.go | 8 ++--- seed.go | 3 +- updater.go | 20 +++++++++--- 17 files changed, 98 insertions(+), 84 deletions(-) diff --git a/db.go b/db.go index a313020..1958d37 100644 --- a/db.go +++ b/db.go @@ -29,6 +29,10 @@ func InitDatabase() error { db = database + // SQLite Pragmas setzen + db.MustExec("PRAGMA journal_mode=WAL") + db.MustExec("PRAGMA foreign_keys=ON") + // Schema erstellen if err := createSchema(); err != nil { return fmt.Errorf("failed to create schema: %w", err) diff --git a/frontend/package.json b/frontend/package.json index 6c23523..086ed7b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,19 +9,18 @@ "preview": "vite preview" }, "dependencies": { - "@types/react-router-dom": "^5.3.3", - "autoprefixer": "^10.4.24", - "postcss": "^8.5.6", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^7.13.0", - "tailwindcss": "^4.2.0" + "react-router-dom": "^6.26.0" }, "devDependencies": { "@types/react": "^18.0.17", "@types/react-dom": "^18.0.6", - "@vitejs/plugin-react": "^2.0.1", - "typescript": "^4.6.4", - "vite": "^3.0.7" + "@vitejs/plugin-react": "^4.3.0", + "autoprefixer": "^10.4.24", + "postcss": "^8.5.6", + "tailwindcss": "^3.4.0", + "typescript": "^5.5.0", + "vite": "^5.4.0" } } diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js index e99ebc2..2e7af2b 100644 --- a/frontend/postcss.config.js +++ b/frontend/postcss.config.js @@ -3,4 +3,4 @@ export default { tailwindcss: {}, autoprefixer: {}, }, -} \ No newline at end of file +} diff --git a/frontend/src/components/AdditivePicker.tsx b/frontend/src/components/AdditivePicker.tsx index f5b66fa..e01d5e2 100644 --- a/frontend/src/components/AdditivePicker.tsx +++ b/frontend/src/components/AdditivePicker.tsx @@ -7,33 +7,8 @@ interface AdditivePickerProps { className?: string; } -// Deutsche Namen für häufige Zusatzstoffe (E-Nummern) -const ADDITIVE_NAMES: Record = { - '1': 'Farbstoff', - '2': 'Konservierungsstoff', - '3': 'Antioxidationsmittel', - '4': 'Geschmacksverstärker', - '5': 'Geschwefelt', - '6': 'Geschwärzt', - '7': 'Gewachst', - '8': 'Phosphat', - '9': 'Süßungsmittel', - '10': 'Phenylalaninquelle', - '11': 'Koffeinhaltig', - '12': 'Chininhaltig', - '13': 'Alkoholhaltig', - '14': 'Nitritpökelsalz', - '15': 'Milchsäure', - '16': 'Citronensäure', - '17': 'Ascorbinsäure', - '18': 'Tocopherol', - '19': 'Lecithin', - '20': 'Johannisbrotkernmehl', - '21': 'Guarkernmehl', - '22': 'Xanthan', - '23': 'Carrageen', - '24': 'Agar' -}; +// Die Zusatzstoffe kommen direkt aus der DB mit id + name, +// daher wird hier kein separates Mapping benötigt. export function AdditivePicker({ additives, selectedIds, onChange, className = '' }: AdditivePickerProps) { const handleToggle = (additiveId: string) => { @@ -68,7 +43,7 @@ export function AdditivePicker({ additives, selectedIds, onChange, className = ' > {sortedAdditives.map(additive => { const isSelected = selectedIds.includes(additive.id); - const displayName = ADDITIVE_NAMES[additive.id] || additive.name; + const displayName = additive.name; return (