The main server, and probably only repository in this org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import React, {useState} from "react";
  2. import {Button, Col, Form, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader} from "reactstrap";
  3. import useGroups from "../../Hooks/group";
  4. import Loading from "../Loading";
  5. import {changeLight} from "../../Helpers/lights";
  6. function LightPropertiesModal({id, gValue, nValue, onClose}) {
  7. const [groupId, setGroupId] = useState(gValue);
  8. const [name, setName] = useState(nValue);
  9. const groups = useGroups();
  10. if (groups === null) {
  11. return <Modal isOpen={true}><Loading/></Modal>;
  12. }
  13. return (
  14. <Modal isOpen={true}>
  15. <ModalHeader>Lysegenskaper</ModalHeader>
  16. <ModalBody style={{margin: "0 auto"}}>
  17. <Form>
  18. <FormGroup row>
  19. <Label sm={3} for="text-name">
  20. Navn:
  21. </Label>
  22. <Col sm={9}>
  23. <Input type="text"
  24. id="text-name"
  25. value={name}
  26. onChange={e => setName(e.target.value)}
  27. />
  28. </Col>
  29. </FormGroup>
  30. </Form>
  31. <Form>
  32. <FormGroup row>
  33. <Label sm={3} for="sel-group">
  34. Gruppe:
  35. </Label>
  36. <Col sm={9}>
  37. <Input type="select"
  38. value={groupId}
  39. onChange={e => setGroupId(parseInt(e.target.value, 10))}>
  40. {groups.map(g => <option value={g.id}>{g.name}</option>)}
  41. </Input>
  42. </Col>
  43. </FormGroup>
  44. </Form>
  45. </ModalBody>
  46. <ModalFooter>
  47. <Button color="primary"
  48. onClick={() => {
  49. changeLight(id, name, groupId);
  50. onClose();
  51. }}
  52. >
  53. Lagre
  54. </Button>
  55. {" "}
  56. <Button color="secondary" onClick={onClose}>Avbryt</Button>
  57. </ModalFooter>
  58. </Modal>
  59. );
  60. }
  61. export default LightPropertiesModal;