BugFix: HomePage did not parse URL correctly

This commit is contained in:
2024-02-08 14:04:48 +01:00
parent 0bb4c12061
commit e2f7b21a5e

View File

@@ -5,6 +5,7 @@ import { FC, useEffect, useState } from 'react';
import { MonthLocationList } from '@/app/ui/MonthLocationList';
import { WithId } from 'mongodb';
import { MonthCardSkeleton } from './MonthCardSkeleton';
import { useSearchParams } from 'next/navigation';
export interface HomePageProps {
}
@@ -23,6 +24,8 @@ const fetchAvailableYears = async () => {
export const HomePage:FC<HomePageProps> = () => {
const searchParams = useSearchParams();
const [ homePageStatus, setHomePageStatus ] = useState<{
status: "loading" | "loaded" | "error",
availableYears: number[],
@@ -36,7 +39,7 @@ export const HomePage:FC<HomePageProps> = () => {
const {availableYears, locations, status, error} = homePageStatus;
const year = new URLSearchParams(window.location.search).get('year');
const year = searchParams.get('year');
const currentYear = year ? parseInt(year, 10) : new Date().getFullYear();
useEffect(() => {