File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,14 @@ const Administration = ({ match }) => {
88 return (
99 < >
1010 < Route exact path = { `${ match . path } /users` } component = { UsersList } />
11- < Route path = { `${ match . path } /users/:userId/edit` } component = { UserEditor } />
11+ < Route
12+ path = { `${ match . path } /users/new` }
13+ render = { ( props ) => < UserEditor { ...props } /> }
14+ />
15+ < Route
16+ path = { `${ match . path } /users/:userId/edit` }
17+ render = { ( props ) => < UserEditor { ...props } userId = { parseInt ( props . match . params . userId ) } /> }
18+ />
1219 </ >
1320 )
1421}
Original file line number Diff line number Diff line change @@ -3,12 +3,20 @@ import PropTypes from 'prop-types'
33
44import api from '@/_api'
55
6- const UserEditor = ( { match } ) => {
7- const [ user , setUser ] = useState ( [ ] )
6+ import BasePageContainer from '@/_common/BasePageContainer'
7+ import BasePageToolbar from '@/_common/BasePageToolbar'
8+ import Grid from "@material-ui/core/Grid" ;
9+
10+ const UserEditor = ( props ) => {
11+
12+ const { userId } = props
13+ const [ user , setUser ] = useState ( { } )
814
915 useEffect ( ( ) => {
16+ if ( ! userId ) {
17+ return
18+ }
1019 async function fetchUser ( ) {
11- const userId = match . params . userId ;
1220 try {
1321 const userDataRes = await api . users . getOne ( userId )
1422 setUser ( userDataRes )
@@ -17,15 +25,20 @@ const UserEditor = ({ match }) => {
1725 }
1826 }
1927 fetchUser ( )
20- } , [ ] )
28+ } , [ userId ] )
2129
2230 return (
23- < >
24- UserEditor
25- </ >
31+ < BasePageContainer >
32+ < BasePageToolbar title = { 'Edit user' } > </ BasePageToolbar >
33+ < Grid container spacing = { 3 } >
34+ UserEditor
35+ </ Grid >
36+ </ BasePageContainer >
2637 )
2738}
2839
29- UserEditor . propTypes = { }
40+ UserEditor . propTypes = {
41+ userId : PropTypes . number
42+ }
3043
3144export default UserEditor
You can’t perform that action at this time.
0 commit comments