From 266be36183b505cc383c509c57ebc639f1860180 Mon Sep 17 00:00:00 2001 From: Foysal Ahamed Date: Mon, 12 Feb 2024 14:54:50 +0100 Subject: [PATCH] :bug: Set max time for event filter to next day to avoid timezone issues (#27) --- components/mod-event/EventList.tsx | 3 ++- components/mod-event/useModEventList.tsx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/mod-event/EventList.tsx b/components/mod-event/EventList.tsx index 3bbef3ab..00854ef3 100644 --- a/components/mod-event/EventList.tsx +++ b/components/mod-event/EventList.tsx @@ -12,6 +12,7 @@ import { MOD_EVENTS, MOD_EVENT_TITLES } from './constants' import { ArchiveBoxXMarkIcon, ChevronDownIcon } from '@heroicons/react/20/solid' import { getSubjectTitle } from './helpers/subject' import { useState } from 'react' +import { addDays } from 'date-fns' import { Checkbox, FormLabel, Input } from '@/common/forms' import { ActionButton } from '@/common/buttons' import { FunnelIcon as FunnelEmptyIcon } from '@heroicons/react/24/outline' @@ -380,7 +381,7 @@ const EventFilterPanel = ({ } autoComplete="off" min={FIRST_EVENT_TIMESTAMP} - max={formatDateForInput(new Date())} + max={formatDateForInput(addDays(new Date(), 1))} /> diff --git a/components/mod-event/useModEventList.tsx b/components/mod-event/useModEventList.tsx index 92f9f36d..04562caa 100644 --- a/components/mod-event/useModEventList.tsx +++ b/components/mod-event/useModEventList.tsx @@ -4,7 +4,7 @@ import { useContext, useEffect, useReducer, useState } from 'react' import { AuthContext } from '@/shell/AuthContext' import { ComAtprotoAdminQueryModerationEvents } from '@atproto/api' import { MOD_EVENT_TITLES } from './constants' -import { endOfDay } from 'date-fns' +import { addDays } from 'date-fns' export type ModEventListQueryOptions = { queryOptions?: { @@ -32,7 +32,7 @@ const initialListState = { createdBy: undefined, subject: undefined, oldestFirst: false, - createdBefore: formatDateForInput(endOfDay(new Date())), + createdBefore: formatDateForInput(addDays(new Date(), 1)), createdAfter: FIRST_EVENT_TIMESTAMP, reportTypes: [], addedLabels: [], @@ -243,4 +243,4 @@ async function getModerationEvents( { headers: client.adminHeaders() }, ) return data -} \ No newline at end of file +}