implemente bill add
This commit is contained in:
10
app/bill/[id]/add/page.tsx
Normal file
10
app/bill/[id]/add/page.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
4
app/bill/[id]/delete/not-found.tsx
Normal file
4
app/bill/[id]/delete/not-found.tsx
Normal 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." />;
|
||||
12
app/bill/[id]/delete/page.tsx
Normal file
12
app/bill/[id]/delete/page.tsx
Normal 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(`/`);
|
||||
}
|
||||
4
app/bill/[id]/edit/not-found.tsx
Normal file
4
app/bill/[id]/edit/not-found.tsx
Normal 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." />;
|
||||
22
app/bill/[id]/edit/page.tsx
Normal file
22
app/bill/[id]/edit/page.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user