forked from usds/us-forms-system-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move route creation code from USFS into here
- Loading branch information
1 parent
a8d2d8f
commit 5033790
Showing
4 changed files
with
69 additions
and
27 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
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 |
---|---|---|
@@ -1,17 +1,58 @@ | ||
import { createRoutes } from 'us-forms-system/lib/js/helpers'; | ||
|
||
import formConfig from './config/form'; | ||
import Form from './components/Form.jsx'; | ||
|
||
const routes = createRoutes(formConfig); | ||
import FormPage from 'us-forms-system/lib/js/containers/FormPage'; | ||
import ReviewPage from 'us-forms-system/lib/js/review/ReviewPage'; | ||
|
||
import { createFormPageList, createPageList } from 'us-forms-system/lib/js/helpers'; | ||
|
||
export function makeRoutes(withRouter) { | ||
const formPages = createFormPageList(formConfig); | ||
const pageList = createPageList(formConfig, formPages); | ||
let routes = formPages | ||
.map(page => { | ||
return { | ||
path: page.path, | ||
component: withRouter(page.component || FormPage), | ||
pageConfig: page, | ||
pageList, | ||
urlPrefix: formConfig.urlPrefix | ||
}; | ||
}); | ||
if (formConfig.introduction) { | ||
routes = [ | ||
{ | ||
path: 'introduction', | ||
component: withRouter(formConfig.introduction), | ||
formConfig, | ||
pageList | ||
} | ||
].concat(routes); | ||
} | ||
|
||
const route = { | ||
path: '/', | ||
component: Form, | ||
indexRoute: { | ||
onEnter: (nextState, replace) => replace(formConfig.urlPrefix+routes[0].path) | ||
}, | ||
childRoutes: routes, | ||
}; | ||
routes = routes.concat([ | ||
{ | ||
path: 'review-and-submit', | ||
formConfig, | ||
component: withRouter(ReviewPage), | ||
pageList | ||
}, | ||
{ | ||
path: 'confirmation', | ||
component: formConfig.confirmation //withRouter | ||
}, | ||
{ | ||
path: '*', | ||
onEnter: (nextState, replace) => replace(formConfig.urlPrefix || '/') | ||
} | ||
]); | ||
|
||
export default route; | ||
return { | ||
path: '/', | ||
component: Form, | ||
indexRoute: { | ||
onEnter: (nextState, replace) => replace(formConfig.urlPrefix+routes[0].path) | ||
}, | ||
childRoutes: routes, | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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