Skip to content

Commit

Permalink
♻️ Refactor actions menu (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejsdev authored Oct 29, 2024
1 parent 0bac7ed commit 041f0d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
40 changes: 10 additions & 30 deletions frontend/src/components/Common/ActionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useDisclosure,
} from "@chakra-ui/react"
import { BsThreeDotsVertical } from "react-icons/bs"
import { FaEdit, FaExchangeAlt } from "react-icons/fa"
import { FaExchangeAlt } from "react-icons/fa"

import { Trash } from "@/assets/icons.tsx"
import type { TeamPublic, UserPublic } from "@/client"
Expand All @@ -17,21 +17,12 @@ import RemoveUser from "./RemoveUser"
interface ActionsMenuProps {
userRole?: string
team?: TeamPublic
type: string
value: UserPublic | TeamPublic
disabled?: boolean
}

const ActionsMenu = ({
userRole,
team,
type,
value,
disabled,
}: ActionsMenuProps) => {
const ActionsMenu = ({ userRole, team, value, disabled }: ActionsMenuProps) => {
const changeRoleModal = useDisclosure()
const editUserModal = useDisclosure()
const deleteTeamModal = useDisclosure()
const removeUserModal = useDisclosure()

return (
Expand All @@ -44,29 +35,18 @@ const ActionsMenu = ({
variant="unstyled"
/>
<MenuList>
{type === "User" ? (
<MenuItem
onClick={changeRoleModal.onOpen}
icon={<FaExchangeAlt fontSize="16px" />}
>
Change Role
</MenuItem>
) : (
<MenuItem
onClick={editUserModal.onOpen}
icon={<FaEdit fontSize="16px" />}
>
Edit {type}
</MenuItem>
)}
<MenuItem
onClick={
type === "User" ? removeUserModal.onOpen : deleteTeamModal.onOpen
}
onClick={changeRoleModal.onOpen}
icon={<FaExchangeAlt fontSize="16px" />}
>
Change Role
</MenuItem>
<MenuItem
onClick={removeUserModal.onOpen}
icon={<Trash fontSize="16px" />}
color="error.base"
>
{type === "User" ? "Remove" : "Delete"} {type}
Remove User
</MenuItem>
</MenuList>
<ChangeRole
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Teams/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ function Team() {
<ActionsMenu
userRole={role}
team={team}
type="User"
value={user}
disabled={
currentUserRole === "member" ||
Expand Down

0 comments on commit 041f0d4

Please sign in to comment.