CheckBoxWindow.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from 'react';
  2. class CheckBoxWindow extends React.Component {
  3. changeSpecialityArray = (e) => {
  4. this.props.changeSpecialityArray(e.target)
  5. };
  6. render() {
  7. const {categories, changeFlag,specialityArray} = this.props;
  8. return (
  9. <>
  10. <div className = "check-container">
  11. {categories.map(el => (
  12. <div className = "check-speciality" key={el._id}>
  13. <h4>{el.name}</h4>
  14. {
  15. el.services.map(item => (
  16. <div className = "check-elem" key={item._id} >
  17. <input
  18. type="checkbox"
  19. value={item._id}
  20. id={item._id}
  21. defaultChecked={specialityArray.find(el => el === item._id)}
  22. onChange={this.changeSpecialityArray}
  23. />
  24. <label htmlFor={item._id} className = "check"> {item.name}</label>
  25. </div>
  26. ))
  27. }
  28. </div>
  29. ))
  30. }
  31. </div>
  32. <div className = "wrap-check-off" onClick={changeFlag}></div>
  33. </>
  34. )
  35. }
  36. }
  37. export default CheckBoxWindow;