import React, { useEffect, useMemo, useState } from 'react';
import { useLocation, useHistory } from 'react-router-dom';
import { UdpFormsBuilder } from 'udp-react-stencil-component-library';
import { useUser } from '../../../utilities/auth/useUser';
import { useTenant } from '../../../utilities/tenant/useTenant';
import { useSnackbar } from 'notistack';
const UdpFormsBuilderPage = (props) => {
    const user = useUser();
    const tenant = useTenant();
    const location = useLocation(); // detects changes in the URL
    const history = useHistory();
    const { enqueueSnackbar, closeSnackbar } = useSnackbar();
    // Store search params in state so re-render happens when they change
    const [searchParams, setSearchParams] = useState(() => new URLSearchParams(location.search));
    // Recompute search params on location change
    useEffect(() => {
        setSearchParams(new URLSearchParams(location.search));
    }, [location.search]);
    // Extract values from searchParams
    const formId = searchParams.get('udpf_formId');
    const version = searchParams.get('udpf_formVersion');
    const callbackUrl = searchParams.get('udpf_callback_url');
    return (React.createElement("div", null, React.createElement(UdpFormsBuilder, Object.assign({ formId: formId, version: version, history: history, getUserCallback: () => user, getTenantCallback: () => tenant, enqueueSnackbar: enqueueSnackbar, closeSnackbar: closeSnackbar, isPublicFormConfigOn: true, isCommentingConfigOn: true, isFollowUpFormConfigOn: false }, props))));
};
export default UdpFormsBuilderPage;
//# sourceMappingURL=UdpFormsBuilderPage.js.map