코드 검토 및 문서 반영
This commit is contained in:
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
|
||||
import { Plus } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { PAID_ACCOUNT_TYPE_VALUES } from "@/lib/constants";
|
||||
import { formatDateTime, getAccountTypeLabel, getRequestStatusLabel } from "@/lib/utils";
|
||||
import type { MaestroDetail } from "@/lib/maestros";
|
||||
|
||||
@@ -26,6 +27,7 @@ export function ExtensionRequestsSection({
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
|
||||
const isPaidAccount = (PAID_ACCOUNT_TYPE_VALUES as readonly number[]).includes(accountType);
|
||||
const isDisabled = isCreating || isPending;
|
||||
|
||||
async function handleCreate() {
|
||||
@@ -37,11 +39,7 @@ export function ExtensionRequestsSection({
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/maestros/${maestroID}/extension-requests`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ accountType }),
|
||||
}
|
||||
{ method: "POST" }
|
||||
);
|
||||
|
||||
const body = (await response.json().catch(() => null)) as {
|
||||
@@ -75,7 +73,7 @@ export function ExtensionRequestsSection({
|
||||
</div>
|
||||
<div className="flex flex-col items-end gap-1">
|
||||
<Button
|
||||
disabled={isDisabled}
|
||||
disabled={isDisabled || !isPaidAccount}
|
||||
onClick={() => void handleCreate()}
|
||||
size="sm"
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user