|
@ -3,10 +3,17 @@ import {Button, Card, CardBody, CardFooter, CardHeader, ListGroup} from "reactst |
|
|
import useLights from "../Hooks/light"; |
|
|
import useLights from "../Hooks/light"; |
|
|
import Light from "./Light"; |
|
|
import Light from "./Light"; |
|
|
import Loading from "./Loading"; |
|
|
import Loading from "./Loading"; |
|
|
|
|
|
import {deleteGroup} from "../Helpers/groups"; |
|
|
|
|
|
|
|
|
function Group({id, name}) { |
|
|
function Group({id, name}) { |
|
|
const lights = useLights({groupId: id}); |
|
|
const lights = useLights({groupId: id}); |
|
|
|
|
|
|
|
|
|
|
|
function onDelete() { |
|
|
|
|
|
if (window.confirm(`Vil du virkelig fjerne "${name}"?`)) { |
|
|
|
|
|
deleteGroup(id); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Card className="mt-3"> |
|
|
<Card className="mt-3"> |
|
|
<CardHeader>{name}</CardHeader> |
|
|
<CardHeader>{name}</CardHeader> |
|
@ -20,7 +27,7 @@ function Group({id, name}) { |
|
|
{" "} |
|
|
{" "} |
|
|
<Button color="secondary">Skift farger</Button> |
|
|
<Button color="secondary">Skift farger</Button> |
|
|
{" "} |
|
|
{" "} |
|
|
{id > 0 && <Button color="danger">Fjern</Button>} |
|
|
|
|
|
|
|
|
{id > 0 && <Button color="danger" onClick={onDelete}>Fjern</Button>} |
|
|
</CardFooter> |
|
|
</CardFooter> |
|
|
</Card> |
|
|
</Card> |
|
|
); |
|
|
); |
|
|