import { faCopy, faEye, faSpinner, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format } from "date-fns"; import { createNotification } from "@app/components/notifications"; import { IconButton, Td, Tooltip, Tr } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { SecretSharingAccessType, TSharedSecret, useRevealSecretRequestValue } from "@app/hooks/api/secretSharing"; import { UsePopUpState } from "@app/hooks/usePopUp"; export const RequestedSecretsRow = ({ row, handlePopUpOpen }: { row: TSharedSecret; handlePopUpOpen: ( popUpName: keyof UsePopUpState<["deleteSecretRequestConfirmation", "revealSecretRequestValue"]>, data: unknown ) => void; }) => { const { mutateAsync: revealSecretValue, isPending } = useRevealSecretRequestValue(); let isExpired = false; if (row.expiresAt !== null && new Date(row.expiresAt) < new Date()) { isExpired = true; } return ( {row.name ? `${row.name}` : "-"} {isExpired && !row.encryptedSecret ? ( Expired ) : ( {row.encryptedSecret ? "Secret Provided" : "Pending Secret"} )} {row.accessType === SecretSharingAccessType.Anyone ? "Anyone" : "Organization Members"} {`${format(new Date(row.createdAt), "yyyy-MM-dd - HH:mm a")}`} {row.expiresAt ? format(new Date(row.expiresAt), "yyyy-MM-dd - HH:mm a") : "-"}
{ e.stopPropagation(); const secretRequest = await revealSecretValue({ id: row.id }); handlePopUpOpen("revealSecretRequestValue", { secretValue: secretRequest.secretValue, secretRequestName: secretRequest.name }); }} variant="plain" ariaLabel="reveal" > { e.stopPropagation(); navigator.clipboard.writeText( `${window.location.origin}/secret-request/secret/${row.id}` ); createNotification({ text: "Shared secret link copied to clipboard.", type: "success" }); }} variant="plain" ariaLabel="copy link" > { e.stopPropagation(); handlePopUpOpen("deleteSecretRequestConfirmation", { name: "delete", id: row.id }); }} variant="plain" ariaLabel="delete" >
); };