From 207f95fcda220cafc2d33fa069478c366559404e Mon Sep 17 00:00:00 2001 From: Rajat-Dabade Date: Fri, 19 Aug 2022 11:18:58 +0530 Subject: [PATCH] Update acrding review changes --- webapp/src/components/kanban/kanban.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/webapp/src/components/kanban/kanban.tsx b/webapp/src/components/kanban/kanban.tsx index eeb99664d..c295ef29c 100644 --- a/webapp/src/components/kanban/kanban.tsx +++ b/webapp/src/components/kanban/kanban.tsx @@ -58,15 +58,13 @@ const Kanban = (props: Props) => { const currentView = useAppSelector(getCurrentView) const cardTemplates: Card[] = useAppSelector(getCurrentBoardTemplates) const {board, activeView, cards, groupByProperty, visibleGroups, hiddenGroups, hiddenCardsCount} = props - const [defaultTemplateID, setDefaultTemplateID] = useState('') + const [defaultTemplateID, setDefaultTemplateID] = useState() useEffect(() => { - if(currentView.fields && currentView.fields.defaultTemplateId) { - cardTemplates.forEach((cardTemplate) => { - if(cardTemplate.id === currentView.fields.defaultTemplateId) { - setDefaultTemplateID(currentView.fields.defaultTemplateId) - } - }) + if(currentView && currentView.fields && currentView.fields.defaultTemplateId) { + if(cardTemplates.find(ct => ct.id === currentView.fields.defaultTemplateId)) { + setDefaultTemplateID(currentView.fields.defaultTemplateId) + } } }, [currentView]) @@ -310,7 +308,7 @@ const Kanban = (props: Props) => {