import { fetchBillById } from '@/app/lib/actions/billActions';
import { BillEditForm } from '@/app/ui/BillEditForm';
import { Main } from '@/app/ui/Main';
import { notFound } from 'next/navigation';

export default async function Page({ params:{ id } }: { params: { id:string } }) {

    const [locationID, billID] = id.split('-');

    const [location, bill] = await fetchBillById(locationID, billID) ?? [];

    if (!bill || !location) {
        return(notFound());
    }
    return (
        <Main>
            <BillEditForm location={location} bill={bill} />
        </Main>
    );
}