From 7dad33b6e4bd837a416fed0726ee4e66f6157fed Mon Sep 17 00:00:00 2001 From: William Petit Date: Fri, 4 Sep 2020 12:28:38 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20r=C3=A9cup=C3=A9ration/fusion=20de?= =?UTF-8?q?s=20Workgroups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DecisionSupportFilePanel.tsx | 3 +- .../components/DashboardPage/ItemPanel.tsx | 12 ++--- .../WorkgroupPage/WorkgroupPage.tsx | 52 +++++++++++-------- client/src/gql/client.tsx | 1 - client/src/gql/mutations/dsf.tsx | 22 +++++++- client/src/gql/queries/dsf.tsx | 4 +- internal/model/workgroup_repository.go | 4 +- 7 files changed, 61 insertions(+), 37 deletions(-) diff --git a/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx b/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx index 1fa31e8..ba8929d 100644 --- a/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx +++ b/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx @@ -26,8 +26,7 @@ export function DecisionSupportFilePanel() { itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Closed }, ]; - - + return ( boolean } - - export interface ItemPanelProps { className?: string itemIconClassName?: string @@ -30,9 +28,12 @@ export const ItemPanel: FunctionComponent = (props) => { const { title, className, newItemUrl, itemKey, itemLabel, - itemIconClassName, itemUrl + itemIconClassName, itemUrl, } = props; + const items = props.items || []; + const tabs = props.tabs || []; + const [ state, setState ] = useState({ selectedTab: 0, filteredItems: [] }); const filterItemsForTab = (tab: TabDefinition, items: Item[]) => { @@ -42,7 +43,6 @@ export const ItemPanel: FunctionComponent = (props) => { const selectTab = (tabIndex: number) => { setState(state => { - const { tabs, items } = props; const newTab = Array.isArray(tabs) && tabs.length > 0 ? tabs[tabIndex] : null; return { ...state, @@ -61,7 +61,7 @@ export const ItemPanel: FunctionComponent = (props) => { filteredItems: filterItemsForTab(newTab, items), } }); - }, [props.items, props.tabs]); + }, [items, tabs]); const itemElements = state.filteredItems.map((item: Item, i: number) => { return ( @@ -74,8 +74,6 @@ export const ItemPanel: FunctionComponent = (props) => { ); }); - const tabs = props.tabs || []; - return (