Files
lucifer/webui/src/Components/Modals/BridgeModal.jsx
T
Stian Aune 511ac51c2b Squashed commit of the following:
commit 042130f11c
Author: Stian Aune <post@stian-aune.com>
Date:   Wed Apr 10 22:16:14 2019 +0200

    Done?

commit 3089c6f8be
Author: Stian Aune <post@stian-aune.com>
Date:   Wed Mar 27 22:20:07 2019 +0100

    Bugfix + some unit tests bc why not?

commit 38f874b553
Author: Stian Aune <post@stian-aune.com>
Date:   Tue Mar 26 22:14:22 2019 +0100

    Front page.

commit 5bdf2a0c48
Author: Stian Aune <post@stian-aune.com>
Date:   Thu Mar 7 21:10:57 2019 +0100

    Rename groups and stuff.

commit 3130710b19
Merge: 118a21a fa98a0b
Author: Stian Aune <post@stian-aune.com>
Date:   Thu Mar 7 21:06:16 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 118a21ad42
Author: Stian Aune <post@stian-aune.com>
Date:   Thu Mar 7 21:06:02 2019 +0100

    I can a lot of things.

commit 089ee68169
Merge: 0a6cc16 f27c0a3
Author: Stian Aune <post@stian-aune.com>
Date:   Tue Mar 5 22:13:41 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 0a6cc16e0f
Author: Stian Aune <post@stian-aune.com>
Date:   Tue Mar 5 22:13:31 2019 +0100

    More stuff.

commit 1ef2623637
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Mar 3 21:59:23 2019 +0100

    Add/remove group.

commit 59240ce22d
Merge: 537e86c e11ba33
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Mar 3 21:15:06 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 537e86cced
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Mar 3 21:14:55 2019 +0100

    For reals.

commit de5fb0d16d
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Mar 3 21:14:30 2019 +0100

    Modal cleanup + light page.

commit 01daa28000
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Feb 24 00:27:36 2019 +0100

    Hmm...

commit be2fe56e62
Merge: 99867a5 22dddc7
Author: Stian Aune <post@stian-aune.com>
Date:   Sat Feb 23 15:16:07 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 99867a5fd6
Author: Stian Aune <post@stian-aune.com>
Date:   Sat Feb 23 15:16:02 2019 +0100

    WIP.

commit d82bbf53f8
Author: Stian Aune <post@stian-aune.com>
Date:   Tue Feb 19 21:37:59 2019 +0100

    WIP.

commit 7ed6d2148d
Author: Stian Aune <mail@stian-aune.com>
Date:   Sun Feb 10 13:30:53 2019 +0100

    Stuffs.

commit ee9a3d485e
Author: Stian Aune <mail@stian-aune.com>
Date:   Sun Feb 10 12:29:47 2019 +0100

    Bleurgh.

commit 59ef68ad8f
Author: Stian Aune <post@stian-aune.com>
Date:   Thu Feb 7 21:15:37 2019 +0100

    Thursday night commit.

commit ee3ff50342
Merge: daf071a e644f48
Author: Stian Aune <post@stian-aune.com>
Date:   Wed Feb 6 22:02:37 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit daf071a442
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Feb 4 20:56:45 2019 +0100

    Rewrote light tests.

commit edffa49d18
Merge: 83052a2 8c302ec
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Feb 4 20:31:26 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 83052a2ab8
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Feb 4 20:31:22 2019 +0100

    Blah.

commit aec6cd0b7d
Merge: e6fefb5 0503f79
Author: Stian Aune <post@stian-aune.com>
Date:   Tue Jan 29 21:06:24 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit e6fefb5bd1
Merge: 97f7a78 eca8a30
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Jan 28 22:44:19 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 97f7a78f3f
Merge: 195738d 174b818
Author: Stian Aune <post@stian-aune.com>
Date:   Sun Jan 13 13:20:10 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit 195738d6ed
Merge: a2f2c2b 2e3e120
Author: Stian Aune <post@stian-aune.com>
Date:   Sat Jan 12 17:24:00 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit a2f2c2b0bc
Merge: edd629e 9004f2f
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Jan 7 20:58:37 2019 +0100

    Merge remote-tracking branch 'origin/master' into webui

commit edd629eb39
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Jan 7 20:58:32 2019 +0100

    More stuff.

commit 206d5005db
Author: Stian Aune <post@stian-aune.com>
Date:   Mon Jan 7 19:11:03 2019 +0100

    Cleanup.
2019-04-10 22:16:51 +02:00

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;