Skip to content
Snippets Groups Projects
Commit 30366869 authored by Malin Haugland Høli's avatar Malin Haugland Høli
Browse files

fix: :ambulance: Add confirmation when email is sent or fails to send

parent 5031abc5
No related branches found
No related tags found
3 merge requests!66Final merge,!38Confirmation when email is sent,!4Pipeline fix
...@@ -15,6 +15,8 @@ const emailRegex = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\ ...@@ -15,6 +15,8 @@ const emailRegex = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\
const userStore = useUserStore() const userStore = useUserStore()
const isEmailValid = computed(() => emailRegex.test(resetEmail.value)) const isEmailValid = computed(() => emailRegex.test(resetEmail.value))
const isSendingEmail = ref(false);
const successMessage = ref<string>('');
const submitForm = () => { const submitForm = () => {
userStore.login(username.value, password.value) userStore.login(username.value, password.value)
...@@ -30,12 +32,20 @@ const openForgotPasswordModal = (event: MouseEvent) => { ...@@ -30,12 +32,20 @@ const openForgotPasswordModal = (event: MouseEvent) => {
} }
const submitReset = async () => { const submitReset = async () => {
await axios.post('http://localhost:8080/forgotPassword/changePasswordRequest', { isSendingEmail.value = true;
email: resetEmail.value try {
}) await axios.post('http://localhost:8080/forgotPassword/changePasswordRequest', {
email: resetEmail.value
resetEmail.value = '' });
isModalOpen.value = false successMessage.value = 'E-posten er sendt. Vennligst sjekk innboksen din for instrukser. OBS: E-posten kan havne i spam-mappen';
resetEmail.value = '';
} catch (error) {
console.error(error);
errorMessage.value = 'Noe gikk galt. Vennligst prøv igjen.';
} finally {
isSendingEmail.value = false;
isModalOpen.value = false;
}
} }
const closeModal = () => { const closeModal = () => {
...@@ -51,6 +61,7 @@ watch( ...@@ -51,6 +61,7 @@ watch(
) )
</script> </script>
<template> <template>
<div class="flex flex-col justify-center gap-5 w-full"> <div class="flex flex-col justify-center gap-5 w-full">
<div class="flex flex-col"> <div class="flex flex-col">
...@@ -101,30 +112,37 @@ watch( ...@@ -101,30 +112,37 @@ watch(
:title="'Glemt passord'" :title="'Glemt passord'"
:message="'Vennligst skriv inn e-posten din for å endre passordet.'" :message="'Vennligst skriv inn e-posten din for å endre passordet.'"
:is-modal-open="isModalOpen" :is-modal-open="isModalOpen"
@close="isModalOpen = false" @close="closeModal"
> >
<template v-slot:input> <template v-slot:input>
<input <div v-if="isSendingEmail" class="flex justify-center items-center">
type="email" <div class="p-3 animate-spin drop-shadow-2xl bg-gradient-to-r from-lime-500 from-30% to-green-600 to-90% md:w-18 md:h-20 h-20 w-20 aspect-square rounded-full">
v-model="resetEmail" <div class="rounded-full h-full w-full bg-slate-100 dark:bg-zinc-900 background-blur-md"></div>
class="border border-gray-300 p-2 w-full mb-7" </div>
placeholder="Skriv e-postadressen din her" </div>
/> <div v-else>
</template> <input
<template v-slot:buttons> type="email"
<button v-model="resetEmail"
:disabled="!isEmailValid" class="border border-gray-300 p-2 w-full mb-7"
@click="submitReset" placeholder="Skriv e-postadressen din her"
class="active-button font-bold py-2 px-4 w-1/2 border-2 disabled:border-transparent" />
> <div class="flex gap-5 mt-4">
Send mail <button
</button> :disabled="!isEmailValid"
<button @click="submitReset"
@click="closeModal" class="active-button font-bold py-2 px-4 w-1/2 border-2 disabled:border-transparent"
class="active-button font-bold py-2 px-4 w-1/2 border-2 disabled:border-transparent" >
> Send mail
Lukk </button>
</button> <button
@click="closeModal"
class="active-button font-bold py-2 px-4 w-1/2 border-2 disabled:border-transparent"
>
Lukk
</button>
</div>
</div>
</template> </template>
</modal-component> </modal-component>
</template> </template>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment