From bddeeedd75350613a4e508b4ed0b03c1a99041d2 Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Tue, 8 Nov 2022 21:29:09 +0530 Subject: [PATCH] Added logic for system board category to show last (#4163) * Added logic for system board category to show last * NIT --- webapp/src/store/sidebar.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/webapp/src/store/sidebar.ts b/webapp/src/store/sidebar.ts index 29a845d1c..cbdc811f8 100644 --- a/webapp/src/store/sidebar.ts +++ b/webapp/src/store/sidebar.ts @@ -38,8 +38,14 @@ export const DefaultCategory: CategoryBoards = { export const fetchSidebarCategories = createAsyncThunk( 'sidebarCategories/fetch', async (teamID: string) => { - const categories = await client.getSidebarCategories(teamID) - return categories.sort((a, b) => a.name.localeCompare(b.name)) + // TODO All this logic should remove once LHS DND PR gets merged + const allCategories = await client.getSidebarCategories(teamID) + const boardSystemCategoies = allCategories.filter((category) => category.name === 'Boards' && category.type === 'system') + const categoriesWithoutSystemBoard = allCategories.filter((category) => category.name !== 'Boards' && category.type !== 'system') + const categories = categoriesWithoutSystemBoard + categories.sort((a, b) => a.name.localeCompare(b.name)) + categories.push(boardSystemCategoies[0]) + return categories }, ) @@ -74,8 +80,14 @@ const sidebarSlice = createSlice({ } }) - // sort categories alphabetically - state.categoryAttributes.sort((a, b) => a.name.localeCompare(b.name)) + // sort categories alphabetically only keeping board system category at the end + // TODO All this logic should remove once LHS DND PR gets merged + const boardsSystemCategories = state.categoryAttributes.filter((category) => category.name === 'Boards' && category.type === 'system') + const categoriesWithoutSystemBoard = state.categoryAttributes.filter((category) => category.name !== 'Baords' && category.type !== 'system') + const categories = categoriesWithoutSystemBoard + categories.sort((a, b) => a.name.localeCompare(b.name)) + categories.push(boardsSystemCategories[0]) + state.categoryAttributes = categories }, updateBoardCategories: (state, action: PayloadAction) => { action.payload.forEach((boardCategory) => {