diff --git a/app/bill/[id]/delete/page.tsx b/app/bill/[id]/delete/page.tsx index 0063355..311a0ed 100644 --- a/app/bill/[id]/delete/page.tsx +++ b/app/bill/[id]/delete/page.tsx @@ -1,4 +1,5 @@ import { deleteBillById } from '@/app/lib/billActions'; +import { revalidatePath } from 'next/cache'; import { notFound, redirect } from 'next/navigation'; export default async function Page({ params:{ id } }: { params: { id:string } }) { @@ -8,5 +9,6 @@ export default async function Page({ params:{ id } }: { params: { id:string } }) return(notFound()); } + revalidatePath('/'); redirect(`/`); } \ No newline at end of file diff --git a/app/location/[id]/delete/not-found.tsx b/app/location/[id]/delete/not-found.tsx new file mode 100644 index 0000000..2e33623 --- /dev/null +++ b/app/location/[id]/delete/not-found.tsx @@ -0,0 +1,4 @@ +import { NotFoundPage } from '@/app/ui/NotFoundPage'; + +export default () => +; \ No newline at end of file diff --git a/app/location/[id]/delete/page.tsx b/app/location/[id]/delete/page.tsx new file mode 100644 index 0000000..9344ac2 --- /dev/null +++ b/app/location/[id]/delete/page.tsx @@ -0,0 +1,15 @@ +import { deleteBillById } from '@/app/lib/billActions'; +import { deleteLocationById } from '@/app/lib/locationActions'; +import { revalidatePath } from 'next/cache'; +import { notFound, redirect } from 'next/navigation'; + +export default async function Page({ params:{ id } }: { params: { id:string } }) { + const locationID = id; + + if(await deleteLocationById(locationID) === 0) { + return(notFound()); + } + + revalidatePath('/'); + redirect(`/`); +} \ No newline at end of file diff --git a/app/ui/LocationEditForm.tsx b/app/ui/LocationEditForm.tsx index 3c94036..a2f55e1 100644 --- a/app/ui/LocationEditForm.tsx +++ b/app/ui/LocationEditForm.tsx @@ -32,13 +32,11 @@ export const LocationEditForm:FC = ({ location, yearMonth { - // show delete button only if location is set (otherwise it's a add operation) - location ? - - - : null + location && + + + } - {state.errors?.locationName &&