Skip to content

Commit

Permalink
fix(api): validating a subscription request v2 now add all department…
Browse files Browse the repository at this point in the history
…s to the maisonMereOnDepartments association
  • Loading branch information
agarbe committed Jul 3, 2024
1 parent 486ef7a commit 60fb2de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/reva-api/modules/organism/organism.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface MaisonMereAAP {

export interface MaisonMereAAPOnDepartement {
departementId: string;
estSurplace: boolean;
estSurPlace: boolean;
estADistance: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { assignMaisonMereAAPToOrganism } from "../../organism/features/assignMai
import { createMaisonMereAAP } from "../../organism/features/createMaisonMereAAP";
import { deleteFile } from "../../shared/file";
import { logger } from "../../shared/logger";
import { getDepartments } from "../../referential/features/getDepartments";

export const validateSubscriptionRequest = async ({
subscriptionRequestId,
Expand Down Expand Up @@ -118,6 +119,8 @@ export const validateSubscriptionRequest = async ({
`[subscription] Successfuly created Account with organismId ${newOrganism.id}`,
);

const allDepartements = await getDepartments();

const newMaisonMereAAP = await createMaisonMereAAP({
maisonMereAAP: {
phone: subscriptionRequest.accountPhoneNumber ?? "",
Expand All @@ -135,7 +138,11 @@ export const validateSubscriptionRequest = async ({
managerLastname: subscriptionRequest.managerLastname,
},
ccnIds: [],
maisonMereAAPOnDepartements: [],
maisonMereAAPOnDepartements: allDepartements.map((d) => ({
departementId: d.id,
estADistance: true,
estSurPlace: true,
})),
});

await assignMaisonMereAAPToOrganism({
Expand Down

0 comments on commit 60fb2de

Please sign in to comment.