diff --git a/src/App.tsx b/src/App.tsx index 2b3744b..ea1ed0b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import Footer from "./components/Footer"; import Server from "./pages/Server"; import ServerDetail from "./pages/ServerDetail"; import NotFound from "./pages/NotFound"; +import ErrorPage from "./pages/ErrorPage"; const App: React.FC = () => { return ( @@ -15,6 +16,7 @@ const App: React.FC = () => { } /> } /> + } /> } /> diff --git a/src/components/CycleTransferStats.tsx b/src/components/CycleTransferStats.tsx index 856d2d0..c70f3e5 100644 --- a/src/components/CycleTransferStats.tsx +++ b/src/components/CycleTransferStats.tsx @@ -14,14 +14,20 @@ export const CycleTransferStatsCard: React.FC = ({ return ( {Object.entries(cycleStats).map(([cycleId, cycleData]) => { - const serverStats = Object.entries(cycleData.server_name).map( - ([serverId, serverName]) => ({ - serverId, - serverName, - transfer: cycleData.transfer[serverId] || 0, - nextUpdate: cycleData.next_update[serverId], - }), - ); + const serverStats = cycleData.server_name + ? Object.entries(cycleData.server_name).map( + ([serverId, serverName]) => ({ + serverId, + serverName, + transfer: cycleData.transfer?.[serverId] || 0, + nextUpdate: cycleData.next_update?.[serverId], + }) + ) + : []; + + if (serverStats.length === 0) { + return null; + } return ( { /> )} - {serviceData.data.services && ( + {serviceData.data.services && Object.keys(serviceData.data.services).length > 0 && ( {Object.entries(serviceData.data.services).map(([name, data]) => { const { days, uptime, avgDelay } = processServiceData(data); diff --git a/src/pages/ErrorPage.tsx b/src/pages/ErrorPage.tsx new file mode 100644 index 0000000..346d65e --- /dev/null +++ b/src/pages/ErrorPage.tsx @@ -0,0 +1,32 @@ +import { Button } from "@/components/ui/button"; +import { useNavigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; + +interface ErrorPageProps { + code?: string | number; + message?: string; +} + +export default function ErrorPage({ code = "500", message }: ErrorPageProps) { + const navigate = useNavigate(); + const { t } = useTranslation(); + + return ( + + + {code} + + {message || t("error.somethingWentWrong")} + + + window.location.reload()} variant="outline"> + {t("error.tryAgain")} + + navigate("/")} className="mt-2"> + {t("error.backToHome")} + + + + + ); +}
+ {message || t("error.somethingWentWrong")} +