import { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import VideoPlayer from "../components/VideoPlayer";
import VideoSidebar from "../components/VideoSidebar";
import { fetchVideo, formatRunTime } from "../api/client";
import type { VideoDetail } from "../types/video";
function getMapDisplayName(mapName: string): string {
return mapName.replace(/_/g, " ").toUpperCase();
}
function getMomUrl(mapName: string): string {
return `https://dashboard.momentum-mod.org/maps/${mapName}`;
}
function SkeletonBlock({ className }: { className?: string }) {
return (
);
}
function PageSkeleton() {
return (
);
}
export default function VideoDetail() {
const { id } = useParams<{ id: string }>();
const [video, setVideo] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
if (!id) return;
fetchVideo(id)
.then((v) => {
setVideo(v);
document.title = `${getMapDisplayName(v.mapName)} — ${v.playerName} · surf.nathan.rip`;
})
.catch((err) => setError(err.message));
return () => {
document.title = "surf.nathan.rip";
};
}, [id]);
if (error) {
return (
);
}
if (!video) {
return ;
}
return (
{video.previousPbs && video.previousPbs.length > 0 && (
Previous PBs
{video.previousPbs.map((pb) => (
-
{formatRunTime(pb.runTime)}
{" · "}
{new Date(
pb.createdAt,
).toLocaleDateString()}
))}
)}
);
}