import {useSearchParams} from "react-router-dom";
import {PageHeader} from "../../../component/PageHeader.tsx";
import {useLoadingToast} from "../../../hook/useLoadingToast.ts";
import {ActionButtonFormGroup} from "../../../component/button/ActionButtonFormGroup.tsx";
import {useContentFormPage} from "../hook/page/useContentFormPage.ts";
import {ContentFormTable} from "../component/ContentFormTable.tsx";

export const ContentFormPage = () => {
    const [urlParams] = useSearchParams();
    const cntId = urlParams.get("cntId") || "";
    const cntDtId = urlParams.get("cntDtId") || "";
    const {
        header,
        status,
        form,
        actions,
    } = useContentFormPage(cntId, cntDtId);

    useLoadingToast(status);

    return (
        <>
            <PageHeader {...header}/>
            <ContentFormTable {...form}/>
            <ActionButtonFormGroup {...actions}/>
        </>
    );
}
