diff --git a/webapp/src/components/createCategory/createCategory.tsx b/webapp/src/components/createCategory/createCategory.tsx index f33feab3435..7d1301056cf 100644 --- a/webapp/src/components/createCategory/createCategory.tsx +++ b/webapp/src/components/createCategory/createCategory.tsx @@ -28,6 +28,7 @@ type Props = { initialValue?: string onClose: () => void title: JSX.Element + onCreate?: () => Promise } const CreateCategory = (props: Props): JSX.Element => { @@ -71,6 +72,7 @@ const CreateCategory = (props: Props): JSX.Element => { } as Category await mutator.createCategory(category) + await props.onCreate?.() } props.onClose() diff --git a/webapp/src/components/sidebar/sidebarBoardItem.tsx b/webapp/src/components/sidebar/sidebarBoardItem.tsx index 27dc31344f8..07c9153eb41 100644 --- a/webapp/src/components/sidebar/sidebarBoardItem.tsx +++ b/webapp/src/components/sidebar/sidebarBoardItem.tsx @@ -197,6 +197,18 @@ const SidebarBoardItem = (props: Props) => { } } + const handleOnCreate = async () => { + const nextCategoriesList = await octoClient.getSidebarCategories(teamID) + const toCategory = nextCategoriesList. + find((category) => props.allCategories.every((prevCategory) => prevCategory.id !== category.id)) + + if (!toCategory) { + return + } + + await mutator.moveBoardToCategory(teamID, currentBoardID, toCategory.id, props.categoryBoards.id) + } + const boardItemRef = useRef(null) const title = board.title || intl.formatMessage({id: 'Sidebar.untitled-board', defaultMessage: '(Untitled Board)'}) @@ -315,13 +327,16 @@ const SidebarBoardItem = (props: Props) => { ))} {showCreateCategoryModal && setShowCreateCategoryModal(false)} + onClose={() => { + setShowCreateCategoryModal(false) + }} title={( )} + onCreate={handleOnCreate} />} )