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

export default async function Page({ params:{ id } }: { params: { id:string } }) {
    const [locationID, billID] = id.split('-');

    const [location, bill] = await fetchBillById(locationID, billID) ?? [];
    
    if (!location || !bill) {
        return(notFound());
    }

    return (
        <Main>
            <BillDeleteForm location={location} bill={bill} />
        </Main>
    );
}