From 25259cbad5979ab3dccbb30c87fac534f63fec32 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Tue, 2 Jul 2024 14:25:38 +0000 Subject: [PATCH] filter edit student forms modal forms by project --- .../students-tab/students-table.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rails/react-components/src/library/components/permission-forms-v2/students-tab/students-table.tsx b/rails/react-components/src/library/components/permission-forms-v2/students-tab/students-table.tsx index b1cc7ef47..a412261e8 100644 --- a/rails/react-components/src/library/components/permission-forms-v2/students-tab/students-table.tsx +++ b/rails/react-components/src/library/components/permission-forms-v2/students-tab/students-table.tsx @@ -151,6 +151,18 @@ export const StudentsTable = ({ classId, currentSelectedProject }: IProps) => { } }; + const getProjectForms = (allForms: IPermissionForm[], currentSelectedProject: CurrentSelectedProject ) => { + if (currentSelectedProject === "") { + return nonArchived(allForms); + } else { + // TODO: fix typing in CurrentSelectedProject and IPermissionForm.project_id that requires us to re-cast string + const project_id = parseInt(currentSelectedProject.toString()); + return allForms.filter(pf => pf.project_id === project_id); + } + }; + + const permissionFormsOfProject = getProjectForms(nonArchivedPermissionForms, currentSelectedProject); + return ( <> @@ -259,7 +271,7 @@ export const StudentsTable = ({ classId, currentSelectedProject }: IProps) => { setEditStudent(null)} onFormSave={handleSaveStudentPermissionsSuccess} classId={classId}