diff --git a/packages/~/moderations/ui/src/Actions/responses/__snapshots__/user_with_existing_pc_account.test.tsx.snap b/packages/~/moderations/ui/src/Actions/responses/__snapshots__/user_with_existing_pc_account.test.tsx.snap
index 1c8b025f..4fdd84cc 100644
--- a/packages/~/moderations/ui/src/Actions/responses/__snapshots__/user_with_existing_pc_account.test.tsx.snap
+++ b/packages/~/moderations/ui/src/Actions/responses/__snapshots__/user_with_existing_pc_account.test.tsx.snap
@@ -1,11 +1,48 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP
-exports[`returns user with existing pc account 1`] = `
+exports[`with one email found 1`] = `
"Bonjour,
Nous avons bien reçu votre demande de rattachement à l'organisation « 🦄 » sur ProConnect (anciennement : AgentConnect, MonComptePro).
-Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « 💌 ».
+Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « 🦄@unicorn.xyz ».
+
+Merci de bien vouloir vous connecter avec le compte déjà existant.
+
+Votre adresse e-mail associée à un nom de domaine gratuit tel que « 🧨 » ne sera pas autorisée.
+
+Bien cordialement,
+L’équipe ProConnect.
+"
+`;
+
+exports[`with three emails found 1`] = `
+"Bonjour,
+
+Nous avons bien reçu votre demande de rattachement à l'organisation « 🦄 » sur ProConnect (anciennement : AgentConnect, MonComptePro).
+
+Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle :
+
+- 🦄@unicorn.xyz
+- 🐷@unicorn.xyz
+- 🧧@unicorn.xyz
+
+Merci de bien vouloir vous connecter avec le compte déjà existant.
+
+Votre adresse e-mail associée à un nom de domaine gratuit tel que « 🧨 » ne sera pas autorisée.
+
+Bien cordialement,
+L’équipe ProConnect.
+"
+`;
+
+exports[`with no emails found 1`] = `
+"Bonjour,
+
+Nous avons bien reçu votre demande de rattachement à l'organisation « 🦄 » sur ProConnect (anciennement : AgentConnect, MonComptePro).
+
+Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « ???? ».
+
Merci de bien vouloir vous connecter avec le compte déjà existant.
Votre adresse e-mail associée à un nom de domaine gratuit tel que « 🧨 » ne sera pas autorisée.
diff --git a/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.test.tsx b/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.test.tsx
index 7d734952..639f556c 100644
--- a/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.test.tsx
+++ b/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.test.tsx
@@ -1,13 +1,65 @@
//
import { render_md } from "@~/app.ui/testing";
+import type { SuggestSameUserEmailsHandler } from "@~/users.lib/usecase/SuggestSameUserEmails";
import { expect, test } from "bun:test";
import { context, type Values } from "../context";
import user_with_existing_pc_account from "./user_with_existing_pc_account";
//
-test("returns user with existing pc account", async () => {
+test("with one email found", async () => {
+ const query_suggest_same_user_emails: SuggestSameUserEmailsHandler =
+ async () => ["🦄@unicorn.xyz"];
+
+ expect(
+ await render_md(
+
+
+ ,
+ ),
+ ).toMatchSnapshot();
+});
+
+test("with three emails found", async () => {
+ const query_suggest_same_user_emails: SuggestSameUserEmailsHandler =
+ async () => ["🦄@unicorn.xyz", "🐷@unicorn.xyz", "🧧@unicorn.xyz"];
+
+ expect(
+ await render_md(
+
+
+ ,
+ ),
+ ).toMatchSnapshot();
+});
+
+test("with no emails found", async () => {
+ const query_suggest_same_user_emails: SuggestSameUserEmailsHandler =
+ async () => [];
+
expect(
await render_md(
{
organization: { cached_libelle: "🦄" },
user: { email: "💌" },
},
+ query_suggest_same_user_emails,
} as Values
}
>
diff --git a/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.tsx b/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.tsx
index dd44f29c..ed26c1ee 100644
--- a/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.tsx
+++ b/packages/~/moderations/ui/src/Actions/responses/user_with_existing_pc_account.tsx
@@ -6,22 +6,30 @@ import { context } from "../context";
export const label = "Utilisateur possédant déjà un compte ProConnect";
-export default function template() {
+export default async function template() {
const {
domain,
moderation: {
- organization: { cached_libelle: organization_name },
- user: { email },
+ organization: { cached_libelle: organization_name, id: organization_id },
+ user: { email, family_name },
},
+ query_suggest_same_user_emails,
} = useContext(context);
+ const members_email = await query_suggest_same_user_emails({
+ family_name: family_name ?? "",
+ organization_id: organization_id,
+ });
+
+ const possible_emails = list_possible_emails(members_email);
return dedent`
Bonjour,
Nous avons bien reçu votre demande de rattachement à l'organisation « ${organization_name} » sur ProConnect (anciennement : AgentConnect, MonComptePro).
- Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « ${email} ».
+ ${possible_emails}
+
Merci de bien vouloir vous connecter avec le compte déjà existant.
Votre adresse e-mail associée à un nom de domaine gratuit tel que « ${domain} » ne sera pas autorisée.
@@ -30,3 +38,22 @@ export default function template() {
L’équipe ProConnect.
`;
}
+
+function list_possible_emails(emails: string[]) {
+ if (emails.length === 0) {
+ return dedent`
+ Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « ???? ».
+ `;
+ }
+
+ if (emails.length === 1) {
+ return dedent`
+ Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle : « ${emails[0]} ».
+ `;
+ }
+
+ return dedent`
+ Vous possédez déjà un compte ProConnect associé à l’adresse e-mail professionnelle :
+ - ${emails.join("\n- ")}
+ `;
+}