Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meilleure gestion d'erreur dans les numéros de téléphone #4643

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/controllers/followups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ export async function persist(req: Request, res: Response) {
return createSimulationRecapUrl(req, res)
}
} catch (error: any) {
Sentry.captureException(error)
if (error.name === "ValidationError") {
if (!error.message || !error.message?.includes("wrongPhoneNumber")) {
Sentry.captureException(error)
}
return res.status(403).send(error.message)
} else {
Sentry.captureException(error)
return res.status(500).send(`Error while persisting followup`)
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/modals/errors-email-and-sms-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const recapEmailState = computed(() => store.recapEmailState)
<div class="fr-pb-3w">
<div v-if="recapPhoneState != 'waiting' && recapEmailState != 'waiting'">
<div
v-if="recapPhoneState === 'error' || recapEmailState === 'error'"
v-if="
recapPhoneState === 'error' ||
recapEmailState === 'error' ||
recapPhoneState === 'wrongPhoneNumber'
"
class="fr-alert fr-alert--error"
>
<p>
Expand Down
23 changes: 17 additions & 6 deletions src/components/recap-email-and-sms-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ const sendRecap = async (surveyOptin) => {
)
}
} catch (error) {
console.error(error)
Sentry.captureException(error)
if (!error?.response?.data?.includes("Invalid")) {
console.error(error)
Sentry.captureException(error)
}
}
}

Expand Down Expand Up @@ -142,10 +144,15 @@ const sendRecapByEmailAndSms = async (surveyOptin) => {
store.setModalState(undefined)
await postFollowup(surveyOptin, emailValue.value, phoneValue.value)
} catch (error) {
Sentry.captureException(error)
store.setFormRecapState("error")
if (error?.response?.data?.includes("Numéro de téléphone invalide")) {
store.setFormRecapState("wrongPhoneNumber")
} else {
Sentry.captureException(error)
store.setFormRecapState("error")
}
throw error
}

store.setFormRecapState("ok")
phoneValue.value = undefined
emailValue.value = undefined
Expand All @@ -166,6 +173,7 @@ const sendRecapBySms = async (surveyOptin) => {
store.setFormRecapPhoneState("error")
throw error
}

store.setFormRecapPhoneState("ok")
phoneValue.value = undefined
}
Expand Down Expand Up @@ -207,8 +215,7 @@ const ctaText = ref(computeCtaText())
<div class="fr-modal__content">
<p>
Si vous le souhaitez nous pouvons vous recontacter à deux reprises pour
faire le point sur les démarches que vous avez faites et les blocages que
vous avez rencontrés.
faire le point sur vos démarches et sur les blocages rencontrés.
</p>
<form class="fr-form fr-my-2w" @submit.prevent="sendRecap(true)">
<div class="fr-form-group">
Expand Down Expand Up @@ -239,6 +246,10 @@ const ctaText = ref(computeCtaText())
>Une adresse email valide doit être indiquée.
</WarningMessage>
</form>
<p
>Vous pouvez saisir uniquement l'adresse e-mail pour recevoir le
récapitulatif.</p
>
<form
v-if="showSms"
class="fr-form fr-my-2w"
Expand Down
Loading