diff --git a/app.go b/app.go index 8e70b3a..94d6131 100644 --- a/app.go +++ b/app.go @@ -373,6 +373,31 @@ func (a *App) DownloadUpdate() (string, error) { return a.updater.DownloadUpdate(*info) } +// PDF EXPORT + +// ExportPDF erstellt eine PDF-Datei des Wochenplans +func (a *App) ExportPDF(weekPlanID int, outputPath string) (string, error) { + // PDF-Export ist ein Platzhalter — in einer späteren Version wird hier + // eine richtige PDF-Bibliothek (z.B. gofpdf) verwendet. + // Vorerst geben wir eine Nachricht zurück. + plan, err := a.getWeekPlanByID(weekPlanID) + if err != nil { + return "", fmt.Errorf("Wochenplan nicht gefunden: %w", err) + } + return fmt.Sprintf("PDF-Export für KW %d/%d wird in einer zukünftigen Version unterstützt. Bitte nutzen Sie die Druckvorschau.", plan.Week, plan.Year), nil +} + +// getWeekPlanByID lädt einen Wochenplan anhand seiner ID +func (a *App) getWeekPlanByID(id int) (*WeekPlan, error) { + var plan WeekPlan + query := "SELECT id, year, week, created_at FROM week_plans WHERE id = ?" + err := db.Get(&plan, query, id) + if err != nil { + return nil, fmt.Errorf("failed to get week plan by ID: %w", err) + } + return &plan, nil +} + // HILFSFUNKTIONEN // loadProductRelations lädt Allergene und Zusatzstoffe für ein Produkt diff --git a/frontend/src/components/InfoPage.tsx b/frontend/src/components/InfoPage.tsx index e50161c..4e804ae 100644 --- a/frontend/src/components/InfoPage.tsx +++ b/frontend/src/components/InfoPage.tsx @@ -79,7 +79,7 @@ export function InfoPage() {
Version
- {updateInfo?.current_version || '1.0.0'} + {updateInfo?.current_version || '0.4.5'}
@@ -345,7 +345,7 @@ export function InfoPage() {

- Version: 1.0.0 (Build 2026.02.20) + Version: 0.4.5 (Build 2026.02.20)

Support: Wenden Sie sich bei Fragen oder Problemen an Ihre IT-Abteilung diff --git a/frontend/src/components/WeekPlanner.tsx b/frontend/src/components/WeekPlanner.tsx index 650d5c7..132aeb0 100644 --- a/frontend/src/components/WeekPlanner.tsx +++ b/frontend/src/components/WeekPlanner.tsx @@ -85,9 +85,8 @@ export function WeekPlanner({ year, week, className = '' }: WeekPlannerProps) { setPdfSuccess(null); try { - // ExportPDF nimmt weekPlanID und outputPath - Go-Seite öffnet Save-Dialog mit leer-string - await ExportPDF(weekPlan.id, ''); - setPdfSuccess('PDF wurde erfolgreich erstellt.'); + const result = await ExportPDF(weekPlan.id, ''); + setPdfSuccess(result || 'PDF wurde erfolgreich erstellt.'); // Success-Nachricht nach 5 Sekunden ausblenden setTimeout(() => { diff --git a/frontend/src/hooks/useProducts.ts b/frontend/src/hooks/useProducts.ts index efc51f5..aa4513c 100644 --- a/frontend/src/hooks/useProducts.ts +++ b/frontend/src/hooks/useProducts.ts @@ -19,7 +19,7 @@ export function useProducts() { try { const productList = await GetProducts(); - setProducts(productList); + setProducts(productList || []); } catch (err) { setError(err instanceof Error ? err.message : 'Fehler beim Laden der Produkte'); } finally { @@ -35,8 +35,8 @@ export function useProducts() { GetAdditives() ]); - setAllergens(allergenList); - setAdditives(additiveList); + setAllergens(allergenList || []); + setAdditives(additiveList || []); } catch (err) { setError(err instanceof Error ? err.message : 'Fehler beim Laden der Stammdaten'); } diff --git a/frontend/src/hooks/useWeekPlan.ts b/frontend/src/hooks/useWeekPlan.ts index f794ac8..3ef3e74 100644 --- a/frontend/src/hooks/useWeekPlan.ts +++ b/frontend/src/hooks/useWeekPlan.ts @@ -19,6 +19,11 @@ export function useWeekPlan(year: number, week: number) { try { const plan = await GetWeekPlan(year, week); + // Null-Safety: Go kann null für leere Arrays zurückgeben + if (plan) { + plan.entries = plan.entries || []; + plan.special_days = plan.special_days || []; + } setWeekPlan(plan); } catch (err) { setError(err instanceof Error ? err.message : 'Fehler beim Laden des Wochenplans'); @@ -35,6 +40,10 @@ export function useWeekPlan(year: number, week: number) { try { const newPlan = await CreateWeekPlan(year, week); + if (newPlan) { + newPlan.entries = newPlan.entries || []; + newPlan.special_days = newPlan.special_days || []; + } setWeekPlan(newPlan); return newPlan; } catch (err) { @@ -52,6 +61,10 @@ export function useWeekPlan(year: number, week: number) { try { const copiedPlan = await CopyWeekPlan(srcYear, srcWeek, year, week); + if (copiedPlan) { + copiedPlan.entries = copiedPlan.entries || []; + copiedPlan.special_days = copiedPlan.special_days || []; + } setWeekPlan(copiedPlan); return copiedPlan; } catch (err) { @@ -73,7 +86,15 @@ export function useWeekPlan(year: number, week: number) { if (!weekPlan) return null; try { - const newEntry = await AddPlanEntry(weekPlan.id, day, meal, productId, customText, groupLabel); + // Go erwartet null statt undefined für optionale Pointer-Parameter + const newEntry = await AddPlanEntry( + weekPlan.id, + day, + meal, + productId ?? null, + customText ?? null, + groupLabel ?? null + ); // State aktualisieren setWeekPlan(prev => prev ? { @@ -114,7 +135,8 @@ export function useWeekPlan(year: number, week: number) { groupLabel?: GroupLabel ): Promise => { try { - const updatedEntry = await UpdatePlanEntry(entryId, 0, '', 0, productId ?? null, customText ?? null, groupLabel ?? null); + // Go: UpdatePlanEntry(id int, productID *int, customText *string, groupLabel *string) + const updatedEntry = await UpdatePlanEntry(entryId, productId ?? null, customText ?? null, groupLabel ?? null); // State aktualisieren setWeekPlan(prev => prev ? { diff --git a/updater.go b/updater.go index 08a572a..373ad00 100644 --- a/updater.go +++ b/updater.go @@ -16,7 +16,7 @@ import ( const ( // Aktuelle Version der App - CurrentVersion = "0.4.3" + CurrentVersion = "0.4.5" // Update-Check URL UpdateURL = "https://speiseplan.supertoll.xyz/version.json" )