diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js deleted file mode 100644 index ae86e51..0000000 --- a/src/App.js +++ /dev/null @@ -1,9 +0,0 @@ -import './App.css'; - -function App() { - return ( - <> - ); -} - -export default App; diff --git a/src/app/store.js b/src/app/store.js new file mode 100644 index 0000000..2155458 --- /dev/null +++ b/src/app/store.js @@ -0,0 +1,12 @@ +import { configureStore } from '@reduxjs/toolkit'; +import { tmdbApi } from '../services/TMDB'; +import genreOrCategoryReducer from '../features/currentGenreOrCategory'; +import userReducer from '../features/auth'; + +export default configureStore({ + reducer: { + [tmdbApi.reducerPath]: tmdbApi.reducer, + currentGenreOrCategory: genreOrCategoryReducer, + user: userReducer, + }, +}); diff --git a/src/assets/genres/action.png b/src/assets/genres/action.png new file mode 100644 index 0000000..83e9808 Binary files /dev/null and b/src/assets/genres/action.png differ diff --git a/src/assets/genres/adventure.png b/src/assets/genres/adventure.png new file mode 100644 index 0000000..ea3f9c6 Binary files /dev/null and b/src/assets/genres/adventure.png differ diff --git a/src/assets/genres/animation.png b/src/assets/genres/animation.png new file mode 100644 index 0000000..e1c2403 Binary files /dev/null and b/src/assets/genres/animation.png differ diff --git a/src/assets/genres/comedy.png b/src/assets/genres/comedy.png new file mode 100644 index 0000000..22c1148 Binary files /dev/null and b/src/assets/genres/comedy.png differ diff --git a/src/assets/genres/crime.png b/src/assets/genres/crime.png new file mode 100644 index 0000000..8b3c4c9 Binary files /dev/null and b/src/assets/genres/crime.png differ diff --git a/src/assets/genres/documentary.png b/src/assets/genres/documentary.png new file mode 100644 index 0000000..12e087b Binary files /dev/null and b/src/assets/genres/documentary.png differ diff --git a/src/assets/genres/drama.png b/src/assets/genres/drama.png new file mode 100644 index 0000000..7126558 Binary files /dev/null and b/src/assets/genres/drama.png differ diff --git a/src/assets/genres/family.png b/src/assets/genres/family.png new file mode 100644 index 0000000..e0daef0 Binary files /dev/null and b/src/assets/genres/family.png differ diff --git a/src/assets/genres/fantasy.png b/src/assets/genres/fantasy.png new file mode 100644 index 0000000..3e9f81c Binary files /dev/null and b/src/assets/genres/fantasy.png differ diff --git a/src/assets/genres/history.png b/src/assets/genres/history.png new file mode 100644 index 0000000..c705ca8 Binary files /dev/null and b/src/assets/genres/history.png differ diff --git a/src/assets/genres/horror.png b/src/assets/genres/horror.png new file mode 100644 index 0000000..d8f159d Binary files /dev/null and b/src/assets/genres/horror.png differ diff --git a/src/assets/genres/index.js b/src/assets/genres/index.js new file mode 100644 index 0000000..dfa50f3 --- /dev/null +++ b/src/assets/genres/index.js @@ -0,0 +1,48 @@ +import action from './action.png'; +import adventure from './adventure.png'; +import animation from './animation.png'; +import comedy from './comedy.png'; +import crime from './crime.png'; +import documentary from './documentary.png'; +import drama from './drama.png'; +import family from './family.png'; +import fantasy from './fantasy.png'; +import horror from './horror.png'; +import history from './history.png'; +import mystery from './mystery.png'; +import music from './music.png'; +import romance from './romance.png'; +import scienceFiction from './science fiction.png'; +import thriller from './thriller.png'; +import tvMovie from './tv movie.png'; +import war from './war.png'; +import western from './western.png'; + +import popular from './popular.png'; +import topRated from './top rated.png'; +import upcoming from './upcoming.png'; + +export default { + action, + adventure, + animation, + comedy, + crime, + documentary, + drama, + family, + fantasy, + horror, + history, + mystery, + music, + romance, + 'science fiction': scienceFiction, + thriller, + 'tv movie': tvMovie, + war, + western, + popular, + 'top rated': topRated, + upcoming, +}; diff --git a/src/assets/genres/music.png b/src/assets/genres/music.png new file mode 100644 index 0000000..3feebb1 Binary files /dev/null and b/src/assets/genres/music.png differ diff --git a/src/assets/genres/mystery.png b/src/assets/genres/mystery.png new file mode 100644 index 0000000..0ab7a83 Binary files /dev/null and b/src/assets/genres/mystery.png differ diff --git a/src/assets/genres/popular.png b/src/assets/genres/popular.png new file mode 100644 index 0000000..18d48ec Binary files /dev/null and b/src/assets/genres/popular.png differ diff --git a/src/assets/genres/romance.png b/src/assets/genres/romance.png new file mode 100644 index 0000000..78b52a6 Binary files /dev/null and b/src/assets/genres/romance.png differ diff --git a/src/assets/genres/science fiction.png b/src/assets/genres/science fiction.png new file mode 100644 index 0000000..01b2693 Binary files /dev/null and b/src/assets/genres/science fiction.png differ diff --git a/src/assets/genres/thriller.png b/src/assets/genres/thriller.png new file mode 100644 index 0000000..6f292db Binary files /dev/null and b/src/assets/genres/thriller.png differ diff --git a/src/assets/genres/top rated.png b/src/assets/genres/top rated.png new file mode 100644 index 0000000..8dcb5bd Binary files /dev/null and b/src/assets/genres/top rated.png differ diff --git a/src/assets/genres/tv movie.png b/src/assets/genres/tv movie.png new file mode 100644 index 0000000..40accfc Binary files /dev/null and b/src/assets/genres/tv movie.png differ diff --git a/src/assets/genres/upcoming.png b/src/assets/genres/upcoming.png new file mode 100644 index 0000000..7bc56c8 Binary files /dev/null and b/src/assets/genres/upcoming.png differ diff --git a/src/assets/genres/war.png b/src/assets/genres/war.png new file mode 100644 index 0000000..a791c2c Binary files /dev/null and b/src/assets/genres/war.png differ diff --git a/src/assets/genres/western.png b/src/assets/genres/western.png new file mode 100644 index 0000000..5beedf4 Binary files /dev/null and b/src/assets/genres/western.png differ diff --git a/src/assets/images/Filmpire.jpg b/src/assets/images/Filmpire.jpg new file mode 100644 index 0000000..190a446 Binary files /dev/null and b/src/assets/images/Filmpire.jpg differ diff --git a/src/assets/images/cinema.png b/src/assets/images/cinema.png new file mode 100644 index 0000000..2c0f200 Binary files /dev/null and b/src/assets/images/cinema.png differ diff --git a/src/assets/images/cinemas.svg b/src/assets/images/cinemas.svg new file mode 100644 index 0000000..94cc179 --- /dev/null +++ b/src/assets/images/cinemas.svg @@ -0,0 +1 @@ +home_cinema \ No newline at end of file diff --git a/src/assets/images/darkmode.png b/src/assets/images/darkmode.png new file mode 100644 index 0000000..a77637c Binary files /dev/null and b/src/assets/images/darkmode.png differ diff --git a/src/assets/images/infodark.png b/src/assets/images/infodark.png new file mode 100644 index 0000000..0de6c03 Binary files /dev/null and b/src/assets/images/infodark.png differ diff --git a/src/assets/images/infolight.png b/src/assets/images/infolight.png new file mode 100644 index 0000000..ca4af57 Binary files /dev/null and b/src/assets/images/infolight.png differ diff --git a/src/assets/images/lightmode.png b/src/assets/images/lightmode.png new file mode 100644 index 0000000..9de1310 Binary files /dev/null and b/src/assets/images/lightmode.png differ diff --git a/src/assets/images/movieNight.svg b/src/assets/images/movieNight.svg new file mode 100644 index 0000000..0f5cc91 --- /dev/null +++ b/src/assets/images/movieNight.svg @@ -0,0 +1 @@ +movie_night \ No newline at end of file diff --git a/src/assets/images/moviesflix.png b/src/assets/images/moviesflix.png new file mode 100644 index 0000000..efd7965 Binary files /dev/null and b/src/assets/images/moviesflix.png differ diff --git a/src/assets/images/nightmode.svg b/src/assets/images/nightmode.svg new file mode 100644 index 0000000..7c7adca --- /dev/null +++ b/src/assets/images/nightmode.svg @@ -0,0 +1 @@ +home_cinema \ No newline at end of file diff --git a/src/components/Actors/Actors.jsx b/src/components/Actors/Actors.jsx new file mode 100644 index 0000000..b002ef3 --- /dev/null +++ b/src/components/Actors/Actors.jsx @@ -0,0 +1,65 @@ +import { useState } from 'react'; +import { Box, Button, CircularProgress, Grid, Typography } from '@mui/material'; +import { useNavigate, useParams } from 'react-router-dom'; +import { ArrowBack } from '@mui/icons-material'; + +import useStyles from './styles'; +import { useGetActorQuery, useGetMoviesByActorIdQuery } from '../../services/TMDB'; +import { MovieList, Pagination } from '../index'; + +function Actors() { + const classes = useStyles(); + const [page, setPage] = useState(1); + const navigate = useNavigate(); + const { id } = useParams(); + const { data, isFetching, error } = useGetActorQuery(id); + const { data: movies } = useGetMoviesByActorIdQuery({ id, page }); + + if (isFetching) { + return ( + + + + ); + } + + if (error) { + return ( + + + + ); + } + + return ( + <> + + + {data.name} + + + {data?.name} + Born: {new Date(data?.birthday).toDateString()} + {data?.biography || 'Sorry, no biography yet...'} + + + + + + + + Movies + {movies && } + + + + ); +} + +export default Actors; \ No newline at end of file diff --git a/src/components/Actors/styles.js b/src/components/Actors/styles.js new file mode 100644 index 0000000..f14bb16 --- /dev/null +++ b/src/components/Actors/styles.js @@ -0,0 +1,15 @@ +import { makeStyles } from '@mui/styles'; + +export default makeStyles(() => ({ + image: { + maxWidth: '90%', + borderRadius: '20px', + objectFit: 'cover', + boxShadow: '0.5em 0.5em 1em', + }, + btns: { + marginTop: '2rem', + display: 'flex', + justifyContent: 'space-around', + }, +})); diff --git a/src/components/Alan.jsx b/src/components/Alan.jsx new file mode 100644 index 0000000..03f7db7 --- /dev/null +++ b/src/components/Alan.jsx @@ -0,0 +1,48 @@ +import { useEffect, useContext } from 'react'; +import alanBtn from '@alan-ai/alan-sdk-web'; +import { useDispatch } from 'react-redux'; +import { useNavigate } from 'react-router-dom'; + +import { ColorModeContext } from '../utils/ToggleColorMode'; +import { fetchToken } from '../utils/index'; +import { selectGenreOrCategory, searchMovie } from '../features/currentGenreOrCategory'; + +function useAlan() { + const { setMode } = useContext(ColorModeContext); + const dispatch = useDispatch(); + const navigate = useNavigate(); + + useEffect(() => { + alanBtn({ + key: process.env.REACT_APP_ALAN_SDK_KEY, + onCommand: ({ command, mode, genres, genreOrCategory, query }) => { + if (command === 'chooseGenre') { + const foundGenre = genres.find((g) => g.name.toLowerCase() === genreOrCategory.toLowerCase()); + if (foundGenre) { + navigate('/'); + dispatch(selectGenreOrCategory(foundGenre.id)); + } else { + const category = genreOrCategory.startsWith('top') ? 'top_rated' : genreOrCategory; + navigate('/'); + dispatch(selectGenreOrCategory(category)); + } + } else if (command === 'changeMode') { + if (mode === 'light') { + setMode('light'); + } else { + setMode('dark'); + } + } else if (command === 'login') { + fetchToken(); + } else if (command === 'logout') { + localStorage.clear(); + navigate('/'); + } else if (command === 'search') { + dispatch(searchMovie(query)); + } + }, + }); + }, []); +} + +export default useAlan; diff --git a/src/components/App.jsx b/src/components/App.jsx new file mode 100644 index 0000000..1067585 --- /dev/null +++ b/src/components/App.jsx @@ -0,0 +1,36 @@ +import { useRef } from 'react'; +import { CssBaseline} from "@mui/material"; +import { Routes, Route } from 'react-router-dom'; + +import useStyles from './styles'; +import useAlan from './Alan'; + +import { Actors, Movies, MovieInfo, Navbar, Profile } from './index' + +function App() { + const classes = useStyles(); + const alanBtnContainer = useRef(); + + useAlan(); + + return ( +
+ + +
+
+ + }/> + }/> + }/> + }/> + }/> + +
+
+
+
+ ); +} + +export default App; diff --git a/src/components/FeaturedMovie/FeaturedMovie.jsx b/src/components/FeaturedMovie/FeaturedMovie.jsx new file mode 100644 index 0000000..5e8b569 --- /dev/null +++ b/src/components/FeaturedMovie/FeaturedMovie.jsx @@ -0,0 +1,32 @@ +import { Box, Typography, Card, CardContent, CardMedia } from '@mui/material'; +import { Link } from 'react-router-dom'; + +import useStyles from './styles'; + +function FeaturedMovie({ movie }) { + const classes = useStyles(); + + if (!movie) return null; + + return ( + + + + + + {movie.title} + {movie.overview} + + + + + ); +} + +export default FeaturedMovie; diff --git a/src/components/FeaturedMovie/styles.js b/src/components/FeaturedMovie/styles.js new file mode 100644 index 0000000..e2bc9e4 --- /dev/null +++ b/src/components/FeaturedMovie/styles.js @@ -0,0 +1,40 @@ +import { makeStyles } from '@mui/styles'; + +export default makeStyles((theme) => ({ + featuredCardContainer: { + marginBottom: '20px', + display: 'flex', + justifyContent: 'center', + height: '490px', + textDecoration: 'none', + }, + card: { + width: '100%', + display: 'flex', + justifyContent: 'flex-end', + flexDirection: 'column', + }, + cardRoot: { + position: 'relative', + }, + cardMedia: { + position: 'absolute', + top: 0, + right: 0, + height: '100%', + width: '100%', + backgroundColor: 'rgba(0,0,0,0.575)', + backgroundBlendMode: 'darken', + }, + cardContent: { + color: '#fff', + width: '40%', + [theme.breakpoints.down('sm')]: { + width: '100%', + }, + }, + cardContentRoot: { + position: 'relative', + backgroundColor: 'transparent', + }, +})); diff --git a/src/components/Movie/Movie.jsx b/src/components/Movie/Movie.jsx new file mode 100644 index 0000000..0f7a733 --- /dev/null +++ b/src/components/Movie/Movie.jsx @@ -0,0 +1,30 @@ +import { Typography, Grid, Grow, Tooltip, Rating } from '@mui/material'; +import { Link } from 'react-router-dom'; + +import useStyles from './styles'; + +function Movie({ movie, i }) { + const classes = useStyles(); + + return ( + + + + {movie.title} + {movie.title} + +
+ +
+
+ +
+
+ ); +} + +export default Movie; \ No newline at end of file diff --git a/src/components/Movie/styles.js b/src/components/Movie/styles.js new file mode 100644 index 0000000..6988d55 --- /dev/null +++ b/src/components/Movie/styles.js @@ -0,0 +1,37 @@ +import { makeStyles } from '@mui/styles'; + +export default makeStyles((theme) => ({ + movie: { + padding: '10px', + }, + title: { + color: theme.palette.text.primary, + textOverflow: 'ellipsis', + width: '230px', + overflow: 'hidden', + whiteSpace: 'nowrap', + marginTop: '10px', + marginBottom: 0, + textAlign: 'center', + }, + links: { + alignItems: 'center', + fontWeight: 'bolder', + textDecoration: 'none', + [theme.breakpoints.up('xs')]: { + display: 'flex', + flexDirection: 'column', + }, + '&:hover': { + cursor: 'pointer', + }, + }, + image: { + borderRadius: '20px', + height: '300px', + marginBottom: '10px', + '&:hover': { + transform: 'scale(1.05)', + }, + }, +})); diff --git a/src/components/MovieInfo/MovieInfo.jsx b/src/components/MovieInfo/MovieInfo.jsx new file mode 100644 index 0000000..aca05b3 --- /dev/null +++ b/src/components/MovieInfo/MovieInfo.jsx @@ -0,0 +1,181 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Typography, Button, ButtonGroup, Grid, Box, CircularProgress, Rating } from '@mui/material'; +import { Movie as MovieIcon, Theaters, Language, PlusOne, Favorite, FavoriteBorderOutlined, Remove, ArrowBack } from '@mui/icons-material'; +import { Link, useParams } from 'react-router-dom'; +import { useDispatch, useSelector } from 'react-redux'; +import axios from 'axios'; + +import useStyles from './styles'; +import { MovieList } from '../index'; +import { useGetMovieQuery, useGetRecommendationsQuery, useGetListQuery } from '../../services/TMDB'; +import { selectGenreOrCategory } from '../../features/currentGenreOrCategory'; +import genreIcons from '../../assets/genres'; + +function MovieInfo() { + const classes = useStyles(); + const dispatch = useDispatch(); + const { user } = useSelector((state) => state.user); + const { id } = useParams(); + + const { data, error, isFetching } = useGetMovieQuery(id); + const { data: favoriteMovies } = useGetListQuery({ listName: 'favorite/movies', accountId: user.id, sessionId: localStorage.getItem('session_id'), page: 1 }); + const { data: watchlistMovies } = useGetListQuery({ listName: 'watchlist/movies', accountId: user.id, sessionId: localStorage.getItem('session_id'), page: 1 }); + const { data: recommendations } = useGetRecommendationsQuery({ list: '/recommendations', movie_id: id }); + + const [open, setOpen] = useState(false); + const [isMovieFavorited, setIsMovieFavorited] = useState(false); + const [isMovieWatchlisted, setIsMovieWatchlisted] = useState(false); + + useEffect(() => { + setIsMovieFavorited(!!favoriteMovies?.results?.find((movie) => movie?.id === data?.id)); + }, [favoriteMovies, data]); + useEffect(() => { + setIsMovieWatchlisted(!!watchlistMovies?.results?.find((movie) => movie?.id === data?.id)); + }, [watchlistMovies, data]); + + const addToFavorites = async () => { + await axios.post(`https://api.themoviedb.org/3/account/${user.id}/favorite?api_key=${process.env.REACT_APP_TMDB_KEY}&session_id=${localStorage.getItem('session_id')}`, { + media_type: 'movie', + media_id: id, + favorite: !isMovieFavorited, + }); + + setIsMovieFavorited((prev) => !prev); + }; + + const addToWatchList = async () => { + await axios.post(`https://api.themoviedb.org/3/account/${user.id}/watchlist?api_key=${process.env.REACT_APP_TMDB_KEY}&session_id=${localStorage.getItem('session_id')}`, { + media_type: 'movie', + media_id: id, + watchlist: !isMovieWatchlisted, + }); + + setIsMovieWatchlisted((prev) => !prev); + }; + + if (isFetching) { + return ( + + + + ); + } + + if (error) { + return ( + + Something went wrong - Go back. + + ); + } + + return ( + + + {data?.title} + + + + {data?.title} ({data.release_date.split('-')[0]}) + + + {data?.tagline} + + + + + + {data?.vote_average} / 10 + + + {data?.runtime}min + + + {data?.genres?.map((genre) => ( + dispatch(selectGenreOrCategory(genre.id))}> + + {genre?.name} + + ))} + + Overview + {data?.overview} + Top Cast + + {data && data?.credits?.cast?.map((character, i) => ( + character.profile_path && ( + + {character.name} + {character?.name} + + {character.character.split('/')[0]} + + + ) + )).slice(0, 6)} + + +
+ + + + + + + + + + + + + + +
+
+
+ + + You might also like + + {recommendations + ? + : Sorry, nothing was found.} + + setOpen(false)} + > + {data?.videos?.results?.length > 0 && ( +