From 3051598ead66a799efd7de1e0c6ec4db90d5e07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Wed, 25 Sep 2024 15:48:38 +0200 Subject: [PATCH] =?UTF-8?q?debug=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arretes_restrictions.service.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arretes_restrictions/arretes_restrictions.service.ts b/src/arretes_restrictions/arretes_restrictions.service.ts index fbd2dcd..dabc4a5 100644 --- a/src/arretes_restrictions/arretes_restrictions.service.ts +++ b/src/arretes_restrictions/arretes_restrictions.service.ts @@ -99,12 +99,12 @@ export class ArretesRestrictionsService { 'crise': 4, }; return ars.map(ar => { - ar.niveauGraviteMax = ar.restrictions.length > 0 ? ar.restrictions.reduce((acc, restriction) => { - if (niveauGravitePriority[restriction.status] > niveauGravitePriority[acc.status]) { - return restriction; + ar.niveauGraviteMax = null; + ar.restrictions?.forEach(r => { + if (!ar.niveauGraviteMax || niveauGravitePriority[r.status] > niveauGravitePriority[ar.niveauGraviteMax]) { + ar.niveauGraviteMax = r.niveauGravite; } - return acc; - }).niveauGravite : null; + }); ar.types = ar.restrictions.map(r => r.zonesAlerteComputed.map(z => z.type)).flat(); ar.types = [...new Set(ar.types)].sort(); return ar;