-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist.tsx
More file actions
65 lines (60 loc) · 2.56 KB
/
list.tsx
File metadata and controls
65 lines (60 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { useBackendAdminClient, useListQuery } from "@frontend/common/src/hooks/useAdminAPI";
import { CircularProgress, Stack, Table, TableBody, TableCell, TableHead, TableRow, Typography } from "@mui/material";
import { ErrorBoundary, Suspense } from "@suspensive/react";
import * as React from "react";
import { Link } from "react-router-dom";
import { BackendAdminSignInGuard } from "../../elements/admin_signin_guard";
import { ErrorFallback } from "../../elements/error_fallback";
type ListRowType = {
id: string;
status: "approved" | "rejected" | "requested" | "cancelled";
str_repr: string;
created_at: string;
updated_at: string;
};
const InnerAdminModificationAuditList: React.FC = ErrorBoundary.with(
{ fallback: ErrorFallback },
Suspense.with({ fallback: <CircularProgress /> }, () => {
const backendAdminClient = useBackendAdminClient();
const listQuery = useListQuery<ListRowType>(backendAdminClient, "modification-audit", "modification-audit");
return (
<Stack sx={{ flexGrow: 1, width: "100%", minHeight: "100%" }}>
<Typography variant="h5" children="수정 심사 목록" />
<br />
<Table>
<TableHead>
<TableRow>
<TableCell sx={{ width: "25%" }}>ID</TableCell>
<TableCell sx={{ width: "17.5%" }}>상태</TableCell>
<TableCell sx={{ width: "40%" }}>이름</TableCell>
<TableCell sx={{ width: "17.5%" }}>요청 시각</TableCell>
</TableRow>
</TableHead>
<TableBody>
{listQuery.data?.map((item) => {
const link = `/modification-audit/modification-audit/${item.id}`;
const isRequested = item.status === "requested";
return (
<TableRow key={item.id}>
<TableCell children={<Link to={link} children={item.id} />} />
<TableCell>
<Typography variant="body2" fontWeight={isRequested ? 700 : 400} color={isRequested ? "primary" : "textSecondary"}>
{item.status}
</Typography>
</TableCell>
<TableCell children={<Link to={link} children={item.str_repr} />} />
<TableCell>{new Date(item.created_at).toLocaleString()}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</Stack>
);
})
);
export const AdminModificationAuditList: React.FC = () => (
<BackendAdminSignInGuard>
<InnerAdminModificationAuditList />
</BackendAdminSignInGuard>
);