1
1
import { logCandidacyAuditEvent } from "@/modules/candidacy-log/features/logCandidacyAuditEvent" ;
2
+ import { getBackofficeUrl } from "@/modules/shared/email" ;
2
3
import { prismaClient } from "@/prisma/client" ;
3
4
5
+ import { sendCandidacyDropOutCanceledEmailToAap } from "../emails/sendCandidacyDropOutCanceledEmailToAap" ;
4
6
import { sendCandidacyDropOutConfirmedEmailToAap } from "../emails/sendCandidacyDropOutConfirmedEmailToAap" ;
5
7
import { sendCandidacyDropOutConfirmedEmailToCandidate } from "../emails/sendCandidacyDropOutConfirmedEmailToCandidate" ;
6
8
@@ -44,6 +46,17 @@ export const updateCandidateCandidacyDropoutDecision = async ({
44
46
"La décision d'abandon a déjà été confirmée automatiquement" ,
45
47
) ;
46
48
}
49
+ const aapEmail =
50
+ dropOut . candidacy ?. organism ?. emailContact ||
51
+ dropOut . candidacy ?. organism ?. contactAdministrativeEmail ;
52
+
53
+ const aapLabel =
54
+ dropOut . candidacy . organism ?. nomPublic || dropOut . candidacy . organism ?. label ;
55
+
56
+ const candidateFullName =
57
+ dropOut . candidacy . candidate ?. firstname +
58
+ " " +
59
+ dropOut . candidacy . candidate ?. lastname ;
47
60
48
61
if ( dropOutConfirmed ) {
49
62
const candidacy = await prismaClient . candidacy . update ( {
@@ -58,19 +71,6 @@ export const updateCandidateCandidacyDropoutDecision = async ({
58
71
...userInfo ,
59
72
} ) ;
60
73
61
- const aapEmail =
62
- dropOut . candidacy ?. organism ?. emailContact ||
63
- dropOut . candidacy ?. organism ?. contactAdministrativeEmail ;
64
-
65
- const aapLabel =
66
- dropOut . candidacy . organism ?. nomPublic ||
67
- dropOut . candidacy . organism ?. label ;
68
-
69
- const candidateFullName =
70
- dropOut . candidacy . candidate ?. firstname +
71
- " " +
72
- dropOut . candidacy . candidate ?. lastname ;
73
-
74
74
if ( aapEmail && aapLabel ) {
75
75
await sendCandidacyDropOutConfirmedEmailToAap ( {
76
76
aapEmail,
@@ -100,6 +100,19 @@ export const updateCandidateCandidacyDropoutDecision = async ({
100
100
eventType : "CANDIDACY_DROPOUT_CANCELED_BY_CANDIDATE" ,
101
101
...userInfo ,
102
102
} ) ;
103
+
104
+ const candidacyUrl = getBackofficeUrl ( {
105
+ path : `/candidacies/${ candidacyId } /summary` ,
106
+ } ) ;
107
+ if ( aapEmail ) {
108
+ await sendCandidacyDropOutCanceledEmailToAap ( {
109
+ aapEmail,
110
+ aapLabel : aapLabel || "" ,
111
+ candidateFullName,
112
+ candidacyUrl,
113
+ } ) ;
114
+ }
115
+
103
116
return candidacy ;
104
117
}
105
118
} ;
0 commit comments