Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.18 KB | None | 0 0
  1. app.js-------------------------
  2.  
  3. import React, { Component } from 'react';
  4. import {
  5. BrowserRouter as Router,
  6. Route,
  7. Switch,
  8. Redirect
  9. } from 'react-router-dom';
  10.  
  11. import Auth from '../auth/auth';
  12. import Home from '../home/home';
  13. import NoMatch from '../../shared/noMatch/noMatch';
  14.  
  15. import './app.css';
  16. import 'ag-grid-community/dist/styles/ag-grid.css';
  17. import 'ag-grid-community/dist/styles/ag-theme-balham.css';
  18.  
  19. class App extends Component {
  20.  
  21. render() {
  22. return (
  23. <Router>
  24. <div className="row row--full">
  25. <Switch>
  26. <Route exact path="/" render={() => (<Redirect to="/auth"/>)}/>
  27. <Route exact path="/auth" component={Auth}/>
  28. <Route path="/panel" component={Home}/>
  29. <Route path="/*" component={NoMatch}/>
  30. </Switch>
  31. </div>
  32. </Router>
  33. );
  34. }
  35. }
  36.  
  37. export default App;
  38.  
  39. home.js-------------------------
  40.  
  41. import React from 'react';
  42. import {
  43. BrowserRouter as Router,
  44. Route
  45. } from 'react-router-dom';
  46.  
  47. import './home.css';
  48.  
  49. import Row from 'react-bootstrap/Row';
  50. import Col from 'react-bootstrap/Col';
  51.  
  52. import { Topbar, Sidebar } from '../index';
  53. import { Dashboard, Lines, Devices, Users, Parameters } from './index';
  54.  
  55. const Home = () => {
  56. return (
  57. <Row className="row--width-full">
  58. <Col className="col--no-padding" xs="12">
  59. <Topbar></Topbar>
  60. <Router>
  61. <Row className="row--width-full home__page">
  62. <Sidebar></Sidebar>
  63. {/* <Col lg="10" md="9" xs="12"> */}
  64. <div className="home__content">
  65. <Route exact path="/panel" component={ Dashboard }/>
  66. <Route exact path="/panel/users" component={ Users }/>
  67. <Route exact path="/panel/lines" component={ Lines }/>
  68. <Route exact path="/panel/devices" component={ Devices }/>
  69. <Route exact path="/panel/parameters" component={ Parameters }/>
  70. {/* </Col> */}
  71. </div>
  72. </Row>
  73. </Router>
  74. </Col>
  75. </Row>
  76. );
  77. }
  78.  
  79. export default Home;
  80.  
  81.  
  82. users.js-------------------------
  83.  
  84. import React, { Component } from 'react';
  85.  
  86. import Row from 'react-bootstrap/Row';
  87. import Col from 'react-bootstrap/Col';
  88.  
  89. import { Page, Sidepanel } from '../../../index';
  90. import { AddUser, EditUser, EditUserGroups, StatusButton } from './index';
  91.  
  92. class Users extends Component {
  93. constructor(props) {
  94. super(props);
  95.  
  96. this.state = {
  97. title: "Użytkownicy",
  98. description: "dodawanie, usuwanie i konfigurowanie kont użytkowników",
  99. isLoading: false,
  100. userAddingMode: false,
  101. selectedUser: {
  102. id: null,
  103. firstName: "",
  104. lastName: "",
  105. login: "",
  106. password: "",
  107. email: "",
  108. roles: [],
  109. isVerified: true,
  110. canLogin: false,
  111. isAD: false,
  112. isAdmin: false
  113. },
  114. newUser: {
  115. firstName: "",
  116. lastName: "",
  117. login: "",
  118. password: "",
  119. email: "",
  120. roles: [],
  121. isVerified: false,
  122. canLogin: false,
  123. isAD: false,
  124. isAdmin: false
  125. },
  126. columnDefs: [],
  127. users: [],
  128. groups: [
  129. { id: 1, groupName: "szef laboratorium" },
  130. { id: 2, groupName: "laborant" },
  131. { id: 3, groupName: "kierownik zmiany" },
  132. { id: 4, groupName: "raport" },
  133. { id: 5, groupName: "audytor" },
  134. { id: 6, groupName: "próby dekadowe" }
  135. ]
  136. };
  137. }
  138.  
  139. async componentDidMount() {
  140. this.setState({ isLoading: true });
  141. try {
  142. const result = await this.getUsers();
  143. this.setState({ users: result, isLoading: false });
  144. } catch (error) {
  145. this.setState({ error, isLoading: false });
  146. }
  147.  
  148. if (this.state.users.length) {
  149. this.prepareAndSendAgGridDataset();
  150. this.setState({ isLoading: true });
  151. try {
  152. const result = await this.getUserDetails(this.state.users[0].id);
  153. this.setState({ selectedUser: result, isLoading: false });
  154. console.log(this.state)
  155. } catch (error) {
  156. this.setState({ isLoading: false });
  157. }
  158. }
  159. }
  160.  
  161. getUsers = () => {
  162. const users = [
  163. { id: 1, firstName: "Seth", lastName: "Seth", login: "seth" },
  164. { id: 2, firstName: "Jan", lastName: "Nowak", login: "jnowak" },
  165. { id: 3, firstName: "Jan", lastName: "Kowalski", login: "jkowalski" }
  166. ];
  167. return users;
  168. }
  169.  
  170. getUserDetails = id => {
  171. const selectedUser = {
  172. id: 1,
  173. firstName: "Seth",
  174. lastName: "Seth",
  175. login: "seth",
  176. password: "33Seth00",
  177. email: "seth@siseth.com",
  178. roles: [5],
  179. isVerified: true,
  180. canLogin: true,
  181. isAD: false,
  182. isAdmin: true
  183. }
  184. return selectedUser;
  185. }
  186.  
  187. prepareAndSendAgGridDataset = () => {
  188. setTimeout(() => {
  189. const columnDefs = [
  190. { headerName: "Imię", field: "firstName", sortable: true, filter: true, width: 100 },
  191. { headerName: "Nazwisko", field: "lastName", sortable: true, filter: true, width: 120 },
  192. { headerName: "Login", field: "login", sortable: true, filter: true, width: 220 }
  193. ];
  194. this.setState({ columnDefs: columnDefs });
  195. }, 0);
  196. }
  197.  
  198. onChangingMode = () => {
  199. if (this.state.userAddingMode) {
  200. const newUser = {
  201. firstName: "",
  202. lastName: "",
  203. login: "",
  204. password: "",
  205. email: "",
  206. roles: [],
  207. isVerified: false,
  208. canLogin: false,
  209. isAD: false,
  210. isAdmin: false
  211. };
  212. this.setState({ newUser: newUser})
  213. }
  214. this.setState(state => ({ userAddingMode: !state.userAddingMode }));
  215. }
  216.  
  217. onChangingStatus = (text, status) => {
  218. if (!this.state.userAddingMode) {
  219. if (text === "ML") {
  220. const selectedUser = { ...this.state.selectedUser, canLogin: !status };
  221. this.setState(() => ({ selectedUser }));
  222. } else if (text === "AD") {
  223. const selectedUser = { ...this.state.selectedUser, isAD: !status };
  224. this.setState(() => ({ selectedUser }));
  225. } else if (text === "A") {
  226. const selectedUser = { ...this.state.selectedUser, isAdmin: !status };
  227. this.setState(() => ({ selectedUser }));
  228. }
  229. } else {
  230. if (text === "ML") {
  231. const newUser = { ...this.state.newUser, canLogin: !status };
  232. this.setState(() => ({ newUser }));
  233. } else if (text === "AD") {
  234. const newUser = { ...this.state.newUser, isAD: !status };
  235. this.setState(() => ({ newUser }));
  236. } else if (text === "A") {
  237. const newUser = { ...this.state.newUser, isAdmin: !status };
  238. this.setState(() => ({ newUser }));
  239. }
  240. }
  241. }
  242.  
  243. onAddingOrRemovingGroup = id => {
  244. if (this.state.userAddingMode) {
  245. const exist = this.state.selectedUser.roles.find(group => {
  246. return group === id;
  247. });
  248.  
  249. if (exist == null) {
  250. const roles = [ ...this.state.selectedUser.roles, id];
  251. const selectedUser = { ...this.state.selectedUser, roles: roles };
  252. this.setState(() => ({ selectedUser }));
  253. } else {
  254. const roles = this.state.selectedUser.roles.filter(number => {
  255. return number !== id;
  256. });
  257.  
  258. const selectedUser = { ...this.state.selectedUser, roles: roles };
  259. this.setState(() => ({ selectedUser }));
  260. }
  261. } else {
  262. const exist = this.state.selectedUser.roles.find(group => {
  263. return group === id;
  264. });
  265.  
  266. if (exist == null) {
  267. const roles = [ ...this.state.newUser.roles, id];
  268. const newUser = { ...this.state.newUser, roles: roles };
  269. this.setState(() => ({ newUser }));
  270. } else {
  271. const roles = this.state.newUser.roles.filter(number => {
  272. return number !== id;
  273. });
  274.  
  275. const newUser = { ...this.state.newUser, roles: roles };
  276. this.setState(() => ({ newUser }));
  277. }
  278. }
  279. }
  280.  
  281. onUpdateUser = form => {
  282. const copiedUser = this.state.selectedUser;
  283. console.log("onUpdateUser", form, copiedUser)
  284. }
  285.  
  286. onCreatingUser = form => {
  287. const copiedUser = this.state.newUser;
  288. console.log("onCreatingUser", form, copiedUser)
  289. }
  290.  
  291. render() {
  292. const userAddingMode = this.state.userAddingMode;
  293. const selectedUser = this.state.selectedUser;
  294. let pageContent;
  295.  
  296. if (!userAddingMode && selectedUser.id) {
  297. pageContent =
  298. <Col xs="12">
  299. <section className="section">
  300. <div className="section__header">
  301. <h3 className="section__title">{ this.state.selectedUser.firstName + " " + this.state.selectedUser.lastName } <small className="page__description">edycja konta użytkownika</small></h3>
  302. <div className="section__actions">
  303. <StatusButton text="V" tooltip="Konto zweryfikowane" type="info" status={ this.state.selectedUser.isVerified }
  304. isDisabled={ true } onChangingStatus={ this.onChangingStatus }/>
  305. <StatusButton text="ML" tooltip="Możliwość logowania" type="info" status={ this.state.selectedUser.canLogin }
  306. onChangingStatus={ this.onChangingStatus }/>
  307. <StatusButton text="AD" tooltip="Konto Active Directory" type="info" status={ this.state.selectedUser.isAD }
  308. onChangingStatus={ this.onChangingStatus }/>
  309. <StatusButton text="A" tooltip="Administrator" type="info" status={ this.state.selectedUser.isAdmin }
  310. onChangingStatus={ this.onChangingStatus }/>
  311. </div>
  312. </div>
  313. <hr/>
  314. <EditUser selectedUser={ this.state.selectedUser } onUpdateUser={ this.onUpdateUser }/>
  315. </section>
  316. <section className="section">
  317. <h3 className="section__title">Grupa użytkowników</h3>
  318. <hr/>
  319. <EditUserGroups groups={ this.state.groups } userRoles={ this.state.selectedUser.roles } onAddingOrRemovingGroup={ this.onAddingOrRemovingGroup }/>
  320. </section>
  321. </Col>;
  322. } else {
  323. pageContent =
  324. <Col xs="12">
  325. <section className="section">
  326. <div className="section__header">
  327. <h3 className="section__title">Nowy użytkownik <small className="page__description">tworzenie konta użytkownika</small></h3>
  328. <div className="section__actions">
  329. <StatusButton text="ML" tooltip="Możliwość logowania" type="info" status={ this.state.newUser.canLogin }
  330. onChangingStatus={ this.onChangingStatus }/>
  331. <StatusButton text="AD" tooltip="Konto Active Directory" type="info" status={ this.state.newUser.isAD }
  332. onChangingStatus={ this.onChangingStatus }/>
  333. <StatusButton text="A" tooltip="Administrator" type="info" status={ this.state.newUser.isAdmin }
  334. onChangingStatus={ this.onChangingStatus }/>
  335. </div>
  336. </div>
  337. <hr/>
  338. <AddUser newUser={ this.state.newUser } onCreatingUser={ this.onCreatingUser } onChangingMode={ this.onChangingMode }/>
  339. </section>
  340. <section className="section">
  341. <h3 className="section__title">Grupa użytkowników</h3>
  342. <hr/>
  343. <EditUserGroups groups={ this.state.groups } userRoles={ this.state.newUser.roles } onAddingOrRemovingGroup={ this.onAddingOrRemovingGroup }/>
  344. </section>
  345. </Col>;
  346. }
  347.  
  348. return(
  349. <Row>
  350. <Page title={ this.state.title } description={ this.state.description }>
  351. { pageContent }
  352. </Page>
  353. <Sidepanel onChangingMode={ this.onChangingMode } mode={ this.state.userAddingMode } columnDefs={ this.state.columnDefs } rowData={ this.state.users }></Sidepanel>
  354. </Row>
  355. );
  356. }
  357. }
  358.  
  359. export default Users;
  360.  
  361. statusButton.js--------------
  362.  
  363. import React from 'react';
  364. import ReactTooltip from 'react-tooltip';
  365.  
  366. import ButtonGroup from 'react-bootstrap/ButtonGroup';
  367. import Button from 'react-bootstrap/Button';
  368.  
  369. const StatusButton = ({ status, tooltip, type, isDisabled, onChangingStatus, text }) => {
  370.  
  371. return (
  372. <ButtonGroup>
  373. <ReactTooltip/>
  374. <Button key={ text } type="button" className={ `section__button ${ (status === false) ? "section__button--unactive" : "" } `}
  375. data-tip={ tooltip } data-type={ type } disabled={ isDisabled }
  376. onClick={ () => { onChangingStatus(text, status) }}>
  377. { text }
  378. </Button>
  379. </ButtonGroup>
  380. );
  381. }
  382.  
  383. export default StatusButton;
  384.  
  385. editUserGroups.js---------
  386.  
  387. import React, { Component } from 'react';
  388.  
  389. import Row from 'react-bootstrap/Row';
  390. import Col from 'react-bootstrap/Col';
  391. import Form from 'react-bootstrap/Form';
  392.  
  393. class EditUserGroups extends Component {
  394. componentDidMount() {
  395. for (let i = 0; i < this.props.userRoles.length; i++) {
  396. const string = `custom-switch-${ this.props.userRoles[i] }`;
  397. // const number = this.props.userRoles[i];
  398. document.getElementById(string).checked = true;
  399. // setTimeout(() => {
  400. // this.props.onAddingOrRemovingGroup(number);
  401. // }, 500);
  402. }
  403. }
  404.  
  405. render() {
  406. const groups = this.props.groups.map((group) =>
  407. <Col xs="12" key={ group.id }>
  408. <Form>
  409. <Row>
  410. <Col lg="2" md="3" xs="6">{ group.groupName }</Col>
  411. <Col lg="10" md="9" xs="6">
  412. <Form.Check type="switch" id={`custom-switch-${ group.id }`} label={`Kliknij by dodać lub usunąć rolę ${ group.groupName }`}
  413. onChange={ () => { this.props.onAddingOrRemovingGroup(group.id) }}></Form.Check>
  414. </Col>
  415. </Row>
  416. </Form>
  417. </Col>
  418. );
  419. let content;
  420.  
  421. if (groups) {
  422. content =
  423. <>
  424. { groups }
  425. </>;
  426. }
  427.  
  428. return (
  429. <Row>
  430. { content }
  431. </Row>
  432. );
  433. };
  434. }
  435.  
  436. export default EditUserGroups;
  437.  
  438.  
  439. editUser.js---------
  440.  
  441. import React, { Component } from 'react';
  442. import { Formik } from 'formik';
  443.  
  444. import './editUser.css';
  445.  
  446. import Row from 'react-bootstrap/Row';
  447. import Col from 'react-bootstrap/Col';
  448. import Form from 'react-bootstrap/Form';
  449. import InputGroup from 'react-bootstrap/InputGroup';
  450. import ButtonGroup from 'react-bootstrap/ButtonGroup';
  451. import Button from 'react-bootstrap/Button';
  452. import { DotValidation } from '../../../../index';
  453.  
  454. class EditUser extends Component {
  455. render() {
  456. let form;
  457.  
  458. if (this.props.selectedUser.firstName) {
  459. form =
  460. <Formik initialValues = {{
  461. firstName: this.props.selectedUser.firstName,
  462. lastName: this.props.selectedUser.lastName,
  463. login: this.props.selectedUser.login,
  464. password: this.props.selectedUser.password,
  465. email: this.props.selectedUser.email,
  466. }}
  467. validate = { values => {
  468. const errors = {};
  469.  
  470. if (!values.firstName || (values.firstName.length < 3)) {
  471. errors.firstName = true;
  472. }
  473.  
  474. if (!values.lastName || (values.lastName.length < 3)) {
  475. errors.lastName = true;
  476. }
  477.  
  478. if (!values.login) {
  479. errors.login = true;
  480. }
  481.  
  482. if (!values.password || !/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/i.test(values.password)) {
  483. errors.password = true;
  484. }
  485.  
  486. if (!values.email || !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
  487. errors.email = true;
  488. }
  489.  
  490. return errors;
  491. }}
  492. onSubmit={( values, { setSubmitting }) => {
  493. setTimeout(() => {
  494. this.props.onUpdateUser(values);
  495. setSubmitting(false);
  496. }, 0);
  497. }}>
  498. {({ values, errors, touched, handleChange, handleBlur, handleSubmit, handleReset, isSubmitting, isValid }) => (
  499. <Form className="form--edit-user" onSubmit={ handleSubmit }>
  500. <Row>
  501. <Col lg="6" md="6" xs="12">
  502. <Form.Group controlId="formFirstName">
  503. <Form.Label>Imię</Form.Label>
  504. <InputGroup>
  505. <DotValidation hidden={ false } validation={ errors.firstName } touched={ touched.firstName }/>
  506. <Form.Control className="input--zucker-theme" type="text" name="firstName" placeholder="Imię"
  507. onChange={ handleChange } onBlur={ handleBlur } value={ values.firstName }></Form.Control>
  508. </InputGroup>
  509. </Form.Group>
  510. </Col>
  511. <Col lg="6" md="6" xs="12">
  512. <Form.Group controlId="formLastName">
  513. <Form.Label>Nazwisko</Form.Label>
  514. <InputGroup>
  515. <DotValidation hidden={ false } validation={ errors.lastName } touched={ touched.lastName }/>
  516. <Form.Control className="input--zucker-theme" type="text" name="lastName" placeholder="Nazwisko"
  517. onChange={ handleChange } onBlur={ handleBlur } value={ values.lastName }></Form.Control>
  518. </InputGroup>
  519. </Form.Group>
  520. </Col>
  521. <Col lg="6" md="6" xs="12">
  522. <Form.Group controlId="formLogin">
  523. <Form.Label>Login</Form.Label>
  524. <InputGroup>
  525. <DotValidation hidden={ false } validation={ errors.login } touched={ touched.login }/>
  526. <Form.Control className="input--zucker-theme" type="text" name="login" placeholder="Login"
  527. onChange={ handleChange } onBlur={ handleBlur } value={ values.login }></Form.Control>
  528. </InputGroup>
  529. </Form.Group>
  530. </Col>
  531. <Col lg="6" md="6" xs="12">
  532. <Form.Group controlId="formPassword">
  533. <Form.Label>Hasło</Form.Label>
  534. <InputGroup>
  535. <DotValidation hidden={ false } validation={ errors.password } touched={ touched.password }/>
  536. <Form.Control className="input--zucker-theme" type="password" name="password" placeholder="Hasło"
  537. onChange={ handleChange } onBlur={ handleBlur } value={ values.password }></Form.Control>
  538. </InputGroup>
  539. </Form.Group>
  540. </Col>
  541. <Col lg="6" md="6" xs="12">
  542. <Form.Group controlId="formEmail">
  543. <Form.Label>Email</Form.Label>
  544. <InputGroup>
  545. <DotValidation hidden={ false } validation={ errors.email } touched={ touched.email }/>
  546. <Form.Control className="input--zucker-theme" type="email" name="email" placeholder="Email"
  547. onChange={ handleChange } onBlur={ handleBlur } value={ values.email }></Form.Control>
  548. </InputGroup>
  549. </Form.Group>
  550. </Col>
  551. <Col className="form__actions--bottom" xs="12">
  552. <ButtonGroup aria-label="Page buttons first bottom group">
  553. <Button className="form__button" variant="secondary" type="reset" onClick={ handleReset }>
  554. Anuluj
  555. </Button>
  556. </ButtonGroup>
  557. <ButtonGroup aria-label="Page buttons second bottom group">
  558. <Button className="form__button" variant="primary" type="submit" disabled={ !isValid || isSubmitting }>
  559. Zapisz
  560. </Button>
  561. </ButtonGroup>
  562. </Col>
  563. </Row>
  564. </Form>
  565. )}
  566. </Formik>;
  567. }
  568.  
  569. return (
  570. <>
  571. { form }
  572. </>
  573. );
  574. };
  575. }
  576.  
  577. export default EditUser;
  578.  
  579.  
  580. addUser.js---------------
  581.  
  582. import React, { Component } from 'react';
  583. import { Formik } from 'formik';
  584.  
  585. import Row from 'react-bootstrap/Row';
  586. import Col from 'react-bootstrap/Col';
  587. import Form from 'react-bootstrap/Form';
  588. import InputGroup from 'react-bootstrap/InputGroup';
  589. import ButtonGroup from 'react-bootstrap/ButtonGroup';
  590. import Button from 'react-bootstrap/Button';
  591. import { DotValidation } from '../../../../index';
  592.  
  593. class AddUser extends Component {
  594. render() {
  595. return (
  596. <Formik initialValues = {{
  597. firstName: this.props.newUser.firstName,
  598. lastName: this.props.newUser.lastName,
  599. login: this.props.newUser.login,
  600. password: this.props.newUser.password,
  601. email: this.props.newUser.email,
  602. isAD: this.props.newUser.isAD
  603. }}
  604. validate = { values => {
  605. const errors = {};
  606.  
  607. if (!values.firstName || (values.firstName.length < 3)) {
  608. errors.firstName = true;
  609. }
  610.  
  611. if (!values.lastName || (values.lastName.length < 3)) {
  612. errors.lastName = true;
  613. }
  614.  
  615. if (!values.login) {
  616. errors.login = true;
  617. }
  618.  
  619. if (!this.props.newUser.isAD && (!values.password || !/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/i.test(values.password))) {
  620. errors.password = true;
  621. }
  622.  
  623. if (!values.email || !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
  624. errors.email = true;
  625. }
  626.  
  627. return errors;
  628. }}
  629. onReset={() => {
  630. setTimeout(() => {
  631. this.props.onChangingMode();
  632. }, 0);
  633. }}
  634. onSubmit={( values, { setSubmitting }) => {
  635. setTimeout(() => {
  636. this.props.onCreatingUser(values);
  637. setSubmitting(false);
  638. }, 0);
  639. }}>
  640. {({ values, errors, touched, handleChange, handleBlur, handleSubmit, handleReset, isSubmitting, isValid }) => (
  641. <Form onSubmit={ handleSubmit }>
  642. <Row>
  643. <Col lg="6" md="6" xs="12">
  644. <Form.Group controlId="formFirstName">
  645. <Form.Label>Imię</Form.Label>
  646. <InputGroup>
  647. <DotValidation hidden={ false } validation={ errors.firstName } touched={ touched.firstName }/>
  648. <Form.Control className="input--zucker-theme" type="text" name="firstName" placeholder="Imię"
  649. onChange={ handleChange } onBlur={ handleBlur } value={ values.firstName }></Form.Control>
  650. </InputGroup>
  651. </Form.Group>
  652. </Col>
  653. <Col lg="6" md="6" xs="12">
  654. <Form.Group controlId="formLastName">
  655. <Form.Label>Nazwisko</Form.Label>
  656. <InputGroup>
  657. <DotValidation hidden={ false } validation={ errors.lastName } touched={ touched.lastName }/>
  658. <Form.Control className="input--zucker-theme" type="text" name="lastName" placeholder="Nazwisko"
  659. onChange={ handleChange } onBlur={ handleBlur } value={ values.lastName }></Form.Control>
  660. </InputGroup>
  661. </Form.Group>
  662. </Col>
  663. <Col lg="6" md="6" xs="12">
  664. <Form.Group controlId="formLogin">
  665. <Form.Label>Login</Form.Label>
  666. <InputGroup>
  667. <DotValidation hidden={ false } validation={ errors.login } touched={ touched.login }/>
  668. <Form.Control className="input--zucker-theme" type="text" name="login" placeholder="Login"
  669. onChange={ handleChange } onBlur={ handleBlur } value={ values.login }></Form.Control>
  670. </InputGroup>
  671. </Form.Group>
  672. </Col>
  673. <Col lg="6" md="6" xs="12">
  674. <Form.Group controlId="formPassword">
  675. <Form.Label>Hasło</Form.Label>
  676. <InputGroup>
  677. <DotValidation hidden={ this.props.newUser.isAD } validation={ errors.password } touched={ touched.password }/>
  678. <Form.Control className="input--zucker-theme" type="password" name="password" placeholder="Hasło"
  679. onChange={ handleChange } onBlur={ handleBlur } value={ values.password }
  680. disabled={ this.props.newUser.isAD } required={ this.props.newUser.isAD }></Form.Control>
  681. </InputGroup>
  682. </Form.Group>
  683. </Col>
  684. <Col lg="6" md="6" xs="12">
  685. <Form.Group controlId="formEmail">
  686. <Form.Label>Email</Form.Label>
  687. <InputGroup>
  688. <DotValidation hidden={ false } validation={ errors.email } touched={ touched.email }/>
  689. <Form.Control className="input--zucker-theme" type="email" name="email" placeholder="Email"
  690. onChange={ handleChange } onBlur={ handleBlur } value={ values.email }></Form.Control>
  691. </InputGroup>
  692. </Form.Group>
  693. </Col>
  694. <Col className="form__actions--bottom" xs="12">
  695. <ButtonGroup aria-label="Page buttons first bottom group">
  696. <Button className="form__button" variant="secondary" type="reset" onClick={ handleReset }>
  697. Anuluj
  698. </Button>
  699. </ButtonGroup>
  700. <ButtonGroup aria-label="Page buttons second bottom group">
  701. <Button className="form__button" variant="primary" type="submit" disabled={ !isValid || isSubmitting }>
  702. Zapisz
  703. </Button>
  704. </ButtonGroup>
  705. </Col>
  706. </Row>
  707. </Form>
  708. )}
  709. </Formik>
  710. );
  711. }
  712. }
  713.  
  714. export default AddUser;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement