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

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 (<BillDeleteForm location={location} bill={bill} />);
}