Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. Grid,
  4. InputLabel,
  5. Input,
  6. FormControl,
  7. FormHelperText,
  8. Popover,
  9. Button
  10. } from '@material-ui/core';
  11. import { SketchPicker } from 'react-color';
  12.  
  13. import './JobForm.css';
  14.  
  15.  
  16. export default class JobForm extends Component {
  17. constructor(props) {
  18. super(props)
  19. this.state = {
  20. isOpen: false,
  21. anchorEl: null
  22. }
  23. }
  24.  
  25. open = (e) => this.setState({ isOpen: true, anchorEl: e.currentTarget })
  26. close = () => this.setState({ isOpen: false });
  27.  
  28. onKeyDown = (event) => {
  29. if (event.key === 'Enter') {
  30. this.props.handleSubmit(event)
  31. }
  32. }
  33.  
  34.  
  35. render() {
  36. const { handleChange, setErrors, handleSubmit } = this.props;
  37. return (
  38. <div className="JobForm">
  39. <Grid spacing={2} container>
  40. <Grid item xs={12} className="jobLine">
  41. <div className='bookmark-job' style={{ backgroundColor: this.props.color }} onClick={(e) => this.open(e)}></div>
  42. <Popover
  43. open={this.state.isOpen}
  44. onClose={this.close}
  45. anchorEl={this.state.anchorEl}
  46. anchorOrigin={{
  47. vertical: 'bottom',
  48. horizontal: 'left',
  49. }}
  50. transformOrigin={{
  51. vertical: 'top',
  52. horizontal: 'left',
  53. }}>
  54. <SketchPicker
  55. color={this.props.color}
  56. onChange={(e) => this.props.handleChange('color', e.hex)}
  57. />
  58. </Popover>
  59. <FormControl disabled={this.props.submitting} error={this.props.error.name ? true : false} fullWidth>
  60. <InputLabel htmlFor="input-name">Nom</InputLabel>
  61. <Input
  62. autoFocus={true}
  63. onKeyDown={this.onKeyDown}
  64. onBlur={() => setErrors(['name'])}
  65. id="input-name"
  66. value={this.props.name}
  67. onChange={e => handleChange('name', e.target.value)}
  68. inputProps={{
  69. maxLength: "50"
  70. }}
  71. />
  72. </FormControl>
  73. </Grid>
  74. </Grid>
  75. </div>
  76. );
  77. }
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement