File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
netflix-create-react-vite-app/src/components/details Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,30 @@ interface MediaDetailProps {
1919 type : 'movie' | 'tv' ;
2020}
2121
22- export const MediaDetail : React . FC < MediaDetailProps > = ( { type } ) => {
22+ interface MediaData {
23+ id : number ;
24+ title ?: string ;
25+ name ?: string ;
26+ poster_path ?: string ;
27+ tagline ?: string ;
28+
29+ }
30+
31+ interface CastMember {
32+ cast_id ?: number ;
33+ credit_id : string ;
34+ name : string ;
35+ profile_path ?: string ;
36+ character ?: string ;
37+ }
38+
39+
40+ export const MediaDetail = ( { type } : MediaDetailProps ) => {
2341 const { id } = useParams < { id : string } > ( ) ;
24- const [ media , setMedia ] = useState < any > ( null ) ;
42+ const [ media , setMedia ] = useState < MediaData | null > ( null ) ;
2543 const [ loading , setLoading ] = useState ( true ) ;
2644 const [ error , setError ] = useState < string | null > ( null ) ;
27- const [ cast , setCast ] = useState < any [ ] > ( [ ] ) ;
45+ const [ cast , setCast ] = useState < CastMember [ ] > ( [ ] ) ;
2846
2947 useEffect ( ( ) => {
3048 const fetchMedia = async ( ) => {
@@ -55,7 +73,9 @@ export const MediaDetail: React.FC<MediaDetailProps> = ({ type }) => {
5573 const data = await response . json ( ) ;
5674 setCast ( data . cast || [ ] ) ;
5775 } catch ( err ) {
58- // Optionally set error for cast
76+ console . error ( 'Failed to fetch cast data:' , err ) ;
77+ setError ( 'Failed to fetch cast data' ) ;
78+ setLoading ( false ) ;
5979 }
6080 } ;
6181 fetchCast ( ) ;
Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ export const ImageColumn = styled.div`
7575
7676export const Tagline = styled . p `
7777 width: 300px;
78- flex-wrap: wrap;
7978 margin-top: ${ ( { theme } ) => theme . space [ 3 ] } ;
8079 text-align: center;
8180 word-break: break-word;
@@ -105,7 +104,6 @@ export const RightColumn = styled.div`
105104
106105export const Title = styled . h2 `
107106 width: 300px;
108- flex-wrap: wrap;
109107 align-items: center;
110108 word-break: break-word;
111109 text-align: center;
You can’t perform that action at this time.
0 commit comments