Skip to content

Commit a29c48a

Browse files
committed
Add typing to remove any. Update error handling. Update styling.
1 parent e4e94fe commit a29c48a

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

netflix-create-react-vite-app/src/components/details/MediaDetail.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff 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();

netflix-create-react-vite-app/src/components/details/details-styles.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export const ImageColumn = styled.div`
7575

7676
export 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

106105
export const Title = styled.h2`
107106
width: 300px;
108-
flex-wrap: wrap;
109107
align-items: center;
110108
word-break: break-word;
111109
text-align: center;

0 commit comments

Comments
 (0)