import { useState } from "react"; import { faCertificate } from "@fortawesome/free-solid-svg-icons"; import { format } from "date-fns"; import { Badge, EmptyState, Pagination, Table, TableContainer, TableSkeleton, TBody, Td, Th, THead, Tr } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { useListWorkspaceSshCertificates } from "@app/hooks/api"; import { getSshCertStatusBadgeDetails } from "./SshCertificatesTable.utils"; const PER_PAGE_INIT = 25; export const SshCertificatesTable = () => { const { currentWorkspace } = useWorkspace(); const [page, setPage] = useState(1); const [perPage, setPerPage] = useState(PER_PAGE_INIT); const { data, isPending } = useListWorkspaceSshCertificates({ projectId: currentWorkspace?.id || "", offset: (page - 1) * perPage, limit: perPage }); return ( {isPending && } {!isPending && data?.certificates?.map((certificate) => { const { variant, label } = getSshCertStatusBadgeDetails(certificate.notAfter); return ( ); })}
Principals Status Not Before Not After
{certificate.principals.join(", ")} {label} {certificate.notBefore ? format(new Date(certificate.notBefore), "yyyy-MM-dd | HH:mm:ss") : "-"} {certificate.notAfter ? format(new Date(certificate.notAfter), "yyyy-MM-dd | HH:mm:ss") : "-"}
{!isPending && data?.totalCount !== undefined && data.totalCount >= PER_PAGE_INIT && ( setPage(newPage)} onChangePerPage={(newPerPage) => setPerPage(newPerPage)} /> )} {!isPending && !data?.certificates?.length && ( )}
); };