From 428a039e9f158b0da22f1337c9007ed92f317cd5 Mon Sep 17 00:00:00 2001 From: Kamil Marczak Date: Mon, 9 Dec 2024 20:55:34 +0100 Subject: [PATCH] fix: better comments --- .../plans/edit/[id]/_components/CreateNewPlanPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/plans/edit/[id]/_components/CreateNewPlanPage.tsx b/frontend/src/app/plans/edit/[id]/_components/CreateNewPlanPage.tsx index fd50c57..b4f733f 100644 --- a/frontend/src/app/plans/edit/[id]/_components/CreateNewPlanPage.tsx +++ b/frontend/src/app/plans/edit/[id]/_components/CreateNewPlanPage.tsx @@ -252,11 +252,19 @@ export function CreateNewPlanPage({ }) .sort((a, b) => a.name.localeCompare(b.name)); - // Aktualizacja list + // List update logic: + // Add unique registrations to the updatedRegistrations array + // r - current registration + // i - current index + // a - array of registrations updatedRegistrations = [...updatedRegistrations, registration].filter( (r, i, a) => a.findIndex((t) => t.id === r.id) === i, ); + // Add unique courses to the updatedCourses array + // c - current course + // i - current index + // a - array of courses updatedCourses = [...updatedCourses, ...extendedCourses].filter( (c, i, a) => a.findIndex((t) => t.id === c.id) === i, );