import { createFileRoute, Link } from "@tanstack/react-router" import { useTranslation } from "react-i18next" import { ArrowLeft, UserCheck, UserPlus } from "lucide-react" import { Button } from "@/components/ui/button" import { ProfileView, ProfileSkeleton } from "@/components/profile-view" import { useAuth } from "@/components/auth-provider" import { useUserProfile } from "@/hooks/use-users" import { useFollow, useUnfollow, useFollowing } from "@/hooks/use-social" export const Route = createFileRoute("/_app/users/$id")({ component: UserProfilePage, }) function UserProfilePage() { const { t } = useTranslation() const { id } = Route.useParams() const { auth } = useAuth() const { data, isPending } = useUserProfile(id, { view: "trends" }) const { data: followingData } = useFollowing() const followMutation = useFollow() const unfollowMutation = useUnfollow() if (isPending) return if (!data) return null const isSelf = auth?.user_id === id const isFollowing = followingData?.actors.some((a) => a.handle === data.username) ?? false return (
{t("common.back")} unfollowMutation.mutate({ handle: data.username })} disabled={unfollowMutation.isPending} > {t("common.following")} ) : ( ) ) : undefined } />
) }