import { Helmet } from "react-helmet"; import { useTranslation } from "react-i18next"; import { useNavigate, useParams } from "@tanstack/react-router"; import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, PageHeader, Tooltip } from "@app/components/v2"; import { ROUTE_PATHS } from "@app/const/routes"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { useDeletePkiCollection, useGetPkiCollectionById } from "@app/hooks/api"; import { PkiItemType } from "@app/hooks/api/pkiCollections/constants"; import { ProjectType } from "@app/hooks/api/workspace/types"; import { usePopUp } from "@app/hooks/usePopUp"; import { PkiCollectionModal } from "../AlertingPage/components/PkiCollectionModal"; import { PkiCollectionDetailsSection, PkiCollectionItemsSection } from "./components"; export const PkiCollectionPage = () => { const navigate = useNavigate(); const params = useParams({ from: ROUTE_PATHS.CertManager.PkiCollectionDetailsByIDPage.id }); const collectionId = params.collectionId as string; const { currentWorkspace } = useWorkspace(); const projectId = currentWorkspace?.id || ""; const { data } = useGetPkiCollectionById(collectionId); const { mutateAsync: deletePkiCollection } = useDeletePkiCollection(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "pkiCollection", "deletePkiCollection" ] as const); const onDeletePkiCollectionSubmit = async (collectionIdToDelete: string) => { try { if (!projectId) return; await deletePkiCollection({ projectId, collectionId: collectionIdToDelete }); createNotification({ text: "Successfully deleted PKI collection", type: "success" }); handlePopUpClose("deletePkiCollection"); navigate({ to: `/projects/$projectId/${ProjectType.CertificateManager}/certificates` as const, params: { projectId } }); } catch { createNotification({ text: "Failed to delete PKI collection", type: "error" }); } }; return (