-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [open-formulieren/open-forms#4929] Extract form landing page route…
… 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
1 parent
189b3b8
commit 1630ff9
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |