전체 코드, 구조 검토 - 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
@@ -113,19 +113,16 @@ function UpgradeRequestActions({
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" | "reject") {
const actionLabel = action === "approve" ? "승인" : "거절";
const confirmed = window.confirm(
`${request.maestroName} 업그레이드 신청을 ${actionLabel}하시겠습니까?`
);
if (!confirmed) {
if (!window.confirm(`${request.maestroName} 업그레이드 신청을 ${actionLabel}하시겠습니까?`)) {
return;
}
@@ -141,14 +138,17 @@ function UpgradeRequestActions({
}
);
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;
throw new Error(
body?.message ?? "업그레이드 신청 처리에 실패했습니다."
);
if (!response.ok) {
throw new Error(body?.message ?? "업그레이드 신청 처리에 실패했습니다.");
}
if (action === "approve" && body?.emailSent === false) {
setEmailWarning(true);
}
startTransition(() => {
@@ -165,27 +165,36 @@ function UpgradeRequestActions({
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("reject")}
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("reject")}
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}