"use client"; import { useQuery } from "@tanstack/react-query"; import Image from "next/image"; import { CalendarDays, EyeOff, UserRound } from "lucide-react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { PublicProfileBadges } from "@/components/profile/PublicProfileBadges"; import { Helmet } from "@/lib/helmet"; import { Link, useParams } from "@/lib/router"; import { api } from "@/lib/api"; import { formatJalali, toPersianDigits } from "@/lib/utils"; import type { PublicProfileEventSchema } from "@/lib/types"; function EventCard({ event }: { event: PublicProfileEventSchema }) { return ( {event.image_url ? : ( )} {event.title} {formatJalali(event.start_time, false)} ); } export default function PublicProfile() { const { username: rawUsername } = useParams<{ username: string }>(); const username = Array.isArray(rawUsername) ? rawUsername[0] : rawUsername; const profileQuery = useQuery({ queryKey: ["public-profile", username], queryFn: () => api.getPublicProfile(username), enabled: Boolean(username), retry: false, }); const profile = profileQuery.data; if (profileQuery.isLoading) { return
در حال بارگذاری پروفایل عمومی...
; } if (profileQuery.isError || !profile) { return (
); } const fallback = `${profile.first_name?.[0] ?? ""}${profile.last_name?.[0] ?? ""}` || profile.username[0]; const maskedDetails = [ { label: "شماره موبایل", value: profile.mobile, isEmail: false }, ...(profile.email ? [{ label: "ایمیل", value: profile.email, isEmail: true }] : []), { label: "دانشگاه", value: profile.university, isEmail: false }, { label: "رشته", value: profile.major, isEmail: false }, { label: "شماره دانشجویی", value: profile.student_id, isEmail: false }, { label: "سال ورود", value: profile.year_of_study || null, isEmail: false }, ]; const pageDescription = profile.bio || `پروفایل عمومی ${profile.full_name} و رویدادهای او در انجمن علمی مهندسی کامپیوتر.`; return ( <> {`${profile.full_name} | پروفایل عمومی`}
رویدادهایی که {profile.first_name || profile.username} در آن‌ها شرکت کرده {profile.events.length ? profile.events.map((event) => ) :

هنوز رویدادی برای نمایش ثبت نشده است.

}
); }