form action redirects user to tjhe appropriate year
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user