new status pages
This commit is contained in:
1 parent
57c3bf3240
commit
853e21623e
6 files changed
+230
-2
No files matched your search
@@ -0,0 +1,109 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { Table, type Header, ValueLabel } from "@/Components/v2/design-elements";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import type { StatusPage } from "@/Types/StatusPage";
|
||||
|
||||
interface StatusPagesTableProps {
|
||||
data: StatusPage[];
|
||||
}
|
||||
|
||||
export const StatusPagesTable = ({ data }: StatusPagesTableProps) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleUrlClick = (e: React.MouseEvent, row: StatusPage) => {
|
||||
if (row.isPublished) {
|
||||
e.stopPropagation();
|
||||
const url = `/status/uptime/public/${row.url}`;
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
};
|
||||
|
||||
const getHeaders = (): Header<StatusPage>[] => {
|
||||
return [
|
||||
{
|
||||
id: "name",
|
||||
content: t("pages.statusPages.table.headers.name"),
|
||||
render: (row) => row.companyName,
|
||||
},
|
||||
{
|
||||
id: "url",
|
||||
content: t("pages.statusPages.table.headers.url"),
|
||||
render: (row) => {
|
||||
const content = row.isPublished
|
||||
? `/${row.url}`
|
||||
: t("pages.statusPages.table.unpublished");
|
||||
return (
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
gap={theme.spacing(2)}
|
||||
paddingLeft={theme.spacing(2)}
|
||||
paddingRight={theme.spacing(2)}
|
||||
onClick={(e) => handleUrlClick(e, row)}
|
||||
sx={{
|
||||
...(row.isPublished && {
|
||||
display: "inline-flex",
|
||||
":hover": {
|
||||
cursor: "pointer",
|
||||
borderBottom: 1,
|
||||
},
|
||||
}),
|
||||
}}
|
||||
>
|
||||
<Typography>{content}</Typography>
|
||||
{row.isPublished && <ExternalLink size={18} />}
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "type",
|
||||
content: t("common.table.headers.type"),
|
||||
render: (row) => row.type,
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
content: t("common.table.headers.status"),
|
||||
render: (row) => {
|
||||
return (
|
||||
<ValueLabel
|
||||
value={row.isPublished ? "positive" : "neutral"}
|
||||
text={
|
||||
row.isPublished
|
||||
? t("pages.statusPages.table.published")
|
||||
: t("pages.statusPages.table.unpublished")
|
||||
}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const handleRowClick = (statusPage: StatusPage) => {
|
||||
navigate(`/status/uptime/${statusPage.url}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Table
|
||||
headers={getHeaders()}
|
||||
data={data}
|
||||
onRowClick={handleRowClick}
|
||||
emptyViewText={t("common.table.empty")}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatusPagesTable;
|
||||
@@ -0,0 +1,33 @@
|
||||
import { BasePageWithStates } from "@/Components/v2/design-elements";
|
||||
import { StatusPagesTable } from "./Components/StatusPagesTable";
|
||||
import { useGet } from "@/Hooks/UseApi";
|
||||
import type { StatusPage } from "@/Types/StatusPage";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const StatusPages = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
data: statusPages,
|
||||
isLoading,
|
||||
error,
|
||||
} = useGet<StatusPage[]>("/status-page/team");
|
||||
|
||||
return (
|
||||
<BasePageWithStates
|
||||
page={t("pages.statusPages.title")}
|
||||
loading={isLoading}
|
||||
bullets={
|
||||
t("pages.statusPages.fallback.checks", { returnObjects: true }) as string[]
|
||||
}
|
||||
error={!!error}
|
||||
items={statusPages ?? []}
|
||||
actionButtonText={t("pages.statusPages.fallback.actionButton")}
|
||||
actionLink="/status/uptime/create"
|
||||
>
|
||||
<StatusPagesTable data={statusPages ?? []} />
|
||||
</BasePageWithStates>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatusPages;
|
||||
File renamed without changes.
Reference in new issue
Block a user