form action redirects user to tjhe appropriate year

This commit is contained in:
2024-01-17 15:47:55 +01:00
parent 119d64344f
commit 0eb11e7d02
18 changed files with 158 additions and 86 deletions

View File

@@ -1,12 +1,13 @@
import { addMonth } from '@/app/lib/actions/monthActions';
import { gotoHome } from '@/app/lib/actions/navigationActions';
import { parseYearMonth } from '@/app/lib/format';
import { revalidatePath } from 'next/cache';
import { redirect } from 'next/navigation';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
await addMonth(parseYearMonth(id));
const { year, month } = parseYearMonth(id);
await addMonth({ year, month });
revalidatePath('/');
redirect(`/`);
await gotoHome(`/?year=${year}`);
return null; // if we don't return anything, the client-side will not re-validate cache
}