Files
2026-06-08 06:05:31 -05:00

142 lines
5.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import { Link, useLocale } from "@/i18n/navigation";
import { useParams } from "next/navigation";
import Footer from "@/app/components/Footer";
import SocialGreetButton from "@/app/components/SocialGreetButton";
import { mediaUrl } from "@/app/lib/media";
import { fetchPublicProfile, type PublicProfile } from "@/app/lib/social";
const INTENT_LABELS: Record<string, string> = {
friends: "🤝 交友",
dating: "🌹 约会",
partner: "👥 搭档",
roommate: "🏠 室友",
cofounder: "🚀 合伙人",
explore: "🍜 探店",
};
export default function MemberProfilePage() {
const params = useParams();
const profileId = String(params?.id || "");
const locale = useLocale();
const [profile, setProfile] = useState<PublicProfile | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (!profileId) return;
fetchPublicProfile(profileId)
.then(setProfile)
.finally(() => setLoading(false));
}, [profileId]);
if (loading) {
return (
<div className="min-h-screen bg-[#fafafa] dark:bg-gray-950">
<div className="mx-auto max-w-2xl animate-pulse px-4 py-10">
<div className="h-64 rounded-2xl bg-gray-200 dark:bg-gray-800" />
</div>
</div>
);
}
if (!profile) {
return (
<div className="flex min-h-screen items-center justify-center bg-[#fafafa] px-4 dark:bg-gray-950">
<div className="text-center">
<p className="text-gray-500">{locale === "zh" ? "成员资料不存在" : "Profile not found"}</p>
<Link href="/dating" className="mt-4 inline-block text-[#ff4d4f]">
{locale === "zh" ? "去智能匹配" : "Go to matching"}
</Link>
</div>
</div>
);
}
const lookingFor = Array.isArray(profile.lookingFor) ? profile.lookingFor : [];
return (
<div className="min-h-screen bg-[#fafafa] dark:bg-gray-950">
<main className="mx-auto max-w-2xl px-4 py-8 sm:px-6">
<div className="overflow-hidden rounded-2xl border border-gray-100 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900">
<div className="bg-gradient-to-br from-[#ff4d4f] to-[#ff7a45] px-6 py-8 text-white">
<div className="flex items-center gap-4">
<img
src={mediaUrl(profile.photo)}
alt={profile.name || "member"}
className="h-20 w-20 rounded-full border-4 border-white/30 object-cover"
/>
<div>
<h1 className="text-2xl font-bold">
{profile.name}
{profile.age ? `,${profile.age}` : ""}
</h1>
<p className="mt-1 text-sm text-white/85">📍 {profile.location || (locale === "zh" ? "远程" : "Remote")}</p>
</div>
</div>
</div>
<div className="space-y-5 p-6">
{profile.bio ? (
<section>
<h2 className="text-sm font-semibold text-gray-900 dark:text-gray-100">
{locale === "zh" ? "自我介绍" : "About"}
</h2>
<p className="mt-2 text-sm leading-7 text-gray-600 dark:text-gray-300">{profile.bio}</p>
</section>
) : null}
{lookingFor.length > 0 ? (
<section>
<h2 className="text-sm font-semibold text-gray-900 dark:text-gray-100">
{locale === "zh" ? "正在寻找" : "Looking for"}
</h2>
<div className="mt-2 flex flex-wrap gap-2">
{lookingFor.map((intent) => (
<span
key={intent}
className="rounded-full bg-gray-100 px-3 py-1 text-xs font-medium text-gray-700 dark:bg-gray-800 dark:text-gray-300"
>
{INTENT_LABELS[intent] || intent}
</span>
))}
</div>
</section>
) : null}
{profile.tags?.length ? (
<section>
<h2 className="text-sm font-semibold text-gray-900 dark:text-gray-100">
{locale === "zh" ? "标签" : "Tags"}
</h2>
<div className="mt-2 flex flex-wrap gap-2">
{profile.tags.map((tag) => (
<span
key={tag}
className="rounded-full bg-red-50 px-3 py-1 text-xs text-[#ff4d4f] dark:bg-red-950/30"
>
{tag}
</span>
))}
</div>
</section>
) : null}
<div className="flex flex-wrap gap-3 border-t border-gray-100 pt-5 dark:border-gray-800">
<Link
href={`/dating?intent=${lookingFor[0] || "friends"}${profile.citySlug ? `&city=${profile.citySlug}` : ""}`}
className="rounded-full border border-gray-200 px-4 py-2 text-sm font-semibold text-gray-700 dark:border-gray-700 dark:text-gray-200"
>
{locale === "zh" ? "在匹配里找 TA" : "Find in matching"}
</Link>
<SocialGreetButton profileId={profile.id} />
</div>
</div>
</div>
</main>
<Footer />
</div>
);
}