Skip to content

Commit 673aa0b

Browse files
committed
move to other category
1 parent d57b0ce commit 673aa0b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

webapp/src/components/createCategory/createCategory.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Props = {
2828
initialValue?: string
2929
onClose: () => void
3030
title: JSX.Element
31+
onCreate?: () => Promise<void>
3132
}
3233

3334
const CreateCategory = (props: Props): JSX.Element => {
@@ -71,6 +72,7 @@ const CreateCategory = (props: Props): JSX.Element => {
7172
} as Category
7273

7374
await mutator.createCategory(category)
75+
await props.onCreate?.()
7476
}
7577

7678
props.onClose()

webapp/src/components/sidebar/sidebarBoardItem.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ const SidebarBoardItem = (props: Props) => {
197197
}
198198
}
199199

200+
const handleOnCreate = async () => {
201+
const nextCategoriesList = await octoClient.getSidebarCategories(teamID)
202+
const toCategory = nextCategoriesList.
203+
find((category) => props.allCategories.every((prevCategory) => prevCategory.id !== category.id))
204+
205+
if (!toCategory) {
206+
return
207+
}
208+
209+
await mutator.moveBoardToCategory(teamID, currentBoardID, toCategory.id, props.categoryBoards.id)
210+
}
211+
200212
const boardItemRef = useRef<HTMLDivElement>(null)
201213

202214
const title = board.title || intl.formatMessage({id: 'Sidebar.untitled-board', defaultMessage: '(Untitled Board)'})
@@ -315,13 +327,16 @@ const SidebarBoardItem = (props: Props) => {
315327
))}
316328
{showCreateCategoryModal &&
317329
<CreateCategory
318-
onClose={() => setShowCreateCategoryModal(false)}
330+
onClose={() => {
331+
setShowCreateCategoryModal(false)
332+
}}
319333
title={(
320334
<FormattedMessage
321335
id='SidebarCategories.CategoryMenu.CreateNew'
322336
defaultMessage='Create New Category'
323337
/>
324338
)}
339+
onCreate={handleOnCreate}
325340
/>}
326341
</>
327342
)

0 commit comments

Comments
 (0)