diff --git a/common/src/models/settings.rs b/common/src/models/settings.rs index fada499..42e4ae6 100644 --- a/common/src/models/settings.rs +++ b/common/src/models/settings.rs @@ -8,6 +8,8 @@ pub struct Settings { pub id: i64, pub mhd: String, pub bio: String, + pub allergens_text: String, + pub bio_info: String, } fn from_postgres_row_small(row: PgRow) -> Settings { @@ -15,6 +17,8 @@ fn from_postgres_row_small(row: PgRow) -> Settings { id: row.get(0), mhd: row.get(1), bio: row.get(2), + allergens_text: row.get(3), + bio_info: row.get(4), } } @@ -44,9 +48,11 @@ pub async fn update_settings(settings: &Settings, pool: PgPool) -> Option = ref(false); @@ -25,15 +26,23 @@ switch (name) { case "MHD": console.log("Update MHD: " + value); - const settingsMhd = new Settings(store.settings.id, value, store.settings.bio); + const settingsMhd = new Settings(store.settings.id, value, store.settings.bio, store.settings.allergens_text, store.settings.bio_info); await store.updateSettings(settingsMhd); - break; case "BIO": console.log("Update BIO: " + value); - const settingsBio = new Settings(store.settings.id, store.settings.mhd, value); + const settingsBio = new Settings(store.settings.id, store.settings.mhd, value, store.settings.allergens_text, store.settings.bio_info); await store.updateSettings(settingsBio); - + break; + case "Allergen Hinweis": + console.log("Update Allergen Text: " + value); + const settingsAllergens = new Settings(store.settings.id, store.settings.mhd, store.settings.bio, value, store.settings.bio_info); + await store.updateSettings(settingsAllergens); + break; + case "BIO Hinweis": + console.log("Update Allergen Text: " + value); + const settingsBioInfo = new Settings(store.settings.id, store.settings.mhd, store.settings.bio, store.settings.allergens_text, value); + await store.updateSettings(settingsBioInfo); break; default: console.log("Error: Unbekannter Wert für Einstellungen"); @@ -80,11 +89,6 @@ Einstellungen - - - - - @@ -104,6 +108,20 @@ v-bind:value="store.settings.bio" @update="updateSettings" /> + + + + diff --git a/frontend/app/types/settings.ts b/frontend/app/types/settings.ts index e1db537..2774c4f 100644 --- a/frontend/app/types/settings.ts +++ b/frontend/app/types/settings.ts @@ -2,10 +2,14 @@ export class Settings { readonly id: number; mhd: string; bio: string; + allergens_text: string; + bio_info: string; - constructor(id: number, mhd: string, bio: string) { + constructor(id: number, mhd: string, bio: string, allergens_text: string, bio_info: string) { this.id = id; this.mhd = mhd; this.bio = bio; + this.allergens_text = allergens_text; + this.bio_info = bio_info; } } diff --git a/server/migrations/20260202170049_allergens_text_settings.sql b/server/migrations/20260202170049_allergens_text_settings.sql new file mode 100644 index 0000000..c2cd23c --- /dev/null +++ b/server/migrations/20260202170049_allergens_text_settings.sql @@ -0,0 +1,10 @@ +-- Add migration script here + +ALTER TABLE public.settings + ADD allergens_text text, + ADD bio_info text; + +UPDATE settings SET + allergens_text = 'Produkt kann Spuren von Erdnüssen, Gluten, Krebstieren, Lupinen, Schalenfrüchte, Sesam, Soja und Weichtieren enthalten.', + bio_info = '+aus kontrolliert biologischem Anbau.' + WHERE id = 1; diff --git a/server/src/main.rs b/server/src/main.rs index fd1f9eb..633a1c5 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -373,6 +373,8 @@ async fn get_settings_route( id: 0, mhd: "".to_string(), bio: "".to_string(), + allergens_text: "".to_string(), + bio_info: "".to_string(), } )) } @@ -396,6 +398,8 @@ async fn update_settings_route( id: 0, mhd: "".to_string(), bio: "".to_string(), + allergens_text: "".to_string(), + bio_info: "".to_string(), } )) }