feat: add friend wishlist link

This commit is contained in:
Vaka.pro
2026-04-26 23:29:20 +03:00
parent f8fcda0d13
commit 34179b3f30
4 changed files with 50 additions and 1 deletions

View File

@@ -1,14 +1,22 @@
import { Link, NavLink, useNavigate } from 'react-router-dom';
import { Archive, Gift, LogOut, Sparkles, Trash2, UserCog, CheckCircle2 } from 'lucide-react';
import { Archive, CheckCircle2, Gift, LogOut, Sparkles, Trash2, UserCog, Users } from 'lucide-react';
import type { ComponentType } from 'react';
import { useQuery } from '@tanstack/react-query';
import { Button } from '../ui/Button';
import { useAuthStore } from '@/features/auth/authStore';
import { cn } from '@/lib/cn';
import { useI18n, type TranslationKey } from '@/i18n/i18n';
import { LanguageSwitcher } from '../LanguageSwitcher';
import { api } from '@/lib/api';
type NavIcon = ComponentType<{ className?: string }>;
interface FriendProfile {
slug: string;
displayName: string;
avatarUrl: string | null;
}
const links = [
{ to: '/', label: 'header.active', icon: Sparkles, end: true },
{ to: '/completed', label: 'header.fulfilled', icon: CheckCircle2 },
@@ -26,6 +34,12 @@ export function Header() {
const logout = useAuthStore((s) => s.logout);
const navigate = useNavigate();
const { t } = useI18n();
const friend = useQuery({
queryKey: ['profile-friend'],
queryFn: () => api.get<FriendProfile | null>('/api/profile/friend'),
staleTime: 10 * 60 * 1000,
enabled: user != null,
});
if (!user) return null;
@@ -61,6 +75,20 @@ export function Header() {
{t(l.label)}
</NavLink>
))}
{friend.data && (
<NavLink
to={`/u/${friend.data.slug}`}
className={({ isActive }) =>
cn(
'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors',
isActive ? 'bg-primary text-primary-foreground shadow-card' : 'text-ink hover:bg-ink/5',
)
}
>
<Users className="h-4 w-4" />
{t('header.friendWishes', { name: friend.data.displayName })}
</NavLink>
)}
</nav>
<div className="flex items-center gap-1">