Files
hetty/admin/src/features/reqlog/components/LogDetail.tsx

60 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-02-23 15:20:23 +01:00
import Alert from "@mui/lab/Alert";
2022-01-28 20:20:15 +01:00
import { Box, Grid, Paper, CircularProgress } from "@mui/material";
import RequestDetail from "./RequestDetail";
2022-02-23 15:20:23 +01:00
import ResponseDetail from "./ResponseDetail";
2022-02-23 15:20:23 +01:00
import { useHttpRequestLogQuery } from "lib/graphql/generated";
interface Props {
2022-01-21 11:45:54 +01:00
requestId: string;
}
function LogDetail({ requestId: id }: Props): JSX.Element {
2022-02-23 15:20:23 +01:00
const { loading, error, data } = useHttpRequestLogQuery({
variables: { id },
});
2020-09-23 18:10:32 +02:00
if (loading) {
return <CircularProgress />;
}
if (error) {
2022-01-28 20:20:15 +01:00
return <Alert severity="error">Error fetching logs details: {error.message}</Alert>;
2020-09-23 18:10:32 +02:00
}
2022-02-23 15:20:23 +01:00
if (data && !data.httpRequestLog) {
2020-09-23 23:43:20 +02:00
return (
<Alert severity="warning">
Request <strong>{id}</strong> was not found.
</Alert>
);
}
2022-02-23 15:20:23 +01:00
if (!data?.httpRequestLog) {
return <div></div>;
}
const httpRequestLog = data.httpRequestLog;
return (
<div>
<Grid container item spacing={2}>
<Grid item xs={6}>
<Box component={Paper}>
2022-02-23 15:20:23 +01:00
<RequestDetail request={httpRequestLog} />
</Box>
</Grid>
<Grid item xs={6}>
2022-02-23 15:20:23 +01:00
{httpRequestLog.response && (
<Box component={Paper}>
2022-02-23 15:20:23 +01:00
<ResponseDetail response={httpRequestLog.response} />
</Box>
)}
</Grid>
</Grid>
</div>
);
}
export default LogDetail;