전체 코드, 구조 검토 - P1-6 코드 수정 진행

This commit is contained in:
2026-07-04 15:40:33 +09:00
parent 41a246ad7b
commit 2231ac4bfe
5 changed files with 93 additions and 72 deletions
@@ -108,19 +108,16 @@ function ExtensionRequestActions({
const router = useRouter();
const [isPending, startTransition] = useTransition();
const [errorMessage, setErrorMessage] = useState("");
const [emailWarning, setEmailWarning] = useState(false);
const isRequested = request.status === REQUEST_STATUSES.REQUESTED;
if (!isRequested) {
if (!isRequested && !emailWarning) {
return <span className="text-xs text-muted-foreground"> </span>;
}
async function submitAction(action: "approve" | "cancel") {
const actionLabel = action === "approve" ? "승인" : "취소";
const confirmed = window.confirm(
`${request.maestroName} 연장 신청을 ${actionLabel}하시겠습니까?`
);
if (!confirmed) {
if (!window.confirm(`${request.maestroName} 연장 신청을 ${actionLabel}하시겠습니까?`)) {
return;
}
@@ -136,14 +133,19 @@ function ExtensionRequestActions({
}
);
if (!response.ok) {
const body = (await response.json().catch(() => null)) as {
message?: string;
} | null;
const body = (await response.json().catch(() => null)) as {
message?: string;
emailSent?: boolean;
} | null;
if (!response.ok) {
throw new Error(body?.message ?? "연장 신청 처리에 실패했습니다.");
}
if (action === "approve" && body?.emailSent === false) {
setEmailWarning(true);
}
startTransition(() => {
router.refresh();
});
@@ -158,27 +160,36 @@ function ExtensionRequestActions({
return (
<div className="space-y-2">
<div className="flex items-center gap-2">
<Button
disabled={isPending}
onClick={() => void submitAction("approve")}
size="sm"
type="button"
>
<Check className="size-4" aria-hidden="true" />
</Button>
<Button
disabled={isPending}
onClick={() => void submitAction("cancel")}
size="sm"
type="button"
variant="outline"
>
<X className="size-4" aria-hidden="true" />
</Button>
</div>
{isRequested ? (
<div className="flex items-center gap-2">
<Button
disabled={isPending}
onClick={() => void submitAction("approve")}
size="sm"
type="button"
>
<Check className="size-4" aria-hidden="true" />
</Button>
<Button
disabled={isPending}
onClick={() => void submitAction("cancel")}
size="sm"
type="button"
variant="outline"
>
<X className="size-4" aria-hidden="true" />
</Button>
</div>
) : (
<span className="text-xs text-muted-foreground"> </span>
)}
{emailWarning ? (
<p className="max-w-56 text-xs text-amber-600 dark:text-amber-400">
</p>
) : null}
{errorMessage ? (
<p className="max-w-56 text-xs text-destructive">{errorMessage}</p>
) : null}