Display a message if relays list is empty

This commit is contained in:
Pierre HUBERT 2024-10-12 15:24:40 +02:00
parent e244fff700
commit 2f8b8aa59f

View File

@ -9,15 +9,16 @@ import {
TableHead, TableHead,
TableRow, TableRow,
Tooltip, Tooltip,
Typography,
} from "@mui/material"; } from "@mui/material";
import React from "react"; import React from "react";
import { useNavigate } from "react-router-dom";
import { Device, DeviceApi, DeviceRelay, DeviceURL } from "../api/DeviceApi"; import { Device, DeviceApi, DeviceRelay, DeviceURL } from "../api/DeviceApi";
import { RelayApi, RelaysStatus } from "../api/RelayApi"; import { RelayApi, RelaysStatus } from "../api/RelayApi";
import { AsyncWidget } from "../widgets/AsyncWidget"; import { AsyncWidget } from "../widgets/AsyncWidget";
import { BoolText } from "../widgets/BoolText"; import { BoolText } from "../widgets/BoolText";
import { SolarEnergyRouteContainer } from "../widgets/SolarEnergyRouteContainer"; import { SolarEnergyRouteContainer } from "../widgets/SolarEnergyRouteContainer";
import { TimeWidget } from "../widgets/TimeWidget"; import { TimeWidget } from "../widgets/TimeWidget";
import { useNavigate } from "react-router-dom";
export function RelaysListRoute(p: { export function RelaysListRoute(p: {
homeWidget?: boolean; homeWidget?: boolean;
@ -86,6 +87,10 @@ function RelaysList(p: {
navigate(DeviceURL(dev!)); navigate(DeviceURL(dev!));
}; };
if (p.list.length === 0) {
return <Typography>There is no configured relay yet!</Typography>;
}
return ( return (
<TableContainer component={Paper}> <TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }}> <Table sx={{ minWidth: 650 }}>