kv-netflix/frontend-react/src/pages/Watch.tsx
vndangkhoa 3009f94fe9
Some checks failed
StreamFlow CI/CD / Backend Tests (push) Has been cancelled
StreamFlow CI/CD / Backend Lint (push) Has been cancelled
StreamFlow CI/CD / Frontend Tests (push) Has been cancelled
StreamFlow CI/CD / Android TV Build (push) Has been cancelled
StreamFlow CI/CD / Docker Build (push) Has been cancelled
StreamFlow CI/CD / Docker Publish (push) Has been cancelled
Release v4: Cleanup and refactoring
2026-03-03 07:55:27 +07:00

46 lines
1.5 KiB
TypeScript

import { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useMyList } from '../hooks/useMyList';
import { defaultTheme } from '../themes/default';
const Watch = () => {
const { slug, episode } = useParams();
const { addToHistory } = useMyList();
// Fetch movie detail to get info for history
useEffect(() => {
if (!slug) return;
const fetchDetail = async () => {
try {
const res = await fetch(`/api/videos/${slug}`);
if (res.ok) {
const data = await res.json();
// Add to history when loaded
addToHistory({
id: data.id,
title: data.title,
original_title: data.original_title,
slug: data.slug,
thumbnail: data.thumbnail,
backdrop: data.backdrop,
year: data.year,
category: data.category || 'movies',
quality: data.quality,
director: data.director,
cast: data.cast
});
}
} catch {
console.error("Failed to fetch for history");
}
};
fetchDetail();
}, [slug]);
const { WatchPage } = defaultTheme.components;
return <WatchPage slug={slug || ''} episode={episode || '1'} />;
};
export default Watch;