;s
This commit is contained in:
@@ -59,28 +59,28 @@ export default function JoinPage() {
|
||||
const [authOpen, setAuthOpen] = useState(false);
|
||||
const [pendingSubmit, setPendingSubmit] = useState(false);
|
||||
const [isAlreadyRecorded, setIsAlreadyRecorded] = useState(false);
|
||||
const [checkingStatus, setCheckingStatus] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined" && new URLSearchParams(window.location.search).get("paid") === "1") {
|
||||
setSubmitted(true);
|
||||
setCheckingStatus(false);
|
||||
return;
|
||||
}
|
||||
const checkExisting = async () => {
|
||||
const meRes = await fetch(apiUrl("/api/auth/me"), { credentials: "include" });
|
||||
const meData = await meRes.json();
|
||||
if (!meData?.user) {
|
||||
setCheckingStatus(false);
|
||||
return;
|
||||
try {
|
||||
const meRes = await fetch(apiUrl("/api/auth/me"), { credentials: "include" });
|
||||
const meData = await meRes.json().catch(() => ({}));
|
||||
if (!meRes.ok || !meData?.user) {
|
||||
return;
|
||||
}
|
||||
const statusRes = await fetch(apiUrl("/api/join/status"), { credentials: "include", cache: "no-store" });
|
||||
const statusData = await statusRes.json().catch(() => ({}));
|
||||
if (statusRes.ok && statusData?.hasRecord && statusData?.isComplete) {
|
||||
setIsAlreadyRecorded(true);
|
||||
setSubmitted(true);
|
||||
}
|
||||
} catch {
|
||||
// Keep the form usable when the API proxy/backend is temporarily unavailable.
|
||||
}
|
||||
const statusRes = await fetch(apiUrl("/api/join/status"), { credentials: "include", cache: "no-store" });
|
||||
const statusData = await statusRes.json();
|
||||
if (statusData?.hasRecord && statusData?.isComplete) {
|
||||
setIsAlreadyRecorded(true);
|
||||
setSubmitted(true);
|
||||
}
|
||||
setCheckingStatus(false);
|
||||
};
|
||||
checkExisting();
|
||||
}, []);
|
||||
@@ -200,14 +200,6 @@ export default function JoinPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (checkingStatus) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-[#f0f4f8] dark:bg-gray-950 px-4">
|
||||
<div className="text-slate-500 dark:text-slate-400">加载中…</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#f0f4f8] dark:bg-gray-950">
|
||||
<div className="mx-auto max-w-2xl px-0 py-0 sm:px-6 sm:py-10 lg:py-14">
|
||||
|
||||
Reference in New Issue
Block a user