Feat: Migrate Hardcoded Strings

This commit is contained in:
Br0wnHammer committed 2025-03-12 00:56:28 +05:30
1 parent 6578d7e78a
commit 5df5cf3870
15 files changed
+231 -117

No files matched your search

@@ -13,6 +13,7 @@ import { useSelector } from "react-redux";
import { useState } from "react";
import useChecksFetch from "../../Hooks/useChecksFetch";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
const IncidentTable = ({
shouldRender,
@@ -38,6 +39,8 @@ const IncidentTable = ({
rowsPerPage,
});
const { t } = useTranslation();
//Handlers
const handleChangePage = (_, newPage) => {
setPage(newPage);
@@ -50,12 +53,12 @@ const IncidentTable = ({
const headers = [
{
id: "monitorName",
content: "Monitor Name",
content: t("incidentsTableMonitorName"),
render: (row) => monitors[row.monitorId]?.name ?? "N/A",
},
{
id: "status",
content: "Status",
content: t("incidentsTableStatus"),
render: (row) => {
const status = row.status === true ? "up" : "down";
return (
@@ -69,7 +72,7 @@ const IncidentTable = ({
},
{
id: "dateTime",
content: "Date & Time",
content: t("incidentsTableDateTime"),
render: (row) => {
const formattedDate = formatDateWithTz(
row.createdAt,
@@ -81,10 +84,10 @@ const IncidentTable = ({
},
{
id: "statusCode",
content: "Status Code",
content: t("incidentsTableStatusCode"),
render: (row) => <HttpStatusLabel status={row.statusCode} />,
},
{ id: "message", content: "Message", render: (row) => row.message },
{ id: "message", content: t("incidentsTableMessage"), render: (row) => row.message },
];
if (!shouldRender || isLoading) return <TableSkeleton />;
@@ -98,7 +101,7 @@ const IncidentTable = ({
}
if (!isLoading && typeof checksCount === "undefined") {
return <GenericFallback>No incidents recorded</GenericFallback>;
return <GenericFallback>{t("incidentsTableNoIncidents")}</GenericFallback>;
}
return (
@@ -108,7 +111,7 @@ const IncidentTable = ({
data={checks}
/>
<Pagination
paginationLabel="incidents"
paginationLabel={t("incidentsTablePaginationLabel")}
itemCount={checksCount}
page={page}
rowsPerPage={rowsPerPage}
@@ -6,6 +6,7 @@ import PropTypes from "prop-types";
//Utils
import { useTheme } from "@emotion/react";
import SkeletonLayout from "./skeleton";
import { useTranslation } from "react-i18next";
const OptionsHeader = ({
shouldRender,
@@ -18,6 +19,7 @@ const OptionsHeader = ({
setDateRange,
}) => {
const theme = useTheme();
const { t } = useTranslation();
const monitorNames = typeof monitors !== "undefined" ? Object.values(monitors) : [];
// The stacks below which are three in number have the same style so
@@ -40,11 +42,11 @@ const OptionsHeader = ({
component="h1"
color={theme.palette.primary.contrastTextSecondary}
>
Incidents for:
{t("incidentsOptionsHeader")}
</Typography>
<Select
id="incidents-select-monitor"
placeholder="All servers"
placeholder={t("incidentsOptionsPlaceholderAllServers")}
value={selectedMonitor}
onChange={(e) => setSelectedMonitor(e.target.value)}
items={monitorNames}
@@ -61,7 +63,7 @@ const OptionsHeader = ({
component="h1"
color={theme.palette.primary.contrastTextSecondary}
>
Filter by:
{t("incidentsOptionsHeaderFilterBy")}
</Typography>
<ButtonGroup>
<Button
@@ -69,21 +71,21 @@ const OptionsHeader = ({
filled={(filter === "all").toString()}
onClick={() => setFilter("all")}
>
All
{t("incidentsOptionsHeaderFilterAll")}
</Button>
<Button
variant="group"
filled={(filter === "down").toString()}
onClick={() => setFilter("down")}
>
Down
{t("incidentsOptionsHeaderFilterDown")}
</Button>
<Button
variant="group"
filled={(filter === "resolve").toString()}
onClick={() => setFilter("resolve")}
>
Cannot resolve
{t("incidentsOptionsHeaderFilterCannotResolve")}
</Button>
</ButtonGroup>
</Stack>
@@ -93,7 +95,7 @@ const OptionsHeader = ({
component="h1"
color={theme.palette.primary.contrastTextSecondary}
>
Show:
{t("incidentsOptionsHeaderShow")}
</Typography>
<ButtonGroup>
<Button
@@ -101,28 +103,28 @@ const OptionsHeader = ({
filled={(dateRange === "hour").toString()}
onClick={() => setDateRange("hour")}
>
Last hour
{t("incidentsOptionsHeaderLastHour")}
</Button>
<Button
variant="group"
filled={(dateRange === "day").toString()}
onClick={() => setDateRange("day")}
>
Last day
{t("incidentsOptionsHeaderLastDay")}
</Button>
<Button
variant="group"
filled={(dateRange === "week").toString()}
onClick={() => setDateRange("week")}
>
Last week
{t("incidentsOptionsHeaderLastWeek")}
</Button>
<Button
variant="group"
filled={(dateRange === "all").toString()}
onClick={() => setDateRange("all")}
>
All
{t("incidentsOptionsHeaderFilterAll")}
</Button>
</ButtonGroup>
</Stack>