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