https://feelvieact.netlify.app/person/1299351
useEffect(() => {
async function fetchApi() {
try {
setFilmoLoading(true);
await dispatch(movieActions(params.type, params.id));
const detail = await movieApi.person(params.id);
setDataUrl(detail.data);
const social = await movieApi.social('person', params.id);
setSocialUrl(social.data)
const art = await movieApi.personArt(params.id, typeTabs);
const art_list = art.data.cast.sort((a, b) => {
const dateA = a.release_date || a.first_air_date;
const dateB = b.release_date || b.first_air_date;
if (dateA && dateB) {
return new Date(dateB) - new Date(dateA);
}
return 0;
});
setArtUrl(art_list);
} catch (error) {
console.log(error);
setError(error);
} finally {
setFilmoLoading(false);
setLoading(false);
}
}
fetchApi();
}, [typeTabs, params.id]);
useEffect(() => {
try {
const popular = [...artUrl].sort((a, b) => b.vote_average - a.vote_average).slice(0, 5);
setArtPopular(popular);
} catch (error) {
console.log(error)
}
}, [artUrl]);
타입에 따라 배경 및 유명작품 & 리스트 변경
- 영화 클릭시
- TV 클릭시