Skip to content

Commit

Permalink
Merge pull request #50 from dnum-mi/fix/repare-organisation-update
Browse files Browse the repository at this point in the history
Fix/repare organisation update
  • Loading branch information
Carolinedanslesnuages authored Aug 30, 2024
2 parents 75e7557 + ddb637f commit 1a2658d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/organisations/organisations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,27 @@ export class OrganisationsService {

async updateOneById(
username: string,
id: string,
id: string, // Cet 'id' vient du frontend
data: UpdateOrganisationDto,
): Promise<OrgOrganisationunit> {
// Étape 1 : Rechercher l'organisation par son id
const orgUnit = await this.prisma.orgOrganisationunit.findFirst({
where: { id: id }, // Recherche l'organisation avec id dans la table
select: { organisationunitid: true }, // Ne récupère que organisationunitid
});

if (!orgUnit) {
throw new Error('Organisation unit not found');
}

// Étape 2 : Utiliser organisationunitid pour la mise à jour
return this.prisma.orgOrganisationunit.update({
data: {
...data,
...{ updatedby: username },
updatedby: username,
},
where: {
organisationunitid: id,
organisationunitid: orgUnit.organisationunitid, // Utilise organisationunitid pour la mise à jour
},
});
}
Expand Down

0 comments on commit 1a2658d

Please sign in to comment.