implemente bill add

This commit is contained in:
2024-01-05 14:20:00 +01:00
parent 73029fb28a
commit 245cc38717
9 changed files with 69 additions and 46 deletions

View File

@@ -0,0 +1,10 @@
import { BillEditForm } from '@/app/ui/BillEditForm';
export default async function Page({ params:{ id:locationID } }: { params: { id:string } }) {
return (
<main>
<BillEditForm locationID={locationID} />
</main>
);
}

View File

@@ -0,0 +1,4 @@
import { NotFoundPage } from '@/app/ui/NotFoundPage';
export default () =>
<NotFoundPage title="404 Bill Not Found" description="Could not find the requested Bill." />;

View File

@@ -0,0 +1,12 @@
import { deleteBillById } from '@/app/lib/actions';
import { notFound, redirect } from 'next/navigation';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
const [locationID, billID] = id.split('-');
if(await deleteBillById(locationID, billID) === 0) {
return(notFound());
}
redirect(`/`);
}

View File

@@ -0,0 +1,4 @@
import { NotFoundPage } from '@/app/ui/NotFoundPage';
export default () =>
<NotFoundPage title="404 Bill Not Found" description="Could not find the requested Bill." />;

View File

@@ -0,0 +1,22 @@
import { BillingLocation, Bill } from '@/app/lib/db-types';
import { fetchBillById } from '@/app/lib/actions';
import clientPromise from '@/app/lib/mongodb';
import { BillEditForm } from '@/app/ui/BillEditForm';
import { ObjectId } from 'mongodb';
import { notFound } from 'next/navigation';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
const [locationID, billID] = id.split('-');
const bill = await fetchBillById(locationID, billID);
if (!bill) {
return(notFound());
}
return (
<main>
<BillEditForm locationID={locationID} bill={bill} />
</main>
);
}