Skip to content

Commit b9fdca0

Browse files
committed
fix(api,admin,candidate): improved CandidateSection birthDepartment and country on both admin and candidate, improved api feature updateCandidate
1 parent 63e77de commit b9fdca0

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

packages/reva-admin-react/src/app/(aap)/candidacies/[candidacyId]/feasibility-aap/_components/DffSummary/_components/CandidateSection.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function CandidateSection({
4141
birthdate,
4242
birthCity,
4343
birthDepartment,
44+
country,
4445
nationality,
4546
phone,
4647
street,
@@ -54,6 +55,8 @@ export default function CandidateSection({
5455
const genderLabel = gender ? getGenderPrefix(gender) : "";
5556
const bornLabel = gender ? getGenderBornLabel(gender) : "";
5657

58+
const isFrance = country ? country?.label == "France" : false;
59+
5760
return (
5861
<div>
5962
<div className="flex">
@@ -71,10 +74,11 @@ export default function CandidateSection({
7174
{!!givenName && <span>{`${bornLabel} ${lastname},`}</span>}
7275
{birthdate && <span>le : {format(birthdate, "dd/MM/yyyy")}</span>}
7376
<span>
74-
à {birthCity ? `${birthCity},` : ""}{" "}
75-
{birthDepartment
76-
? `${birthDepartment?.label} (${birthDepartment?.code})`
77+
à {birthCity}
78+
{country && isFrance && birthDepartment
79+
? `${birthCity ? ", " : ""}${birthDepartment.label} (${birthDepartment.code})`
7780
: ""}
81+
{country && !isFrance && `${birthCity ? ", " : ""}${country.label}`}
7882
</span>
7983
</p>
8084
{nationality && <p>Nationalité {nationality}</p>}

packages/reva-admin-react/src/app/(aap)/candidacies/[candidacyId]/feasibility-aap/send-file-candidate/_components/sendFileCandidate.hook.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ const feasibilityWithDematerializedFeasibilityFileSendFileCandidateByCandidacyId
131131
label
132132
}
133133
}
134+
country {
135+
id
136+
label
137+
}
134138
nationality
135139
gender
136140
phone

packages/reva-admin-react/src/app/(aap)/candidacies/[candidacyId]/feasibility-aap/send-file-certification-authority/_components/sendFileCertificationAuthority.hook.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ const getActiveFeasibilitySendFileCertificationAuthorityByCandidacyId = graphql(
146146
label
147147
}
148148
}
149+
country {
150+
id
151+
label
152+
}
149153
nationality
150154
gender
151155
phone

packages/reva-admin-react/src/app/(certificateur)/candidacies/[candidacyId]/feasibility/_components/dematerialized-feasibility/dematerializedFeasibility.hook.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ const feasibilityGetActiveFeasibilityByCandidacyId = graphql(`
140140
label
141141
}
142142
}
143+
country {
144+
id
145+
label
146+
}
143147
nationality
144148
gender
145149
phone

packages/reva-api/modules/candidate/features/updateCandidate.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export const updateCandidate = async ({
129129

130130
return prismaClient.candidate.update({
131131
where: { id },
132-
data: candidateInput,
132+
data: {
133+
...candidateInput,
134+
birthDepartmentId:
135+
countrySelected.label == "France" ? birthDepartmentId : undefined,
136+
},
133137
});
134138
};

packages/reva-candidate/src/components/candidacy/candidacy.context.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const GET_CANDIDATE_WITH_CANDIDACY = graphql(`
2828
label
2929
}
3030
}
31+
country {
32+
id
33+
label
34+
}
3135
nationality
3236
gender
3337
phone

packages/reva-candidate/src/components/legacy/organisms/DffSummary/components/CandidateSection.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default function CandidateSection({
4242
birthdate,
4343
birthCity,
4444
birthDepartment,
45+
country,
4546
nationality,
4647
phone,
4748
street,
@@ -55,6 +56,8 @@ export default function CandidateSection({
5556
const genderLabel = gender ? getGenderPrefix(gender) : "";
5657
const bornLabel = gender ? getGenderBornLabel(gender) : "";
5758

59+
const isFrance = country ? country?.label == "France" : false;
60+
5861
return (
5962
<div>
6063
<div className="flex">
@@ -73,10 +76,11 @@ export default function CandidateSection({
7376
{!!givenName && <span>{`${bornLabel} ${lastname},`}</span>}
7477
{birthdate && <span> le {format(birthdate, "dd/MM/yyyy")} </span>}
7578
<span>
76-
à {birthCity ? `${birthCity},` : ""}{" "}
77-
{birthDepartment
78-
? `${birthDepartment?.label} (${birthDepartment?.code})`
79+
à {birthCity}
80+
{country && isFrance && birthDepartment
81+
? `${birthCity ? ", " : ""}${birthDepartment.label} (${birthDepartment.code})`
7982
: ""}
83+
{country && !isFrance && `${birthCity ? ", " : ""}${country.label}`}
8084
</span>
8185
</p>
8286
{nationality && <p>Nationalité {nationality}</p>}

0 commit comments

Comments
 (0)