Skip to content

Commit

Permalink
♻️ [open-formulieren/open-forms#4929] Extract form landing page route…
Browse files Browse the repository at this point in the history
… into separate component

Created a separate component that handles the redirect logic from the
landing page, using the context rather than props to get the
necessary information. This makes it possible to use the component as
element in a statically defined route.
  • Loading branch information
sergei-maertens committed Jan 13, 2025
1 parent 189b3b8 commit 1630ff9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/FormLandingPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Navigate} from 'react-router-dom';

import useFormContext from 'hooks/useFormContext';
import useInitialDataReference from 'hooks/useInitialDataReference';

const FormLandingPage = () => {
const {introductionPageContent = ''} = useFormContext();
const {addInitialDataReference} = useInitialDataReference();
const startPageUrl = introductionPageContent ? 'introductie' : 'startpagina';
return <Navigate replace to={addInitialDataReference(startPageUrl)} />;
};

FormLandingPage.propTypes = {};

export default FormLandingPage;
10 changes: 10 additions & 0 deletions src/components/formRoutes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FormLandingPage from 'components/FormLandingPage';

const formRoutes = [
{
path: '',
element: <FormLandingPage />,
},
];

export default formRoutes;

0 comments on commit 1630ff9

Please sign in to comment.