diff --git a/frontend/src/lib/components/UserForgotPassword.svelte b/frontend/src/lib/components/UserForgotPassword.svelte index c3cec375..071297c4 100644 --- a/frontend/src/lib/components/UserForgotPassword.svelte +++ b/frontend/src/lib/components/UserForgotPassword.svelte @@ -7,7 +7,6 @@ import { Button, Card, Heading, Input } from 'flowbite-svelte'; import { _ } from 'svelte-i18n'; - const heading = $_('user.forgotPw.heading'); const maildata = { component: Input, type: 'text', @@ -16,12 +15,8 @@ placeholder: $_('user.forgotPw.placeholder') } }; - 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 = $_('user.forgotPw.alertMessage'); + let alertMessage: string = $_('user.forgotPw.formatError'); let valid: boolean = true; let showAlert: boolean = !valid; let showSuccess: boolean = false; @@ -36,33 +31,29 @@ } async function submitData(mailstring: string): Promise { - try { - const data = { - body: { - email: mailstring - }, - throwOnError: true - }; - const { response, error } = await resetForgotPassword(data); + const data = { + body: { + email: mailstring + }, + throwOnError: true + }; - if (error) { - console.log('error: ', error); - throw Error(error); - } else { - console.log('successful transmission, response status: ', response.status); + await resetForgotPassword(data) + .then((returned) => { + console.log('successful transmission, response status: ', returned.response.status); showSuccess = true; - } - } catch (error) { - console.log(error); - showAlert = true; - alertMessage = $_('user.forgotPw.sendError'); - } + }) + .catch((error) => { + console.log(error); + showAlert = true; + alertMessage = $_('user.forgotPw.sendError'); + }); } {#if showAlert} { @@ -75,7 +66,7 @@ {heading}{$_('user.forgotPw.heading')} {#if showSuccess === false}
@@ -95,19 +86,19 @@ if (valid) { submitData(maildata.value); } - }}>{pendingButtonLabel}{$_('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." }