Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. Index: src/components/UserForm.js
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- src/components/UserForm.js (date 1542033676279)
  7. +++ src/components/UserForm.js (date 1542033676279)
  8. @@ -0,0 +1,32 @@
  9. +import React from 'react';
  10. +import Tab from '@material-ui/core/Tab';
  11. +import Tabs from '@material-ui/core/Tabs';
  12. +import TextField from '@material-ui/core/TextField';
  13. +import Typography from '@material-ui/core/Typography';
  14. +import withStyles from '@material-ui/core/styles/withStyles';
  15. +
  16. +const styles = theme => ({
  17. + form: {
  18. + width: '100%',
  19. + marginTop: theme.spacing.unit * 5
  20. + }
  21. +});
  22. +
  23. +export default withStyles(styles)(({ classes, handleInputChange, handleSubmit, onTabChange, selectedTab, submitButtonText, value }) => {
  24. + return (
  25. + <form
  26. + autoComplete={"off"}
  27. + className={classes.form}
  28. + onSubmit={handleSubmit}>
  29. + <Tabs
  30. + indicatorColor={"primary"}
  31. + textColor={"primary"}
  32. + value={selectedTab}
  33. + onChange={onTabChange}>
  34. + <Tab label={"General Information"} />
  35. + <Tab label={"Roles"} />
  36. + <Tab label={"Custom permissions"} />
  37. + </Tabs>
  38. + </form>
  39. + );
  40. +});
  41. Index: src/containers/UserFormContainer.js
  42. IDEA additional info:
  43. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  44. <+>UTF-8
  45. ===================================================================
  46. --- src/containers/UserFormContainer.js (date 1542033424799)
  47. +++ src/containers/UserFormContainer.js (date 1542033424799)
  48. @@ -0,0 +1,120 @@
  49. +import React from 'react';
  50. +import Paper from '@material-ui/core/Paper';
  51. +import Typography from '@material-ui/core/Typography';
  52. +import withStyles from '@material-ui/core/styles/withStyles';
  53. +
  54. +import UserForm from '../components/UserForm';
  55. +
  56. +const styles = theme => ({
  57. + paper: {
  58. + width: 1024,
  59. + margin: '64px auto',
  60. + padding: `${theme.spacing.unit * 3}px`
  61. + }
  62. +});
  63. +
  64. +class UserFormContainer extends React.Component {
  65. +
  66. + constructor(props) {
  67. + super(props);
  68. +
  69. + this.state = {
  70. + form: {
  71. + client: '',
  72. + emailAddress: '',
  73. + password: '',
  74. + replicatedPassword: '',
  75. + firstName: '',
  76. + lastName: ''
  77. + },
  78. + modeConfiguration: {
  79. + cardTitle: '',
  80. + submitButtonText: ''
  81. + },
  82. + selectedTab: 0,
  83. + selectedUser: {
  84. + id: '',
  85. + client: '',
  86. + emailAddress: '',
  87. + password: '',
  88. + firstName: '',
  89. + lastName: '',
  90. + permissions: {
  91. + roleSet: [],
  92. + customPermissionSet: [],
  93. + isSuperAdmin: false
  94. + }
  95. + }
  96. + };
  97. + }
  98. +
  99. + componentDidMount() {
  100. + if (this.props.mode === 'create') {
  101. + const modeConfiguration = this.state.modeConfiguration;
  102. + modeConfiguration.paperTitle = 'Create user';
  103. + modeConfiguration.submitButtonText = 'Create';
  104. +
  105. + this.setState({
  106. + modeConfiguration: modeConfiguration
  107. + });
  108. + }
  109. +
  110. + if (this.props.mode === 'edit') {
  111. + const modeConfiguration = this.state.modeConfiguration;
  112. + modeConfiguration.paperTitle = 'Edit user';
  113. + modeConfiguration.submitButtonText = 'Edit';
  114. +
  115. + this.setState({
  116. + modeConfiguration: modeConfiguration
  117. + });
  118. + }
  119. + }
  120. +
  121. + handleInputChange = event => {
  122. + const name = event.target.name;
  123. + const value = event.target.value;
  124. +
  125. + const form = this.state.form;
  126. + form[ name ] = value;
  127. +
  128. + this.setState({
  129. + form: form
  130. + });
  131. + };
  132. +
  133. + handleSubmit = event => {
  134. + event.preventDefault();
  135. +
  136. + if (this.props.mode === 'create') {
  137. + this.handleCreateModeSubmit();
  138. + }
  139. +
  140. + if (this.props.mode === 'edit') {
  141. + this.handleEditModeSubmit();
  142. + }
  143. + };
  144. +
  145. + handleTabChange = (event, value) => {
  146. + this.setState({ selectedTab: value });
  147. + };
  148. +
  149. + handleCreateModeSubmit() {
  150. + }
  151. +
  152. + handleEditModeSubmit() {
  153. + }
  154. +
  155. + render() {
  156. + return (
  157. + <Paper className={this.props.classes.paper}>
  158. + <Typography
  159. + component={"h1"}
  160. + variant={"h5"}>{this.state.modeConfiguration.paperTitle}
  161. + </Typography>
  162. + <UserForm onTabChange={this.handleTabChange} selectedTab={this.state.selectedTab}/>
  163. + </Paper>
  164. + );
  165. + }
  166. +}
  167. +
  168. +export default withStyles(styles)(UserFormContainer);
  169. Index: src/components/PermissionList.js
  170. IDEA additional info:
  171. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  172. <+>UTF-8
  173. ===================================================================
  174. --- src/components/PermissionList.js (date 1542031217603)
  175. +++ src/components/PermissionList.js (date 1542031217603)
  176. @@ -0,0 +1,1 @@
  177. +import React from 'react';
  178. Index: src/components/RoleList.js
  179. IDEA additional info:
  180. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  181. <+>UTF-8
  182. ===================================================================
  183. --- src/components/RoleList.js (date 1542031217605)
  184. +++ src/components/RoleList.js (date 1542031217605)
  185. @@ -0,0 +1,1 @@
  186. +import React from 'react';
  187. Index: src/routers/UserRouter.js
  188. IDEA additional info:
  189. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  190. <+>UTF-8
  191. ===================================================================
  192. --- src/routers/UserRouter.js (revision f96042b33a71505f37e535a4bfb9a0546e59ce3e)
  193. +++ src/routers/UserRouter.js (date 1542032932224)
  194. @@ -3,6 +3,7 @@
  195.  
  196. import NavigationBar from '../components/NavigationBar';
  197.  
  198. +import UserFormContainer from '../containers/UserFormContainer';
  199. import UserListContainer from '../containers/UserListContainer';
  200.  
  201. export default () => (
  202. @@ -10,7 +11,7 @@
  203. <NavigationBar title={"Users"} />
  204. <Switch>
  205. <Route exact path={"/users"} component={UserListContainer} />
  206. - <Route path={"/users/add"} render={{}} />
  207. + <Route path={"/users/add"} render={props => <UserFormContainer mode={"create"} {...props} />} />
  208. <Route path={"/users/detail/:id"} render={{}} />
  209. </Switch>
  210. </React.Fragment>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement