-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
122 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,29 @@ | ||
import React, { createElement } from 'react'; | ||
import { Route } from 'react-router'; | ||
|
||
/** | ||
<CreateRouter basePath="/user" resource="user"> | ||
<Create /> | ||
</CreateRouter>; | ||
*/ | ||
|
||
export const CreateRouter = ({ basePath, resource, children }) => { | ||
if (!children) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Route | ||
path={`${basePath}/create`} | ||
render={props => | ||
createElement(children, { | ||
basePath, | ||
...resource, | ||
...props, | ||
}) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default CreateRouter; |
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,30 @@ | ||
import React, { createElement } from 'react'; | ||
import { Route } from 'react-router'; | ||
|
||
/** | ||
<EditRouter basePath="/user" resource="user"> | ||
<Show /> | ||
</EditRouter>; | ||
*/ | ||
|
||
export const EditRouter = ({ basePath, resource, children }) => { | ||
if (!children) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Route | ||
path={`${basePath}/:id`} | ||
render={props => | ||
createElement(children, { | ||
basePath, | ||
id: decodeURIComponent(props.match.params.id), | ||
...resource, | ||
...props, | ||
}) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default EditRouter; |
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,29 @@ | ||
import React, { createElement } from 'react'; | ||
import { Route } from 'react-router'; | ||
|
||
/** | ||
<ListRouter basePath="/user" resource="user"> | ||
<Create /> | ||
</ListRouter>; | ||
*/ | ||
|
||
export const ListRouter = ({ basePath, resource, children }) => { | ||
if (!children) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Route | ||
path={basePath} | ||
render={props => | ||
createElement(children, { | ||
basePath, | ||
...resource, | ||
...props, | ||
}) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default ListRouter; |
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,30 @@ | ||
import React, { createElement } from 'react'; | ||
import { Route } from 'react-router'; | ||
|
||
/** | ||
<ShowRouter basePath="/user" resource="user"> | ||
<Show /> | ||
</ShowRouter>; | ||
*/ | ||
|
||
export const ShowRouter = ({ basePath, resource, children }) => { | ||
if (!children) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Route | ||
path={`${basePath}/:id/show`} | ||
render={props => | ||
createElement(children, { | ||
basePath, | ||
id: decodeURIComponent(props.match.params.id), | ||
...resource, | ||
...props, | ||
}) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default ShowRouter; |
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,4 @@ | ||
export * from './CreateRouter'; | ||
export * from './EditRouter'; | ||
export * from './ListRouter'; | ||
export * from './ShowRouter'; |