Skip to content

Commit 3f6d3a7

Browse files
committed
feat: add confirmation dialog before sending invitation email in sendInit function
1 parent d0bbbf1 commit 3f6d3a7

File tree

1 file changed

+61
-24
lines changed

1 file changed

+61
-24
lines changed

apps/web/src/components/identityForm/actions.vue

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ div
3838
q-tooltip.text-body2(slot="trigger") Obliger l'utilisateur à changer son mot de passe
3939
q-btn(@click="resetPasswordModal = true" color="red-8" icon="mdi-account-key" :disabled="props.identity.state != IdentityState.SYNCED" padding='5px 10px' dense)
4040
q-tooltip.text-body2(slot="trigger") Définir le mot de passe
41-
q-btn(@click="sendInit" color="primary" icon="mdi-email-arrow-right" :disabled="props.identity.state != IdentityState.SYNCED" padding='5px 10px' dense)
41+
q-btn(@click="sendInit()" color="primary" icon="mdi-email-arrow-right" :disabled="props.identity.state != IdentityState.SYNCED" padding='5px 10px' dense)
4242
q-tooltip.text-body2(slot="trigger") Envoyer le mail d'invitation
4343

4444
q-separator(size='3px' vertical)
@@ -413,30 +413,67 @@ async function sync() {
413413
}
414414
415415
async function sendInit() {
416-
//envoi le mail
417-
418-
const {
419-
data: result,
420-
pending,
421-
error,
422-
refresh,
423-
} = await useHttp(`/management/passwd/init`, {
424-
method: 'POST',
425-
body: { uid: props.identity.inetOrgPerson.uid },
426-
})
427-
if (error.value) {
428-
handleError({
429-
error: error.value,
430-
message: "Erreur lors de l'envoi du mail",
431-
})
432-
} else {
433-
$q.notify({
434-
message: 'Le mail a été envoyé',
416+
$q.dialog({
417+
title: 'Confirmation',
418+
message: `Voulez-vous envoyer le mail d'invitation à <${props.identity.inetOrgPerson.uid}> ?`,
419+
persistent: true,
420+
ok: {
421+
push: true,
435422
color: 'positive',
436-
position: 'top-right',
437-
icon: 'mdi-check-circle-outline',
438-
})
439-
}
423+
label: 'Envoyer',
424+
},
425+
cancel: {
426+
push: true,
427+
color: 'negative',
428+
label: 'Annuler',
429+
},
430+
}).onOk(async () => {
431+
const requestOptions = { method: 'POST', body: JSON.stringify({ uid: props.identity.inetOrgPerson.uid }) }
432+
try {
433+
const data = await $http.post('/management/passwd/init', requestOptions)
434+
$q.notify({
435+
message: `Le mail d'invitation a été envoyé à <${props.identity.inetOrgPerson.uid}> : `,
436+
color: 'positive',
437+
position: 'top-right',
438+
icon: 'mdi-check-circle-outline',
439+
})
440+
props?.refreshTarget(props.identity)
441+
} catch (error) {
442+
$q.notify({
443+
message: "Impossible d'envoyer le mail d'invitation : " + error.response._data.message,
444+
color: 'negative',
445+
position: 'top-right',
446+
icon: 'mdi-alert-circle-outline',
447+
})
448+
}
449+
})
450+
//envoi le mail
451+
// console.log('send init', props.identity.inetOrgPerson.uid)
452+
// const requestOptions = { method: 'POST', body: JSON.stringify({ uid: props.identity.inetOrgPerson.uid }) }
453+
// const {
454+
// data: result,
455+
// pending,
456+
// error,
457+
// refresh,
458+
// } = await useHttp(`/management/passwd/init`, {
459+
// method: 'POST',
460+
// cache: 'no-cache',
461+
// body: JSON.stringify({ uid: props.identity.inetOrgPerson.uid }),
462+
// })
463+
// props?.refreshTarget(props.identity)
464+
// if (error.value) {
465+
// handleError({
466+
// error: error.value,
467+
// message: "Erreur lors de l'envoi du mail",
468+
// })
469+
// } else {
470+
// $q.notify({
471+
// message: 'Le mail a été envoyé',
472+
// color: 'positive',
473+
// position: 'top-right',
474+
// icon: 'mdi-check-circle-outline',
475+
// })
476+
// }
440477
}
441478
442479
function back() {

0 commit comments

Comments
 (0)