Skip to content

Commit

Permalink
move to other category
Browse files Browse the repository at this point in the history
  • Loading branch information
cannalee90 committed Oct 20, 2022
1 parent d57b0ce commit 673aa0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions webapp/src/components/createCategory/createCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Props = {
initialValue?: string
onClose: () => void
title: JSX.Element
onCreate?: () => Promise<void>
}

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

await mutator.createCategory(category)
await props.onCreate?.()
}

props.onClose()
Expand Down
17 changes: 16 additions & 1 deletion webapp/src/components/sidebar/sidebarBoardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(null)

const title = board.title || intl.formatMessage({id: 'Sidebar.untitled-board', defaultMessage: '(Untitled Board)'})
Expand Down Expand Up @@ -315,13 +327,16 @@ const SidebarBoardItem = (props: Props) => {
))}
{showCreateCategoryModal &&
<CreateCategory
onClose={() => setShowCreateCategoryModal(false)}
onClose={() => {
setShowCreateCategoryModal(false)
}}
title={(
<FormattedMessage
id='SidebarCategories.CategoryMenu.CreateNew'
defaultMessage='Create New Category'
/>
)}
onCreate={handleOnCreate}
/>}
</>
)
Expand Down

0 comments on commit 673aa0b

Please sign in to comment.