form action redirects user to tjhe appropriate year
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { deleteBillById } from '@/app/lib/actions/billActions';
|
||||
import { deleteLocationById } from '@/app/lib/actions/locationActions';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { notFound, redirect } from 'next/navigation';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { fetchLocationById } from '@/app/lib/actions/locationActions';
|
||||
import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm';
|
||||
|
||||
export default async function Page({ params:{ id } }: { params: { id:string } }) {
|
||||
const locationID = id;
|
||||
|
||||
if(await deleteLocationById(locationID) === 0) {
|
||||
const location = await fetchLocationById(id);
|
||||
|
||||
if (!location) {
|
||||
return(notFound());
|
||||
}
|
||||
|
||||
revalidatePath('/');
|
||||
redirect(`/`);
|
||||
return (<LocationDeleteForm location={location} />);
|
||||
}
|
||||
Reference in New Issue
Block a user