From 7578701087e95ef58a5d55fe139d9b928ccd9d04 Mon Sep 17 00:00:00 2001 From: Stef Winterswijk Date: Wed, 4 Dec 2024 12:51:23 +0100 Subject: [PATCH] Fix app from breaking if object type doesn't exist in UI --- src/components/Modules/ModuleItemList/ModuleItemList.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Modules/ModuleItemList/ModuleItemList.tsx b/src/components/Modules/ModuleItemList/ModuleItemList.tsx index 6577f228..3e2501cf 100644 --- a/src/components/Modules/ModuleItemList/ModuleItemList.tsx +++ b/src/components/Modules/ModuleItemList/ModuleItemList.tsx @@ -23,7 +23,8 @@ interface ModuleItemListProps { const ModuleItemList = ({ objects, ...rest }: ModuleItemListProps) => { const { user } = useAuth() - const { canEditModule, canPatchObjectInModule, canAddNewObjectToModule } = usePermissions() + const { canEditModule, canPatchObjectInModule, canAddNewObjectToModule } = + usePermissions() const { isLocked } = useModule() /** @@ -66,7 +67,9 @@ const ModuleItemList = ({ objects, ...rest }: ModuleItemListProps) => { title="Jouw onderdelen in deze module" noResultsText="Je hebt nog geen onderdelen in deze module" hasEditButton={canPatchObjectInModule && !isLocked} - hasViewButton={canPatchObjectInModule && !canAddNewObjectToModule} + hasViewButton={ + canPatchObjectInModule && !canAddNewObjectToModule + } {...rest} /> @@ -128,6 +131,8 @@ const ItemList = ({ ] const { slugOverview, plural } = model?.defaults || {} + if (!model) return null + return (