Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import React, { useState } from "react";
  2. import ReactDOM from "react-dom";
  3.  
  4. import Switch from "@material-ui/core/Switch";
  5.  
  6. import "./styles.css";
  7.  
  8. function App(props) {
  9. const initialFormState = {
  10. datRev: "01/05/2019",
  11. empRev: "1",
  12. numCad: "5",
  13. numEmp: "1",
  14. obsRev: "ReactJS done!",
  15. sitRev: "1",
  16. tipCol: "1",
  17. tipEqp: "10",
  18. tipSvc: "100",
  19. cheklist: {
  20. "": "",
  21. "": "",
  22. "": "",
  23. "": ""
  24. },
  25.  
  26. codCkl: "4",
  27. sitCkl: "N",
  28. selPro: "S",
  29. obsCkl: "obs insomina"
  30. };
  31.  
  32. const [equipRev, setEquipRevisao] = useState(initialFormState);
  33. const [checkedA, setCheckedA] = useState(false);
  34.  
  35. const handleChange = nameChecked => event => {
  36. const { name, value } = event.target;
  37.  
  38. setCheckedA({ [nameChecked]: event.target.checked });
  39.  
  40. if (event.target.checked === true) {
  41. console.log("True: " + event.target.checked);
  42. const value = "S";
  43. } else {
  44. console.log("False: " + event.target.checked);
  45. const value = "N";
  46. }
  47.  
  48. console.log("Value: " + value);
  49. setEquipRevisao({ ...equipRev, [name]: value });
  50.  
  51. console.log("sitCkl: " + equipRev.sitCkl);
  52. };
  53.  
  54. return (
  55. <div className="App">
  56. <h1>Hello CodeSandbox</h1>
  57. <h2>Start editing to see some magic happen!</h2>
  58.  
  59. <Switch
  60. name="sitCkl"
  61. checked={props.checkedA}
  62. onChange={handleChange("checkedA")}
  63. value={equipRev.sitCkl}
  64. />
  65. </div>
  66. );
  67. }
  68.  
  69. const rootElement = document.getElementById("root");
  70. ReactDOM.render(<App />, rootElement);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement