From 7593e6378a0f11108bf9b121e6ad58148652d98c Mon Sep 17 00:00:00 2001 From: poulch Date: Wed, 25 Jan 2023 08:34:01 +0100 Subject: [PATCH] Fix crash staff page when access property of undefined (#3038) --- src/staff/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/staff/utils.ts b/src/staff/utils.ts index 3a635af8b..70b65362e 100644 --- a/src/staff/utils.ts +++ b/src/staff/utils.ts @@ -7,9 +7,13 @@ import { StaffDetailsFormData } from "./components/StaffDetailsPage"; * Return lists of groups which have to be added and removed from user. */ export const groupsDiff = ( - user: StaffMemberDetailsFragment, + user: StaffMemberDetailsFragment | undefined, formData: StaffDetailsFormData, ) => { + if (!user) { + return {}; + } + const newGroups = formData.permissionGroups; const oldGroups = user.permissionGroups.map(u => u.id);