/* eslint-disable @typescript-eslint/no-unused-vars */ import { useRouter } from "next/router"; import { faChevronLeft, faEllipsis } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { withProjectPermission } from "@app/hoc"; import { useDeleteProjectRole,useGetProjectRoleBySlug } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { RoleDetailsSection, RoleModal, RolePermissionsSection } from "./components"; import { TabSections } from '../Types'; export const RolePage = withProjectPermission( () => { const router = useRouter(); const roleSlug = router.query.roleSlug as string; const { currentWorkspace } = useWorkspace(); const projectId = currentWorkspace?.id || ""; const { data } = useGetProjectRoleBySlug(currentWorkspace?.slug ?? "", roleSlug as string); const { mutateAsync: deleteProjectRole } = useDeleteProjectRole(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "role", "deleteRole" ] as const); const onDeleteRoleSubmit = async () => { try { if (!currentWorkspace?.slug || !data?.id) return; await deleteProjectRole({ projectSlug: currentWorkspace.slug, id: data.id }); createNotification({ text: "Successfully deleted project role", type: "success" }); handlePopUpClose("deleteRole"); router.push(`/project/${projectId}/members?selectedTab=${TabSections.Roles}`); } catch (err) { console.error(err); const error = err as any; const text = error?.response?.data?.message ?? "Failed to delete project role"; createNotification({ text, type: "error" }); } }; const isCustomRole = !["admin", "member", "viewer", "no-access"].includes(data?.slug ?? ""); return (
{data.name}
{isCustomRole && (