From 76c7fd41bdd86723cd9170fe41fe6e08027dae71 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Fri, 27 Sep 2024 16:54:47 +0200 Subject: [PATCH 01/15] add forgotpassword page --- .../lib/components/UserForgotPassword.svelte | 74 +++++++++++++++++++ .../routes/userLand/lostPassword/+page.svelte | 5 ++ 2 files changed, 79 insertions(+) create mode 100644 frontend/src/lib/components/UserForgotPassword.svelte diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte new file mode 100644 index 00000000..682d41ee --- /dev/null +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -0,0 +1,74 @@ + + +{#if showAlert} + { + showAlert = false; + }} + /> +{/if} + +
+ + {#if heading} + {heading} + {/if} + +
+ {#each data as element} + + {/each} +
+ + +
+
diff --git a/frontend/src/routes/userLand/lostPassword/+page.svelte b/frontend/src/routes/userLand/lostPassword/+page.svelte index e69de29b..8e424da9 100644 --- a/frontend/src/routes/userLand/lostPassword/+page.svelte +++ b/frontend/src/routes/userLand/lostPassword/+page.svelte @@ -0,0 +1,5 @@ + + + From 22a4e019b42d2e1290d92ef74476a8eaa68d8b9c Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Fri, 27 Sep 2024 17:02:27 +0200 Subject: [PATCH 02/15] add validation --- .../lib/components/UserForgotPassword.svelte | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index 682d41ee..de1bc3eb 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -4,7 +4,7 @@ import DataInput from '$lib/components/DataInput/DataInput.svelte'; import { Button, Card, Heading, Input } from 'flowbite-svelte'; - const heading = 'Password vergessen?'; + const heading = 'Passwort vergessen?'; const data = [ { component: Input, @@ -15,7 +15,7 @@ } } ]; - const alertMessage = 'Die angegebene email Adresse hat ein falsches Format'; + let alertMessage = 'Die angegebene email Adresse hat ein falsches Format'; const alertTitle = 'Fehler'; let valid: boolean = true; let showAlert: boolean = !valid; @@ -24,6 +24,26 @@ const mailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return mailRegex.test(value) && value !== null; } + + async function submitData(mailstring: string): Promise { + try { + const response = await fetchDummy('api/forgot-password', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(mailstring) + }); + + if (!response.ok) { + throw new Error('Network error'); + } + } catch (error) { + console.log(error); + showAlert = true; + alertMessage = 'Beim Senden ist ein Fehler aufgetreten'; + } + } {#if showAlert} @@ -68,6 +88,9 @@ on:click={(event) => { valid = validateEmail(data[0].value); showAlert = !valid; + if (valid) { + submitData(data[0].value); + } }}>Absenden From 60f042d4fc36039532294fbfad3d41387333f928 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Fri, 27 Sep 2024 17:17:18 +0200 Subject: [PATCH 03/15] add success and failure handling --- .../lib/components/UserForgotPassword.svelte | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index de1bc3eb..96c68112 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -1,30 +1,39 @@
@@ -63,7 +61,7 @@
- {:else} -
-

{mailSentMessage}

-
+
+ {:else} +
- {/if} - -
+
+ {/if} + From a7af4fa20dc73e3d3d2ccfec97f1f92d7c0709da Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Mon, 14 Oct 2024 10:55:57 +0200 Subject: [PATCH 05/15] add padding, margin to card --- frontend/src/lib/components/UserForgotPassword.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index 83a8d81e..1c08ae17 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -70,7 +70,7 @@ /> {/if} - + Date: Mon, 14 Oct 2024 11:05:05 +0200 Subject: [PATCH 06/15] change some types, values to get rid of errors --- .../lib/components/DataInput/DataInput.svelte | 4 ++-- .../lib/components/UserForgotPassword.svelte | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib/components/DataInput/DataInput.svelte b/frontend/src/lib/components/DataInput/DataInput.svelte index fe9215ed..c4e1785b 100644 --- a/frontend/src/lib/components/DataInput/DataInput.svelte +++ b/frontend/src/lib/components/DataInput/DataInput.svelte @@ -8,7 +8,7 @@ // variables export let component: any; export let value: any; - export let label: string; + export let label: string | null = null; export let componentClass: string = ''; export let textTrigger: string = 'noAdditionalText'; export let showTextField: boolean = false; @@ -63,7 +63,7 @@ { + async function submitData(mailstring: string | null): Promise { try { const response = await fetchDummy('api/forgot-password', { method: 'POST', @@ -80,14 +84,8 @@
{:else} From 46735f0d8069f5b415d21ded85bb88a8477de493 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Mon, 14 Oct 2024 11:57:56 +0200 Subject: [PATCH 07/15] add localization --- .../lib/components/UserForgotPassword.svelte | 32 ++++++++++++++----- frontend/src/locales/de.json | 13 ++++++++ frontend/src/locales/en.json | 13 ++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index e5d03d75..b60e1f4c 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -3,23 +3,27 @@ import { base } from '$app/paths'; import AlertMessage from '$lib/components/AlertMessage.svelte'; import DataInput from '$lib/components/DataInput/DataInput.svelte'; + import { lang_id } from '$lib/stores/langStore'; import { Button, Card, Heading, Input } from 'flowbite-svelte'; + import { onDestroy, onMount } from 'svelte'; + import { _ } from 'svelte-i18n'; + import { get } from 'svelte/store'; - const heading = 'Passwort vergessen?'; + const heading = $_('user.forgotPw.heading'); const maildata = { component: Input, type: 'text', value: null, props: { - placeholder: 'Bitte geben sie eine E-mail Adresse an um ihr Passwort zu erneuern' + placeholder: $_('user.forgotPw.placeholder') } }; - const successButtonLabel: string = 'Zurück zur Startseite'; - const pendingButtonLabel: string = 'Absenden'; - const mailSentMessage: string = 'Überprüfen sie ihr E-Mail Postfach'; - const alertTitle: string = 'Fehler'; + const successButtonLabel: string = $_('user.forgotPw.success'); + const pendingButtonLabel: string = $_('user.forgotPw.pending'); + const mailSentMessage: string = $_('user.forgotPw.mailSentMessage'); + const alertTitle: string = $_('user.forgotPw.alertTitle'); - let alertMessage: string = 'Die angegebene email Adresse hat ein falsches Format'; + let alertMessage: string = $_('user.forgotPw.alertMessage'); let valid: boolean = true; let showAlert: boolean = !valid; let showSuccess: boolean = false; @@ -58,9 +62,21 @@ } catch (error) { console.log(error); showAlert = true; - alertMessage = 'Beim Senden ist ein Fehler aufgetreten'; + alertMessage = $_('user.forgotPw.sendError'); } } + + let unsubscribe: () => void; + + onMount(async () => { + unsubscribe = await lang_id.subscribe(() => { + console.log('language changed: ', get(lang_id)); + }); + }); + + onDestroy(() => { + unsubscribe(); + }); {#if showAlert} diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 733000b4..7f57280c 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -44,5 +44,18 @@ "help": "Förderhilfen", "image": "Bild", "images": "Bilder" + }, + "user": { + "login": {}, + "forgotPw": { + "heading": "Passwort vergessen?", + "placeholder": "Bitte geben sie eine E-mail Adresse an um ihr Passwort zu erneuern", + "success": "Zurück zur Startseite", + "pending": "Absenden", + "alertTitle": "Fehler", + "alertMessage": "Die angegebene email Adresse hat ein falsches Format", + "mailSentMessage": "Bitte überprüfen sie ihr E-Mail Postfach", + "sendError": "Beim Senden der Daten ist ein Fehler aufgetreten. Bitte versuchen sie es erneut" + } } } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a4b846d1..c0f76310 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -44,5 +44,18 @@ "help": "More information", "image": "Image", "images": "Images" + }, + "user": { + "login": {}, + "forgotPw": { + "heading": "Forgot your password?", + "placeholder": "Please enter your e-mail adress to get a new password", + "success": "Back to home", + "pending": "Send", + "alertTitle": "Error", + "alertMessage": "The given e-mail adress has a wrong format.", + "mailSentMessage": "Please check your e-mail inbox", + "sendError": "An error occured while sending the data. Please try again." + } } } From 22376cd9072ed51ff739a536f40c646ad3cc3ce8 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Mon, 14 Oct 2024 13:50:49 +0200 Subject: [PATCH 08/15] try to integrate backend call --- .../lib/components/UserForgotPassword.svelte | 52 ++++++------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index b60e1f4c..c3cec375 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -1,13 +1,11 @@ {#if showAlert} @@ -104,13 +85,7 @@ properties={maildata.props} /> - {:else} -
-

{mailSentMessage}

-
- {/if} - {#if showSuccess === false}
{:else} +
+

{mailSentMessage}

+
{$_('user.forgotPw.pending')}
{:else}
-

{mailSentMessage}

+

{$_('user.forgotPw.mailSentMessage')}

{$_('user.forgotPw.success')}
{/if} diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 7f57280c..fc1dbf4e 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -53,7 +53,7 @@ "success": "Zurück zur Startseite", "pending": "Absenden", "alertTitle": "Fehler", - "alertMessage": "Die angegebene email Adresse hat ein falsches Format", + "formatError": "Die angegebene email Adresse hat ein falsches Format", "mailSentMessage": "Bitte überprüfen sie ihr E-Mail Postfach", "sendError": "Beim Senden der Daten ist ein Fehler aufgetreten. Bitte versuchen sie es erneut" } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index c0f76310..a8703446 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -53,7 +53,7 @@ "success": "Back to home", "pending": "Send", "alertTitle": "Error", - "alertMessage": "The given e-mail adress has a wrong format.", + "formatError": "The given e-mail adress has a wrong format.", "mailSentMessage": "Please check your e-mail inbox", "sendError": "An error occured while sending the data. Please try again." } From 752349d2af4ebddcd2164d7099baed908bedefe6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 14 Oct 2024 12:09:43 +0000 Subject: [PATCH 10/15] update openapi.json & openapi-ts client, run pnpm format --- frontend/src/lib/components/DataDisplay/GalleryDisplay.svelte | 2 +- frontend/src/lib/components/DataInput/DataInput.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/DataDisplay/GalleryDisplay.svelte b/frontend/src/lib/components/DataDisplay/GalleryDisplay.svelte index fad805d1..8be3fbf6 100644 --- a/frontend/src/lib/components/DataDisplay/GalleryDisplay.svelte +++ b/frontend/src/lib/components/DataDisplay/GalleryDisplay.svelte @@ -61,7 +61,7 @@
-
+
+ +
+ {:else}
-

{$_('user.forgotPw.mailSentMessage')}

+

{$_('forgotPw.mailSentMessage')}

{$_('forgotPw.success')}
{/if} From 20069f51f595755bdd963718d01bb9993507d99a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 15 Oct 2024 08:19:25 +0000 Subject: [PATCH 13/15] update openapi.json & openapi-ts client, run pnpm format --- frontend/src/lib/components/DataInput/DataInput.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/components/DataInput/DataInput.svelte b/frontend/src/lib/components/DataInput/DataInput.svelte index 789f8e40..09edb483 100644 --- a/frontend/src/lib/components/DataInput/DataInput.svelte +++ b/frontend/src/lib/components/DataInput/DataInput.svelte @@ -63,7 +63,7 @@ Date: Tue, 15 Oct 2024 10:58:22 +0200 Subject: [PATCH 14/15] add button styling --- frontend/src/lib/components/UserForgotPassword.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index bca6e445..143af147 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -83,6 +83,7 @@