import { useQuery } from '@tanstack/react-query' import { Link, useParams } from 'react-router-dom' import { getVideo } from '../api/client' import { formatDuration, formatRelativeTime } from '../utils/format' import DownloadButton from '../components/DownloadButton' import Player from '../components/Player' function VideoPage() { const { youtubeVideoId } = useParams<{ youtubeVideoId: string }>() const videoQuery = useQuery({ queryKey: ['video', youtubeVideoId], queryFn: () => getVideo(youtubeVideoId!), enabled: !!youtubeVideoId, }) if (videoQuery.isLoading) { return (

Загрузка...

) } if (videoQuery.isError || !videoQuery.data) { return (
← Лента

Видео не найдено

) } const video = videoQuery.data const duration = formatDuration(video.duration_seconds) return (
← Лента

{video.title}

{video.channel.title} {' · '} {formatRelativeTime(video.published_at)} {duration && ` · ${duration}`} {' · '}
{video.categories.length > 0 && (
{video.categories.map((c) => ( {c.name} ))}
)} {video.description &&

{video.description}

}
) } export default VideoPage