Skip to content

Commit

Permalink
On ne peut pas insérer un référentiel qui est vide
Browse files Browse the repository at this point in the history
  • Loading branch information
NerOcrO committed May 14, 2024
1 parent 505d8f8 commit bc75568
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/repositories/referentielsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export async function modifierUnReferentielRepository(formData: FormData): Promi

if (fichierReferentiel.name === 'correspondanceTypeEquipement.csv') {
const correspondancesTypeEquipement = (await fichierReferentiel.text())
.split('\r\n').map((ligne): correspondanceTypeEquipementModeleModel => {
.split(/\r\n|\r|\n/)
.map((ligne): correspondanceTypeEquipementModeleModel => {
const splittedLigne = ligne.split(';')

return {
Expand Down Expand Up @@ -43,6 +44,8 @@ export async function modifierUnReferentielRepository(formData: FormData): Promi
async function enregistrerCorrespondancesTypeEquipementRepository(
correspondancesTypeEquipement: Array<correspondanceTypeEquipementModeleModel>
): Promise<void> {
if (correspondancesTypeEquipement.length === 0) return

await prisma.$transaction(async (prisma) => {
await supprimerCorrespondanceTypeEquipementRepository()

Expand Down

0 comments on commit bc75568

Please sign in to comment.