import { unwrap } from '@pipu/core'; import { useQuery } from '@tanstack/react-query'; import { Link } from '@tanstack/react-router'; import { useTranslation } from 'react-i18next'; import { useSession } from '../app/session'; import { Cover, TrackList } from '../entities/catalog'; import { usePlayer } from '../player/context'; import { formatDuration } from '../shared/lib/format'; import { playIcon, shuffleIcon } from '../shared/ui/icons'; import { Button } from '../shared/ui/ui'; import { NotFound } from './NotFound'; import s from './page.module.css'; import c from './catalog.module.css'; export function AlbumPage({ id }: { id: string }) { const { t } = useTranslation(); const session = useSession(); const player = usePlayer(); const album = useQuery({ queryKey: ['album', id], queryFn: async () => unwrap(await session.client.GET('/api/v1/albums/{id}', { params: { path: { id } } })), }); if (album.isError) return ; const a = album.data; const colors = a?.cover_colors.length === 3 ? a.cover_colors : null; const ctx = { type: 'album' as const, id, label: a?.title }; return (
{colors && }
{t('catalog.album')}

{a?.title ?? '…'}

{a && ( {a.artist.name} {a.year ? ` · ${a.year}` : ''} · {t('catalog.track_count', { count: a.tracks.length })} · {formatDuration(a.duration_ms)} )} {a && a.tracks.some((tr) => tr.available) && (
)}
{a && }
); }