import { PlainLocation, PlainBill, MongoLocation } from '@/app/lib/db-types';
import { fetchBillById } from '@/app/lib/fetchBillById';
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 [invoiceID, billID] = id.split('-');

    const bill = await fetchBillById(invoiceID, billID);

    if (!bill) {
        notFound();
    }
    return (
        <main>
            <BillEditForm invoiceID={invoiceID} bill={bill} />
        </main>
    );
}