-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from abes-esr/ITEM-85-Migrer-le-composant-de-m…
…odification-de-l'adresse-mail-(2)---modifier-le-résumé-Migrer-le-composant-de-modification-de-l'adresse-mail-(2) Item 85 migrer le composant de modification de l'adresse mail (2) modifier le résumé migrer le composant de modification de l'adresse mail (2)
- Loading branch information
Showing
6 changed files
with
154 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<v-card class="elevation-5"> | ||
<v-card-title style="background-color: #295494; color: white" > | ||
<span v-if="!email">Première connexion</span> | ||
<span v-else>Modifier les informations de votre compte</span> | ||
</v-card-title> | ||
<v-card-text> | ||
<v-form ref="form" class="pt-5"> | ||
<span> | ||
Votre adresse mail est obligatoire pour utiliser l'application. Pour ajouter plusieurs adresses mail, séparez-les par des points virgules ; | ||
</span> | ||
<v-text-field | ||
prepend-inner-icon="mdi-email-outline" | ||
class="pt-12" | ||
type="email" | ||
name="email" | ||
id="email" | ||
v-model="emailModel" | ||
:rules="rules" | ||
@keyup.enter="validate()"> | ||
</v-text-field> | ||
</v-form> | ||
<v-alert | ||
v-if="messageError" | ||
type="error" | ||
title="Erreur" | ||
:text="messageError" | ||
></v-alert> | ||
</v-card-text> | ||
<v-card-actions> | ||
<v-spacer></v-spacer> | ||
<v-btn | ||
color="#295494" | ||
variant="flat" | ||
:disabled="isDisabled" | ||
@click="validate()">Valider</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</template> | ||
<script setup> | ||
import {onMounted, ref, watch} from 'vue'; | ||
import demandesService from '@/service/DemandesService'; | ||
const emits = defineEmits(['validate']); | ||
const props = defineProps({ | ||
email: { | ||
type: String, | ||
required: true | ||
}, | ||
userId: { | ||
type: String, | ||
required: true | ||
} | ||
}); | ||
const emailModel = ref(); | ||
const isDisabled = ref(true); | ||
const pattern = /^((([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))[;]?)+$/; | ||
const rules = ref([ | ||
value => { | ||
if (value) { | ||
isDisabled.value = false; | ||
return true; | ||
} | ||
isDisabled.value = true; | ||
return 'Champ obligatoire.'; | ||
}, | ||
value => { | ||
if (pattern.test(value)) { | ||
isDisabled.value = false; | ||
return true; | ||
} | ||
isDisabled.value = true; | ||
return 'mail(s) invalide' | ||
} | ||
]); | ||
const messageError = ref(); | ||
onMounted(() => { | ||
emailModel.value = props.email; | ||
}); | ||
function validate() { | ||
demandesService.modifierEmail(props.userId, emailModel.value) | ||
.then(result => { | ||
emits('validate', result.data.email); | ||
}) | ||
.catch(err => { | ||
messageError.value = err.response.data.message; | ||
throw err; | ||
}); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<!-- MODIFICATION DE L'ADRESSE MAIL --> | ||
<v-container class="fill-height" fluid > | ||
<v-row align="center" justify="center"> | ||
<v-col md="7"> | ||
<email :email="user.email ? user.email : ''" :user-id="user.userNum" @validate="setEmailUser"></email> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
</template> | ||
|
||
<script setup> | ||
import Email from '@/components/Email.vue'; | ||
import { ref } from 'vue'; | ||
import router from '@/router'; | ||
const user = ref(JSON.parse(sessionStorage.getItem('user'))); | ||
function setEmailUser(email){ | ||
user.value.email = email; | ||
sessionStorage.setItem('user',JSON.stringify(user.value)); | ||
router.push('Accueil'); | ||
} | ||
</script> |