From ccdd63120ca6bd8fbed511e37d6833973139abc8 Mon Sep 17 00:00:00 2001 From: Giang Vu Date: Thu, 10 Oct 2024 00:20:45 +1100 Subject: [PATCH] fix: filter units with no students --- frontend/src/scripts/handleInput.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/scripts/handleInput.ts b/frontend/src/scripts/handleInput.ts index f9faebd..81ada5f 100644 --- a/frontend/src/scripts/handleInput.ts +++ b/frontend/src/scripts/handleInput.ts @@ -132,7 +132,9 @@ export async function prefillUnitSpreadsheet(enrolmentExcel: File) { const units = unitsMaps.map(m => { const unitsData = Array.from(m.values()); - const transformed = unitsData.map(ud => { return { ...ud, enrolment: JSON.stringify(ud.enrolment) } }); + const transformed = unitsData + .filter((ud) => ud.enrolment.length > 0) + .map(ud => { return { ...ud, enrolment: JSON.stringify(ud.enrolment) } }); return transformed; }).flat();