diff --git a/web-app/app/ui/HomePage.tsx b/web-app/app/ui/HomePage.tsx index fd7d4aa..2e46fcb 100644 --- a/web-app/app/ui/HomePage.tsx +++ b/web-app/app/ui/HomePage.tsx @@ -2,9 +2,9 @@ import { fetchAllLocations } from '@/app/lib/actions/locationActions'; import { fetchAvailableYears } from '@/app/lib/actions/monthActions'; import { getUserSettings } from '@/app/lib/actions/userSettingsActions'; import { BillingLocation, YearMonth } from '@/app/lib/db-types'; -import { FC, useEffect } from 'react'; +import { FC } from 'react'; import { MonthLocationList } from '@/app/ui/MonthLocationList'; -import { redirect } from 'next/navigation'; +import { ParamsYearInvalidMessage } from './ParamsYearInvalidMessage'; export interface HomePageProps { searchParams?: { @@ -13,24 +13,6 @@ export interface HomePageProps { }; } -const ParamsYearInvalidMessage:FC<{ firstAvailableYear?: number }> = ({ firstAvailableYear }) => { - - // Redirect to the first available year after showing the message - useEffect(() => { - if(firstAvailableYear) { - redirect(`/?year=${firstAvailableYear}`); - } else { - redirect(`/`); - } - }); - - return( - - The year specified in the URL is invalid ... redirecting - - ); -}; - export const HomePage:FC = async ({ searchParams }) => { /** years found in the DB sorted descending */ diff --git a/web-app/app/ui/ParamsYearInvalidMessage.tsx b/web-app/app/ui/ParamsYearInvalidMessage.tsx new file mode 100644 index 0000000..ea20a1c --- /dev/null +++ b/web-app/app/ui/ParamsYearInvalidMessage.tsx @@ -0,0 +1,21 @@ +"use client"; +import { FC, useEffect } from 'react'; +import { redirect } from 'next/navigation'; + +export const ParamsYearInvalidMessage:FC<{ firstAvailableYear?: number }> = ({ firstAvailableYear }) => { + + // Redirect to the first available year after showing the message + useEffect(() => { + if(firstAvailableYear) { + redirect(`/?year=${firstAvailableYear}`); + } else { + redirect(`/`); + } + }); + + return( + + The year specified in the URL is invalid ... redirecting + + ); +}; \ No newline at end of file diff --git a/web-app/package-lock.json b/web-app/package-lock.json index e3eb556..33a5a29 100644 --- a/web-app/package-lock.json +++ b/web-app/package-lock.json @@ -1,11 +1,11 @@ { "name": "evidencija-rezija", - "version": "2.20.0", + "version": "2.20.3", "lockfileVersion": 3, "requires": true, "packages": { "": { - "version": "2.20.0", + "version": "2.20.3", "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", diff --git a/web-app/package.json b/web-app/package.json index 5a7330b..7d05a2e 100644 --- a/web-app/package.json +++ b/web-app/package.json @@ -58,5 +58,5 @@ "engines": { "node": ">=18.17.0" }, - "version": "2.20.0" + "version": "2.20.3" }
The year specified in the URL is invalid ... redirecting