import React from "react"; // ui import { PrimaryButton } from "components/ui"; // icons // helpers import { renderShortDateWithYearFormat } from "helpers/date-time.helper"; // types import { IExportData } from "types"; type Props = { service: IExportData; refreshing: boolean; }; export const SingleExport: React.FC = ({ service, refreshing }) => { const provider = service.provider; const [isLoading, setIsLoading] = React.useState(false); const checkExpiry = (inputDateString: string) => { const currentDate = new Date(); const expiryDate = new Date(inputDateString); expiryDate.setDate(expiryDate.getDate() + 7); return expiryDate > currentDate; }; return (

Export to{" "} {provider === "csv" ? "CSV" : provider === "xlsx" ? "Excel" : provider === "json" ? "JSON" : ""} {" "} {refreshing ? "Refreshing..." : service.status}

{renderShortDateWithYearFormat(service.created_at)}| Exported by {service?.initiated_by_detail?.display_name}
{checkExpiry(service.created_at) ? ( <> {service.status == "completed" && (
{isLoading ? "Downloading..." : "Download"}
)} ) : (
Expired
)}
); };