import { Helmet } from "react-helmet"; 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, useProject } from "@app/context"; import { CaType, useDeleteCa, useGetCa } from "@app/hooks/api"; import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types"; import { usePopUp } from "@app/hooks/usePopUp"; import { CaInstallCertModal } from "../CertificateAuthoritiesPage/components/CaInstallCertModal"; import { CaModal } from "../CertificateAuthoritiesPage/components/CaModal"; import { CaCertificatesSection, CaCrlsSection, CaDetailsSection, CaRenewalModal } from "./components"; const Page = () => { const { currentProject } = useProject(); const navigate = useNavigate(); const params = useParams({ from: ROUTE_PATHS.CertManager.CertAuthDetailsByIDPage.id }); const { caName } = params as { caName: string }; const { data } = useGetCa({ caName, projectId: currentProject?.id || "", type: CaType.INTERNAL }) as { data: TInternalCertificateAuthority }; const projectId = currentProject?.id || ""; const { mutateAsync: deleteCa } = useDeleteCa(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "ca", "deleteCa", "installCaCert", "renewCa" ] as const); const onRemoveCaSubmit = async () => { try { if (!currentProject?.slug) return; await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL }); createNotification({ text: "Successfully deleted CA", type: "success" }); handlePopUpClose("deleteCa"); navigate({ to: "/projects/cert-management/$projectId/certificate-authorities", params: { projectId } }); } catch { createNotification({ text: "Failed to delete CA", type: "error" }); } }; return (