Skip to content

Commit

Permalink
fix(api): fix department not updated after saving zip code for the fi…
Browse files Browse the repository at this point in the history
…rst time
  • Loading branch information
cedricss committed Dec 16, 2024
1 parent 8ee4d13 commit 5d8ad09
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ export const updateCandidate = async ({
throw new Error(`Le pays n'existe pas`);
}

const isDifferentZipCode =
candidateToUpdate.zip &&
candidateToUpdate.zip !== candidateInput.zip &&
candidateToUpdate.zip?.match(/^(\d{5}|)$/);
const isNewZip =
candidateToUpdate.zip === null ||
candidateToUpdate.zip !== candidateInput.zip;

if (isDifferentZipCode) {
if (isNewZip && candidateToUpdate.zip?.match(/^(\d{5}|)$/)) {
const departmentCode = candidateInput.zip?.slice(0, 2);

const department = await prismaClient.department.findUnique({
Expand Down

0 comments on commit 5d8ad09

Please sign in to comment.