diff --git a/ui/Puzzles.tsx b/ui/Puzzles.tsx index a3d1781..4c6a27f 100644 --- a/ui/Puzzles.tsx +++ b/ui/Puzzles.tsx @@ -42,6 +42,25 @@ export default function Puzzles({ token }: { token: string }) { ); } + function isBetweenDates(chapter: Chapter) { + if (!chapter.startDate || !chapter.endDate) { + return false; + } + + const startDate = new Date(chapter.startDate); + const endDate = new Date(chapter.endDate); + const now = new Date(); + + if (startDate < now && endDate > now) { + const minutes = 10 * 60 * 1000; + if (startDate.getTime() + minutes < now.getTime()) { + return true; + } + } + + return false; + } + const filteredData = useMemo(() => { if (filter && filterChapter) { if (filter === 'completed' || filter === 'no-completed') { @@ -63,16 +82,6 @@ export default function Puzzles({ token }: { token: string }) { return data?.find((chapter) => chapter.id === filterChapter)?.puzzles; }, [data, filter, filterChapter]); - useEffect(() => { - const { hash } = window.location; - if (hash) { - const element = document.querySelector(hash); - if (element) { - element.scrollIntoView({ behavior: 'smooth' }); - } - } - }, []); - return ( <> {(!isLoading && @@ -81,7 +90,7 @@ export default function Puzzles({ token }: { token: string }) {