commit042130f11cAuthor: Stian Aune <post@stian-aune.com> Date: Wed Apr 10 22:16:14 2019 +0200 Done? commit3089c6f8beAuthor: Stian Aune <post@stian-aune.com> Date: Wed Mar 27 22:20:07 2019 +0100 Bugfix + some unit tests bc why not? commit38f874b553Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 26 22:14:22 2019 +0100 Front page. commit5bdf2a0c48Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:10:57 2019 +0100 Rename groups and stuff. commit3130710b19Merge:118a21afa98a0bAuthor: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:16 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit118a21ad42Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:02 2019 +0100 I can a lot of things. commit089ee68169Merge:0a6cc16f27c0a3Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:41 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit0a6cc16e0fAuthor: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:31 2019 +0100 More stuff. commit1ef2623637Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:59:23 2019 +0100 Add/remove group. commit59240ce22dMerge:537e86ce11ba33Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:15:06 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit537e86ccedAuthor: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:55 2019 +0100 For reals. commitde5fb0d16dAuthor: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:30 2019 +0100 Modal cleanup + light page. commit01daa28000Author: Stian Aune <post@stian-aune.com> Date: Sun Feb 24 00:27:36 2019 +0100 Hmm... commitbe2fe56e62Merge:99867a522dddc7Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:07 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit99867a5fd6Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:02 2019 +0100 WIP. commitd82bbf53f8Author: Stian Aune <post@stian-aune.com> Date: Tue Feb 19 21:37:59 2019 +0100 WIP. commit7ed6d2148dAuthor: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 13:30:53 2019 +0100 Stuffs. commitee9a3d485eAuthor: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 12:29:47 2019 +0100 Bleurgh. commit59ef68ad8fAuthor: Stian Aune <post@stian-aune.com> Date: Thu Feb 7 21:15:37 2019 +0100 Thursday night commit. commitee3ff50342Merge:daf071ae644f48Author: Stian Aune <post@stian-aune.com> Date: Wed Feb 6 22:02:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commitdaf071a442Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:56:45 2019 +0100 Rewrote light tests. commitedffa49d18Merge:83052a28c302ecAuthor: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:26 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit83052a2ab8Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:22 2019 +0100 Blah. commitaec6cd0b7dMerge:e6fefb50503f79Author: Stian Aune <post@stian-aune.com> Date: Tue Jan 29 21:06:24 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commite6fefb5bd1Merge:97f7a78eca8a30Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 28 22:44:19 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit97f7a78f3fMerge:195738d174b818Author: Stian Aune <post@stian-aune.com> Date: Sun Jan 13 13:20:10 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit195738d6edMerge:a2f2c2b2e3e120Author: Stian Aune <post@stian-aune.com> Date: Sat Jan 12 17:24:00 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commita2f2c2b0bcMerge:edd629e9004f2fAuthor: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commitedd629eb39Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:32 2019 +0100 More stuff. commit206d5005dbAuthor: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 19:11:03 2019 +0100 Cleanup.
95 lines
2.7 KiB
React
95 lines
2.7 KiB
React
import React, {useState} from "react";
|
|
import {Button, Col, Form, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader} from "reactstrap";
|
|
import useBridges from "../../Hooks/bridge";
|
|
import Loading from "../Loading";
|
|
|
|
function BridgeModal({onCancel, bridge = null}) {
|
|
const {addBridge, editBridge} = useBridges();
|
|
|
|
const edit = bridge !== null;
|
|
|
|
const [name, setName] = useState(edit ? bridge.name : "");
|
|
const [driver, setDriver] = useState(edit ? bridge.driver : "");
|
|
const [addr, setAddr] = useState(edit ? bridge.addr : "");
|
|
|
|
const [waiting, setWaiting] = useState(false);
|
|
|
|
function onConfirm() {
|
|
if (edit) {
|
|
editBridge(bridge.id, name);
|
|
} else {
|
|
setWaiting(true);
|
|
addBridge(name, driver, addr, (result) => {
|
|
if (!result) {
|
|
alert("Noe gikk galt");
|
|
}
|
|
|
|
setWaiting(false);
|
|
onCancel();
|
|
});
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Modal isOpen={true}>
|
|
<ModalHeader>{edit ? "Bruegenskaper" : "Ny bru"}</ModalHeader>
|
|
<ModalBody>
|
|
{waiting ? (
|
|
<Loading/>
|
|
) : (
|
|
<Form>
|
|
<FormGroup row>
|
|
<Label sm={3} for="text-name">
|
|
Navn:
|
|
</Label>
|
|
<Col sm={9}>
|
|
<Input type="text"
|
|
id="text-name"
|
|
name="name"
|
|
value={name}
|
|
onChange={e => setName(e.target.value)}
|
|
/>
|
|
</Col>
|
|
</FormGroup>
|
|
<FormGroup row>
|
|
<Label sm={3} for="text-driver">
|
|
Driver:
|
|
</Label>
|
|
<Col sm={9}>
|
|
<Input type="text"
|
|
id="text-driver"
|
|
name="driver"
|
|
value={driver}
|
|
onChange={e => setDriver(e.target.value)}
|
|
disabled={edit}
|
|
/>
|
|
</Col>
|
|
</FormGroup>
|
|
<FormGroup row>
|
|
<Label sm={3} for="text-name">
|
|
Adresse:
|
|
</Label>
|
|
<Col sm={9}>
|
|
<Input type="text"
|
|
id="text-addr"
|
|
name="addr"
|
|
value={addr}
|
|
onChange={e => setAddr(e.target.value)}
|
|
disabled={edit}
|
|
/>
|
|
</Col>
|
|
</FormGroup>
|
|
</Form>
|
|
)}
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button color="primary" disabled={waiting} onClick={onConfirm}>Bekreft</Button>
|
|
{" "}
|
|
<Button color="secondary" disabled={waiting} onClick={onCancel}>Avbryt</Button>
|
|
</ModalFooter>
|
|
</Modal>
|
|
);
|
|
}
|
|
|
|
export default BridgeModal;
|