Skip to content

Commit

Permalink
feat(api): update candidacy status when dff has been sent to the cert…
Browse files Browse the repository at this point in the history
…ification authority
  • Loading branch information
ThomasDos committed Jul 9, 2024
1 parent 949ae08 commit e2174f9
Showing 1 changed file with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,38 @@ import { sendDFFNotificationToCertificationAuthorityEmail } from "../emails";
export const sendDFFToCertificationAuthority = async ({
dematerializedFeasibilityFileId,
certificationAuthorityId,
candidacyId,
}: {
dematerializedFeasibilityFileId: string;
certificationAuthorityId: string;
candidacyId: string;
}) => {
const now = new Date().toISOString();
await prismaClient.dematerializedFeasibilityFile.update({
where: { id: dematerializedFeasibilityFileId },
data: {
sentToCertificationAuthorityAt: now,
certificationAuthorityId,
},
});

await prismaClient.$transaction([
prismaClient.candidaciesStatus.updateMany({
where: {
candidacyId: candidacyId,
},
data: {
isActive: false,
},
}),
prismaClient.candidaciesStatus.create({
data: {
status: "DOSSIER_FAISABILITE_ENVOYE",
isActive: true,
candidacyId,
},
}),
prismaClient.dematerializedFeasibilityFile.update({
where: { id: dematerializedFeasibilityFileId },
data: {
sentToCertificationAuthorityAt: now,
certificationAuthorityId,
},
}),
]);

const dff = await prismaClient.dematerializedFeasibilityFile.findUnique({
where: { id: dematerializedFeasibilityFileId },
Expand Down

0 comments on commit e2174f9

Please sign in to comment.