diff --git a/src/components/details/CastnCrew.js b/src/components/details/CastMovie.js similarity index 88% rename from src/components/details/CastnCrew.js rename to src/components/details/CastMovie.js index cc403ad..448798a 100644 --- a/src/components/details/CastnCrew.js +++ b/src/components/details/CastMovie.js @@ -4,7 +4,7 @@ import { v4 as uuidv4 } from 'uuid'; import { img200, noUserImg } from '../../config/imgConfig'; import SearchWithIcon from '../search/SearchWithIcon'; -const CastnCrew = ({ credits, title }) => { +const CastMovie = ({ credits, title }) => { const [search, setSearch] = useState(''); const handleChange = (e) => { @@ -33,7 +33,7 @@ const CastnCrew = ({ credits, title }) => { {filtered.map((credit) => ( -
+
{ className="w-14 h-14 rounded-full object-cover align-top" />
-
+

{credit.name}

{credit.character && ( -

+

as {credit.character}

)} @@ -67,11 +67,12 @@ const Cast = styled.div` display: flex; align-items: center; border-left: 5px solid #f99185; - padding-left: 2px; + padding: 7px 10px; + gap: 10px; width: 350px; min-width: 280px; box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.3); border-radius: 5px; `; -export default CastnCrew; +export default CastMovie; diff --git a/src/components/details/CastTV.js b/src/components/details/CastTV.js new file mode 100644 index 0000000..2a55351 --- /dev/null +++ b/src/components/details/CastTV.js @@ -0,0 +1,88 @@ +import React, { useState } from 'react'; +import styled from 'styled-components'; +import { v4 as uuidv4 } from 'uuid'; +import { img200, noUserImg } from '../../config/imgConfig'; +import SearchWithIcon from '../search/SearchWithIcon'; + +const CastTV = ({ credits, title }) => { + const [search, setSearch] = useState(''); + + const handleChange = (e) => { + setSearch(e.target.value); + }; + + const filtered = credits.filter((person) => { + return ( + person?.name?.toLowerCase().includes(search.toLowerCase()) || + person?.roles[0]?.character?.toLowerCase().includes(search.toLowerCase()) + ); + }); + + return ( +
+

Cast of {title}

+ + + {credits && credits.length > 0 && filtered && filtered.length > 0 ? ( +
+ {filtered.map((credit) => ( + + +
+ {credit?.name} +
+
+

{credit.name}

+ {credit.roles && ( +
+ {credit.roles.map((role, index) => ( + + {index > 0 && ', '} + + {role.character} + + + {' (' + role.episode_count + ' episodes)'} + + + ))} +
+ )} +
+
+
+ ))} +
+ ) : ( +

No Cast Found

+ )} +
+ ); +}; + +const Cast = styled.div` + display: flex; + align-items: center; + border-left: 5px solid #f99185; + padding: 7px 10px; + gap: 10px; + width: 350px; + min-width: 280px; + box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.3); + border-radius: 5px; +`; + +export default CastTV; diff --git a/src/pages/withid/DetailsPage.js b/src/pages/withid/DetailsPage.js index af37f8c..f35d9f8 100644 --- a/src/pages/withid/DetailsPage.js +++ b/src/pages/withid/DetailsPage.js @@ -5,7 +5,8 @@ import { useParams } from 'react-router-dom'; import styled from 'styled-components'; import BannerInfo from '../../components/details/BannerInfo'; -import CastnCrew from '../../components/details/CastnCrew'; +import CastMovie from '../../components/details/CastMovie'; +import CastTV from '../../components/details/CastTV'; import Trailers from '../../components/details/Trailers'; import FactBox from '../../components/details/FactBox'; import Recommended from '../../components/details/Recomamded'; @@ -29,19 +30,21 @@ const DetailsPage = () => { const [photos, setPhotos] = useState(); const [recommended, setRecommended] = useState(); const [credits, setCredits] = useState(); + const [creditsAll, setCreditsAll] = useState(); const [loading, setLoading] = useState(false); const fetchData = async () => { setLoading(true); const { data } = await axios.get( - `${detailURL}${type}/${id}?${apiKey}&language=en&append_to_response=external_ids,videos,images,recommendations,credits,collection,keywords` + `${detailURL}${type}/${id}?${apiKey}&language=en&append_to_response=external_ids,videos,images,recommendations,aggregate_credits,credits,collection,keywords` ); setContent(data); setVideos(data.videos.results); setPhotos(data.images); setRecommended(data.recommendations.results); - setCredits(data.credits.cast); + setCredits(data.credits?.cast); + setCreditsAll(data.aggregate_credits?.cast); setLoading(false); }; @@ -50,12 +53,6 @@ const DetailsPage = () => { // eslint-disable-next-line }, []); - useEffect(() => { - document.title = content - ? `${content.name || content.title} - CineParadis` - : 'CineParadis'; - }, [content]); - const getSlug = `${type}/${id}`; const getBackdrop = content?.backdrop_path ? `${img500}${content.backdrop_path}` @@ -149,10 +146,20 @@ const DetailsPage = () => {
<> {active === 0 && content && ( - + <> + {type === 'movie' && ( + + )} + {type === 'tv' && ( + + )} + )} {active === 1 && content && ( diff --git a/tailwind.config.js b/tailwind.config.js index f2f1b95..fd12c85 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -70,6 +70,7 @@ module.exports = { extend: { fontSize: { normal: '18px', + small: '15px', }, boxShadow: { bs1: '0px 10px 36px 0px rgba(0, 0, 0, 0.16), 0px 0px 0px 1px rgba(0, 0, 0, 0.06)',