Files
Checkmate/client/src/pages/diagnostic/DiagnosticsConfigTab.tsx
T

77 lines
2.4 KiB
TypeScript
Raw Normal View History

2025-12-13 23:12:02 +00:00
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Divider from "@mui/material/Divider";
import Box from "@mui/material/Box";
import { useTheme } from "@mui/material/styles";
2025-12-13 22:04:32 +00:00
import { useGet } from "@/hooks/UseApi";
2025-12-13 23:12:02 +00:00
import { StatBox } from "@/components/design-elements";
import { config as clientConfig } from "@/config";
2025-12-13 22:04:32 +00:00
type EnvConfig = {
NODE_ENV: string;
DEPLOYMENT_MODE: string;
LOG_LEVEL: string;
ORIGIN: string;
JWT_SECRET: string;
PORT: number;
PAGESPEED_API_KEY: string;
SMTP_HOST: string;
SMTP_PORT: number;
SMTP_USER: string;
SMTP_PASS: string;
STRIPE_SECRET: string;
STRIPE_WEBHOOK_SECRET: string;
};
export default function DiagnosticsConfigTab() {
2025-12-13 23:12:02 +00:00
const theme = useTheme();
2025-12-13 22:04:32 +00:00
const { response, loading, error } = useGet<{
message: string;
data: EnvConfig;
2025-12-13 23:12:02 +00:00
}>("/diagnostic/env", {}, { refreshInterval: clientConfig.GLOBAL_REFRESH });
2025-12-13 22:04:32 +00:00
const data = response?.data;
2025-12-13 23:12:02 +00:00
const clientEntries = Object.entries(clientConfig as Record<string, any>);
if (!data && !loading && !error) return null;
const totalKeys = data ? Object.keys(data).length : 0;
2025-12-13 22:04:32 +00:00
return (
2025-12-13 23:12:02 +00:00
<Stack spacing={theme.spacing(8)}>
2025-12-13 22:04:32 +00:00
{data && (
2025-12-13 23:12:02 +00:00
<Stack spacing={theme.spacing(3)}>
<Typography variant="h1">Server environment</Typography>
2025-12-13 22:04:32 +00:00
<Stack divider={<Divider />}>
{Object.entries(data).map(([key, value]) => (
<Box key={key} px={2} py={1.5} display="flex" gap={2}>
<Typography sx={{ minWidth: 220 }} color="text.secondary">
{key}
</Typography>
<Typography sx={{ wordBreak: "break-all" }}>
{String(value)}
</Typography>
</Box>
))}
</Stack>
2025-12-13 23:12:02 +00:00
</Stack>
2025-12-13 22:04:32 +00:00
)}
2025-12-13 23:12:02 +00:00
<Stack spacing={theme.spacing(3)}>
<Typography variant="h1">Client runtime config</Typography>
<Stack divider={<Divider />}>
{clientEntries.map(([key, value]) => (
<Box key={key} px={2} py={1.5} display="flex" gap={2}>
<Typography sx={{ minWidth: 220 }} color="text.secondary">
{key}
</Typography>
<Typography sx={{ wordBreak: "break-all" }}>
{String(value)}
</Typography>
</Box>
))}
</Stack>
</Stack>
</Stack>
2025-12-13 22:04:32 +00:00
);
}