This commit is contained in:
eric
2026-06-07 23:57:52 -05:00
parent 6d479c9f94
commit 47b1ae8514
56 changed files with 4163 additions and 874 deletions

View File

@@ -10,9 +10,18 @@ import {
import { usePayStatusPoll } from "@/app/lib/payment/usePayStatusPoll";
import AuthModal from "@/app/components/AuthModal";
import { apiFetch, fetchAuthMe } from "@/app/lib/api-client";
import { cities } from "@/app/data/cities";
const genderOptions = ["男", "女"];
const singleOptions = ["单身", "恋爱中", "已婚"];
const lookingForOptions = [
{ key: "friends", label: "🤝 交友" },
{ key: "dating", label: "🌹 约会" },
{ key: "partner", label: "👥 搭档" },
{ key: "roommate", label: "🏠 室友" },
{ key: "cofounder", label: "🚀 合伙人" },
{ key: "explore", label: "🍜 探店" },
];
const educationOptions = ["高中及以下", "大专", "本科", "硕士", "博士"];
const graduationYears = Array.from({ length: 41 }, (_, i) => String(2026 - i));
@@ -26,6 +35,8 @@ interface FormData {
education: string;
graduationYear: string;
phone: string;
location: string;
citySlug: string;
}
interface MediaInfo {
@@ -45,7 +56,10 @@ export default function JoinPage() {
education: "",
graduationYear: "",
phone: "",
location: "",
citySlug: "",
});
const [lookingFor, setLookingFor] = useState<string[]>(["friends", "explore"]);
const [media, setMedia] = useState<MediaInfo | null>(null);
const [uploading, setUploading] = useState(false);
const fileRef = useRef<HTMLInputElement>(null);
@@ -100,7 +114,11 @@ export default function JoinPage() {
try {
const data = await apiFetch<{ ok?: boolean; user_id?: string; error?: string }>("/api/join", {
method: "POST",
body: JSON.stringify({ ...form, media: media?.url }),
body: JSON.stringify({
...form,
media: media?.url,
lookingFor,
}),
});
if (!data?.ok) {
throw new Error(data?.error || "提交失败,请稍后重试");
@@ -303,6 +321,60 @@ export default function JoinPage() {
</Field>
</div>
<Field label="📍 当前城市">
<select
value={form.citySlug}
onChange={(e) => {
const city = cities.find((item) => (item.slug || item.name) === e.target.value);
setForm((prev) => ({
...prev,
citySlug: e.target.value,
location: city?.name || "",
}));
}}
required
className={`form-input appearance-none ${form.citySlug ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
>
<option value="" disabled>请选择所在城市</option>
{cities.map((city) => (
<option key={city.name} value={city.slug || city.name}>
{city.name}
</option>
))}
</select>
<ChevronDown />
</Field>
<div className="py-4 sm:py-5">
<label className="mb-3 block text-base font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
🎯 我在寻找
<span className="ml-2 text-xs font-normal text-slate-400 dark:text-slate-500">(可多选,影响智能匹配推荐)</span>
</label>
<div className="flex flex-wrap gap-2">
{lookingForOptions.map((option) => {
const active = lookingFor.includes(option.key);
return (
<button
key={option.key}
type="button"
onClick={() =>
setLookingFor((prev) =>
active ? prev.filter((item) => item !== option.key) : [...prev, option.key]
)
}
className={`rounded-full px-3 py-2 text-sm font-medium transition ${
active
? "bg-[#ff4d4f] text-white"
: "border border-slate-200 bg-white text-slate-600 dark:border-gray-700 dark:bg-gray-900 dark:text-slate-300"
}`}
>
{option.label}
</button>
);
})}
</div>
</div>
<div className="border-b border-slate-100 dark:border-gray-700 py-4 sm:border-b-0 sm:py-5">
<label className="mb-2 block text-base font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
📝 自我介绍