From 673aa0b84dd4a72ef6aa6ec876817e41f047aa96 Mon Sep 17 00:00:00 2001 From: "cannalee90@gmail.com" Date: Fri, 21 Oct 2022 00:34:50 +0900 Subject: [PATCH] move to other category --- .../createCategory/createCategory.tsx | 2 ++ .../src/components/sidebar/sidebarBoardItem.tsx | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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} />} )