From e3228cb3cd0bc75de702b9365ecadbd58c4a23cb Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Thu, 3 Oct 2024 11:35:15 +0200 Subject: [PATCH 1/2] fix date comparisons --- .../components/Settings/Submissions/EventsLog.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx index 870dc7864e..c01be1f12f 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx @@ -18,7 +18,7 @@ import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator"; import ErrorFallback from "components/Error/ErrorFallback"; -import { addDays, format, isBefore } from "date-fns"; +import { addDays, format, isAfter, isBefore } from "date-fns"; import { DAYS_UNTIL_EXPIRY } from "lib/pay"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useState } from "react"; @@ -105,12 +105,15 @@ const CollapsibleRow: React.FC = (submission) => { ]); // Only show an application download button if certain conditions are met - const submissionDataExpirationDate = addDays(new Date(), DAYS_UNTIL_EXPIRY); + const submissionDataExpirationDate = addDays( + new Date(submission.createdAt), + DAYS_UNTIL_EXPIRY, + ); const showDownloadButton = canUserEditTeam(teamSlug) && submission.status === "Success" && submissionEmail && - isBefore(new Date(submission.createdAt), submissionDataExpirationDate); + isBefore(new Date(), submissionDataExpirationDate); return ( From 2ae0bceeb33fa31108461e990f02c7460ad59eea Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Thu, 3 Oct 2024 11:38:57 +0200 Subject: [PATCH 2/2] remove unused import --- .../FlowEditor/components/Settings/Submissions/EventsLog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx index c01be1f12f..ff21f5325a 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/EventsLog.tsx @@ -18,7 +18,7 @@ import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator"; import ErrorFallback from "components/Error/ErrorFallback"; -import { addDays, format, isAfter, isBefore } from "date-fns"; +import { addDays, format, isBefore } from "date-fns"; import { DAYS_UNTIL_EXPIRY } from "lib/pay"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useState } from "react";