Use timezones for incidents table
This commit is contained in:
1 parent
40cb5ba189
commit
30cb62a93b
1 file changed
+12
-3
@@ -21,7 +21,15 @@ import { networkService } from "../../../main";
|
|||||||
import { StatusLabel } from "../../../Components/Label";
|
import { StatusLabel } from "../../../Components/Label";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import utc from "dayjs/plugin/utc";
|
||||||
|
import timezone from "dayjs/plugin/timezone";
|
||||||
|
|
||||||
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
||||||
|
dayjs.extend(utc);
|
||||||
|
dayjs.extend(timezone);
|
||||||
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { authToken, user } = useSelector((state) => state.auth);
|
||||||
const [checks, setChecks] = useState([]);
|
const [checks, setChecks] = useState([]);
|
||||||
@@ -151,6 +159,9 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
<TableBody>
|
<TableBody>
|
||||||
{checks.map((check) => {
|
{checks.map((check) => {
|
||||||
const status = check.status === true ? "up" : "down";
|
const status = check.status === true ? "up" : "down";
|
||||||
|
const formattedDate = dayjs(check.createdAt)
|
||||||
|
.tz(uiTimezone)
|
||||||
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={check._id}>
|
<TableRow key={check._id}>
|
||||||
@@ -162,9 +173,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
customStyles={{ textTransform: "capitalize" }}
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>{formattedDate}</TableCell>
|
||||||
{new Date(check.createdAt).toLocaleString()}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{check.statusCode ? check.statusCode : "N/A"}
|
{check.statusCode ? check.statusCode : "N/A"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
Reference in new issue
Block a user