Skip to content

Commit de46715

Browse files
committed
feat: 어드민에 수정 심사 반려 사유 기능 추가
1 parent f0e1433 commit de46715

File tree

3 files changed

+64
-35
lines changed

3 files changed

+64
-35
lines changed

apps/pyconkr-admin/src/components/pages/modification_audit/components.tsx

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
Typography,
1717
} from "@mui/material";
1818
import * as React from "react";
19+
import * as R from "remeda";
1920

2021
type SharedPreviewFieldProps = {
2122
originalDataset: Record<string, unknown>;
@@ -164,33 +165,55 @@ type SimplifiedModificationAudit = {
164165
created_at: string;
165166
created_by: string;
166167
status: string;
168+
comments?: {
169+
content: string;
170+
created_by: { is_superuser: boolean; nickname: string };
171+
}[];
167172
};
168173

169-
export const ModificationAuditProperties: React.FC<{ audit: SimplifiedModificationAudit }> = ({ audit }) => (
170-
<Table>
171-
<TableHead>
172-
<TableRow>
173-
<TableCell>속성</TableCell>
174-
<TableCell></TableCell>
175-
</TableRow>
176-
</TableHead>
177-
<TableBody>
178-
<TableRow>
179-
<TableCell>심사 ID</TableCell>
180-
<TableCell>{audit.id}</TableCell>
181-
</TableRow>
182-
<TableRow>
183-
<TableCell>심사 요청 시간</TableCell>
184-
<TableCell>{new Date(audit.created_at).toLocaleString()}</TableCell>
185-
</TableRow>
186-
<TableRow>
187-
<TableCell>심사 요청자</TableCell>
188-
<TableCell>{audit.created_by}</TableCell>
189-
</TableRow>
190-
<TableRow>
191-
<TableCell>심사 상태</TableCell>
192-
<TableCell>{audit.status}</TableCell>
193-
</TableRow>
194-
</TableBody>
195-
</Table>
196-
);
174+
export const ModificationAuditProperties: React.FC<{ audit: SimplifiedModificationAudit }> = ({ audit }) => {
175+
let rejectReason: React.ReactNode = null;
176+
if (R.isArray(audit.comments) && !R.isEmpty(audit.comments.filter((c) => c.created_by.is_superuser))) {
177+
const comment = audit.comments.filter((c) => c.created_by.is_superuser)[0];
178+
rejectReason = (
179+
<>
180+
<TableRow>
181+
<TableCell>반려 사유</TableCell>
182+
<TableCell>
183+
<pre style={{ whiteSpace: "pre-wrap" }}>{comment.content}</pre>(by {comment.created_by.nickname})
184+
</TableCell>
185+
</TableRow>
186+
</>
187+
);
188+
}
189+
190+
return (
191+
<Table>
192+
<TableHead>
193+
<TableRow>
194+
<TableCell>속성</TableCell>
195+
<TableCell></TableCell>
196+
</TableRow>
197+
</TableHead>
198+
<TableBody>
199+
<TableRow>
200+
<TableCell>심사 ID</TableCell>
201+
<TableCell>{audit.id}</TableCell>
202+
</TableRow>
203+
<TableRow>
204+
<TableCell>심사 요청 시간</TableCell>
205+
<TableCell>{new Date(audit.created_at).toLocaleString()}</TableCell>
206+
</TableRow>
207+
<TableRow>
208+
<TableCell>심사 요청자</TableCell>
209+
<TableCell>{audit.created_by}</TableCell>
210+
</TableRow>
211+
<TableRow>
212+
<TableCell>심사 상태</TableCell>
213+
<TableCell>{audit.status}</TableCell>
214+
</TableRow>
215+
{rejectReason}
216+
</TableBody>
217+
</Table>
218+
);
219+
};

apps/pyconkr-admin/src/components/pages/modification_audit/dialogs.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Common from "@frontend/common";
2-
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@mui/material";
2+
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, Typography } from "@mui/material";
33
import { enqueueSnackbar, OptionsObject } from "notistack";
44
import * as React from "react";
55

@@ -42,22 +42,25 @@ export const ApproveSubmitConfirmDialog: React.FC<SubmitConfirmDialogProps> = ({
4242
</Typography>
4343
</DialogContent>
4444
<DialogActions>
45-
<Button onClick={onClose} color="error" children="취소" />
46-
<Button onClick={onApproveClick} color="primary" variant="contained" children="승인" />
45+
<Button loading={approveModificationAuditMutation.isPending} onClick={onClose} color="error" children="취소" />
46+
<Button loading={approveModificationAuditMutation.isPending} onClick={onApproveClick} color="primary" variant="contained" children="승인" />
4747
</DialogActions>
4848
</Dialog>
4949
);
5050
};
5151

5252
export const RejectSubmitConfirmDialog: React.FC<SubmitConfirmDialogProps> = ({ open, onClose, modificationAuditId }) => {
53+
const inputRef = React.useRef<HTMLInputElement>(null);
5354
const backendAdminClient = Common.Hooks.BackendAdminAPI.useBackendAdminClient();
5455
const rejectModificationAuditMutation = Common.Hooks.BackendAdminAPI.useRejectModificationAuditMutation(backendAdminClient, modificationAuditId);
5556

5657
const addSnackbar = (c: string | React.ReactNode, variant: OptionsObject["variant"]) =>
5758
enqueueSnackbar(c, { variant, anchorOrigin: { vertical: "bottom", horizontal: "center" } });
5859

5960
const onRejectClick = () => {
60-
rejectModificationAuditMutation.mutate(undefined, {
61+
if (!inputRef.current) return;
62+
63+
rejectModificationAuditMutation.mutate(inputRef.current.value.trim(), {
6164
onSuccess: () => {
6265
addSnackbar("수정 심사가 반려되었습니다.", "success");
6366
onClose();
@@ -80,10 +83,13 @@ export const RejectSubmitConfirmDialog: React.FC<SubmitConfirmDialogProps> = ({
8083
<br />
8184
반려 후에는 다시 승인할 수 없습니다!
8285
</Typography>
86+
<Common.Components.Fieldset legend="반려 사유 (선택)">
87+
<TextField fullWidth multiline minRows={4} inputRef={inputRef} label="반려 사유" />
88+
</Common.Components.Fieldset>
8389
</DialogContent>
8490
<DialogActions>
85-
<Button onClick={onClose} color="error" children="취소" />
86-
<Button onClick={onRejectClick} color="primary" variant="contained" children="반려" />
91+
<Button loading={rejectModificationAuditMutation.isPending} onClick={onClose} color="error" children="취소" />
92+
<Button loading={rejectModificationAuditMutation.isPending} onClick={onRejectClick} color="primary" variant="contained" children="반려" />
8793
</DialogActions>
8894
</Dialog>
8995
);

apps/pyconkr-participant-portal/src/components/pages/modification_audit_preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const RejectedAuditNoticeHeader: React.FC<AuditNoticeHeaderProps> = ({ language,
7070
<>
7171
{auditRejectedText + rejectReasonIsText}
7272
<br />
73-
{rejectedReason}
73+
<pre style={{ whiteSpace: "pre-wrap" }}>{rejectedReason}</pre>
7474
</>
7575
);
7676
}

0 commit comments

Comments
 (0)