Files
Checkmate/Client/src/Pages/Status/index.jsx
T

73 lines
1.8 KiB
React
Raw Normal View History

2024-08-27 20:11:59 -04:00
import { useTheme } from "@emotion/react";
2024-07-22 16:35:57 -04:00
import Fallback from "../../Components/Fallback";
import { Box, Button, Stack } from "@mui/material";
import { useNavigate } from "react-router-dom";
2024-12-16 20:18:05 -05:00
import CreateStatus from "./CreateStatus";
import { useEffect } from "react";
import { networkService } from "../../main";
import { useSelector } from "react-redux";
const Status = () => {
const theme = useTheme();
2024-12-16 20:18:05 -05:00
const navigate = useNavigate();
const {authToken} = useSelector((state) => state.auth);
const {apiBaseUrl} = useSelector((state) => state.settings);
let initForm = {}
useEffect(() => {
const getStatusPage = async () => {
let config = { authToken: authToken, url: apiBaseUrl };
initForm = await networkService.getStatusPageByUrl(config);
};
getStatusPage();
}, []);
return (
2024-12-16 20:18:05 -05:00
<>
{Object.keys(initForm).length===0? (
<Box
className="status"
sx={{
':has(> [class*="fallback__"])': {
position: "relative",
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
borderStyle: "dashed",
backgroundColor: theme.palette.background.main,
overflow: "hidden",
},
}}
>
2024-12-16 20:18:05 -05:00
<Fallback
title="status page"
checks={[
"Share your uptime publicly",
"Keep your users informed about incidents",
"Build trust with your customers",
]}
/>
<Stack
alignItems="center"
mt={theme.spacing(10)}
>
<Button
variant="contained"
color="primary"
onClick={() => {
navigate("/status/create");
}}
sx={{ fontWeight: 500 }}
>
Let's create your status page
</Button>
</Stack>
</Box>
) : (
<CreateStatus initForm={initForm}/>
)}
</>
);
};
export default Status;