's'
This commit is contained in:
@@ -73,21 +73,50 @@ export default function JoinPage() {
|
||||
const [isAlreadyRecorded, setIsAlreadyRecorded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined" && new URLSearchParams(window.location.search).get("paid") === "1") {
|
||||
setSubmitted(true);
|
||||
return;
|
||||
}
|
||||
const checkExisting = async () => {
|
||||
try {
|
||||
const meData = await fetchAuthMe();
|
||||
if (!meData?.user) return;
|
||||
const statusData = await apiFetch<{ hasRecord?: boolean; isComplete?: boolean }>(
|
||||
"/api/join/status",
|
||||
{ cache: "no-store" }
|
||||
);
|
||||
const [statusData, profileData] = await Promise.all([
|
||||
apiFetch<{ hasRecord?: boolean; isComplete?: boolean }>("/api/join/status", {
|
||||
cache: "no-store",
|
||||
}),
|
||||
apiFetch<{
|
||||
profile?: {
|
||||
name?: string;
|
||||
gender?: string;
|
||||
single?: string;
|
||||
location?: string;
|
||||
citySlug?: string;
|
||||
bio?: string;
|
||||
photo?: string;
|
||||
lookingFor?: string[];
|
||||
tags?: string[];
|
||||
};
|
||||
}>("/api/matches/profile/me", { cache: "no-store" }),
|
||||
]);
|
||||
const profile = profileData?.profile;
|
||||
if (profile) {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
nickname: profile.name || prev.nickname,
|
||||
gender: profile.gender || prev.gender,
|
||||
single: profile.single || prev.single,
|
||||
location: profile.location || prev.location,
|
||||
citySlug: profile.citySlug || prev.citySlug,
|
||||
intro: profile.bio || prev.intro,
|
||||
profession: profile.tags?.[0] || prev.profession,
|
||||
education: profile.tags?.[1] || prev.education,
|
||||
}));
|
||||
if (Array.isArray(profile.lookingFor) && profile.lookingFor.length > 0) {
|
||||
setLookingFor(profile.lookingFor);
|
||||
}
|
||||
if (profile.photo) {
|
||||
setMedia({ preview: profile.photo, url: profile.photo, type: "image" });
|
||||
}
|
||||
}
|
||||
if (statusData?.hasRecord && statusData?.isComplete) {
|
||||
setIsAlreadyRecorded(true);
|
||||
setSubmitted(true);
|
||||
}
|
||||
} catch {
|
||||
// Keep the form usable when the API proxy/backend is temporarily unavailable.
|
||||
@@ -219,6 +248,12 @@ export default function JoinPage() {
|
||||
<div className="absolute -right-10 -bottom-10 h-48 w-48 rounded-full bg-white/10 blur-2xl" />
|
||||
</div>
|
||||
|
||||
{isAlreadyRecorded && (
|
||||
<div className="mx-5 mt-4 rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-800 dark:border-sky-900/50 dark:bg-sky-950/40 dark:text-sky-200 sm:mx-8">
|
||||
你已提交过资料,可直接修改后保存更新,匹配与活动推荐会同步使用最新信息。
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="px-5 py-5 text-center sm:px-8 sm:py-7">
|
||||
<h1 className="text-xl font-bold text-slate-800 dark:text-slate-100 sm:text-2xl">
|
||||
🌍 数字游民社区报名
|
||||
|
||||
Reference in New Issue
Block a user