"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { api } from "@/lib/api"; import { useAuth } from "@/lib/auth"; import { useI18n } from "@/lib/i18n"; import type { ConversationItem } from "@/lib/types"; import RingNext from "@/components/RingNext"; import { useRingSteps } from "@/lib/rings"; function Avatar({ photo, name }: { photo?: string; name?: string }) { if (photo?.startsWith("http")) { return ( // eslint-disable-next-line @next/next/no-img-element ); } return {photo || name?.[0] || "💬"}; } export default function ChatClient() { const { user, token } = useAuth(); const { t } = useI18n(); const rings = useRingSteps(); const [items, setItems] = useState([]); const [loading, setLoading] = useState(Boolean(token)); useEffect(() => { if (!token) { setLoading(false); return; } setLoading(true); api .getConversations(token) .then(setItems) .catch(() => setItems([])) .finally(() => setLoading(false)); }, [token]); if (!user) { return ( {t.chat.loginTitle} {t.chat.loginDesc} {t.nav.login} {t.dating.meetAtEvents} {t.chat.goDating} ); } return ( {t.nav.dating} {t.chat.tag} {t.chat.title} {loading && {t.chat.loadingList}} {!loading && items.map((c) => ( 0 ? " unread" : ""}`} > {c.peer?.name || t.chat.peerFallback} {c.lastMessagePreview || t.chat.noMessages} {c.unreadCount > 0 && {c.unreadCount}} ))} {!loading && items.length === 0 && ( {t.chat.empty} {t.chat.goDating} {t.dating.meetAtEvents} {t.nav.community} )} ); }
{t.chat.loginDesc}
{t.chat.loadingList}
{c.lastMessagePreview || t.chat.noMessages}
{t.chat.empty}