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 @@
+
\ 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 @@
+
\ 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 @@
+
\ 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 (
+
+ } onClick={() => navigate(-1)} color="primary">
+ Go Back
+
+
+ );
+ }
+
+ return (
+ <>
+
+
+
+
+
+ {data?.name}
+ Born: {new Date(data?.birthday).toDateString()}
+ {data?.biography || 'Sorry, no biography yet...'}
+
+
+ } onClick={() => navigate(-1)} color="primary">Back
+
+
+
+
+ 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}
+
+
+
+
+
+
+
+
+ );
+}
+
+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.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.character.split('/')[0]}
+
+
+ )
+ )).slice(0, 6)}
+
+
+
+
+
+ }>Website
+ }>IMDB
+
+
+
+
+
+ : }>
+ {isMovieFavorited ? 'Unfavorite' : 'Favorite'}
+
+ : }>
+ Watchlist
+
+ } sx={{ borderColor: 'primary.main' }}>
+
+ Back
+
+
+
+
+
+
+
+
+
+ You might also like
+
+ {recommendations
+ ?
+ : Sorry, nothing was found.}
+
+ setOpen(false)}
+ >
+ {data?.videos?.results?.length > 0 && (
+
+ )}
+
+
+ );
+}
+
+export default MovieInfo;
diff --git a/src/components/MovieInfo/styles.js b/src/components/MovieInfo/styles.js
new file mode 100644
index 0000000..a117c56
--- /dev/null
+++ b/src/components/MovieInfo/styles.js
@@ -0,0 +1,75 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles((theme) => ({
+ containerSpaceAround: {
+ display: 'flex',
+ justifyContent: 'space-around',
+ margin: '10px 0 !important',
+ [theme.breakpoints.down('sm')]: {
+ flexDirection: 'column',
+ flexWrap: 'wrap',
+ },
+ },
+ poster: {
+ borderRadius: '20px',
+ boxShadow: '0.5em 1em 1em rgb(64, 64, 70)',
+ width: '80%',
+ [theme.breakpoints.down('md')]: {
+ margin: '0 auto !imporatant',
+ width: '50%',
+ },
+ [theme.breakpoints.down('sm')]: {
+ margin: '0 auto !imporatant',
+ width: '100%',
+ height: '350px',
+ marginBottom: '30px',
+ },
+ },
+ genresContainer: {
+ margin: '10px 0 !imaportant',
+ display: 'flex',
+ justifyContent: 'space-around',
+ flexWrap: 'wrap',
+ },
+ genreImage: {
+ filter: theme.palette.mode === 'dark' && 'invert(1)',
+ marginRight: '10px',
+ },
+ links: {
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ textDecoration: 'none',
+ [theme.breakpoints.down('sm')]: {
+ padding: '0.5rem 1rem',
+ },
+ },
+ castImage: {
+ width: '100%',
+ maxWidth: '7em',
+ height: '8em',
+ objectFit: 'cover',
+ borderRadius: '10px',
+ },
+ buttonContainer: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ width: '100%',
+ [theme.breakpoints.down('sm')]: {
+ flexDirection: 'column',
+ },
+ },
+ modal: {
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ video: {
+ width: '50%',
+ height: '50%',
+ [theme.breakpoints.down('sm')]: {
+ width: '90%',
+ height: '90%',
+ },
+ },
+}));
diff --git a/src/components/MovieList/MovieList.jsx b/src/components/MovieList/MovieList.jsx
new file mode 100644
index 0000000..c4f5dda
--- /dev/null
+++ b/src/components/MovieList/MovieList.jsx
@@ -0,0 +1,19 @@
+import { Grid } from '@mui/material';
+
+import useStyles from './styles';
+import { Movie } from '../index';
+
+function MovieList({ movies, numberOfMovies, excludeFirst }) {
+ const classes = useStyles();
+ const startFrom = excludeFirst ? 1 : 0;
+
+ return (
+
+ {movies.results.slice(startFrom, numberOfMovies).map((movie, i) => (
+
+ ))}
+
+ );
+}
+
+export default MovieList;
diff --git a/src/components/MovieList/styles.js b/src/components/MovieList/styles.js
new file mode 100644
index 0000000..fed624a
--- /dev/null
+++ b/src/components/MovieList/styles.js
@@ -0,0 +1,13 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles((theme) => ({
+ movieContainer: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ overflow: 'auto',
+ flexWrap: 'wrap',
+ [theme.breakpoints.down('sm')]: {
+ justifyContent: 'center',
+ },
+ },
+}));
diff --git a/src/components/Movies/Movies.jsx b/src/components/Movies/Movies.jsx
new file mode 100644
index 0000000..57cff1c
--- /dev/null
+++ b/src/components/Movies/Movies.jsx
@@ -0,0 +1,47 @@
+import { useState } from 'react';
+import { Box, CircularProgress, useMediaQuery, Typography } from '@mui/material';
+import { useSelector } from 'react-redux';
+
+import { MovieList, Pagination, FeaturedMovie } from '../index';
+import { useGetMoviesQuery } from '../../services/TMDB';
+
+function Movies() {
+ const [page, setPage] = useState(1);
+ const { genreIdOrCategoryName, searchQuery } = useSelector((state) => state.currentGenreOrCategory);
+ const { data, error, isFetching } = useGetMoviesQuery({ genreIdOrCategoryName, page, searchQuery });
+
+ const lg = useMediaQuery((theme) => theme.breakpoints.only('lg'));
+ const numberOfMovies = lg ? 17 : 19;
+
+ if (isFetching) {
+ return (
+
+
+
+ );
+ }
+
+ if (!data.results.length) {
+ return (
+
+
+ No movies that match that name.
+
+ Please searh for something else.
+
+
+ );
+ }
+
+ if (error) return 'An error has occured.';
+
+ return (
+
+ );
+}
+
+export default Movies;
diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx
new file mode 100644
index 0000000..4863374
--- /dev/null
+++ b/src/components/Navbar/Navbar.jsx
@@ -0,0 +1,115 @@
+import { useState, useEffect, useContext } from 'react';
+import { AppBar, IconButton, Toolbar, Drawer, Button, Avatar, useMediaQuery } from '@mui/material';
+import { Menu, AccountCircle, Brightness4, Brightness7 } from '@mui/icons-material';
+import { useTheme } from '@mui/material/styles';
+import { Link } from 'react-router-dom';
+import { useDispatch, useSelector } from 'react-redux';
+
+import useStyles from './styles';
+import { Search, Sidebar } from '../index';
+import { setUser } from '../../features/auth';
+import { fetchToken, createSessionId, moviesApi } from '../../utils/index';
+import { ColorModeContext } from '../../utils/ToggleColorMode';
+
+function Navbar() {
+ const classes = useStyles();
+ const isMobile = useMediaQuery('(max-width:600px)');
+ const theme = useTheme();
+ const dispatch = useDispatch();
+ const { isAuthenticated, user } = useSelector((state) => state.user);
+ const [mobileOpen, setMobileOpen] = useState(false);
+
+ const colorMode = useContext(ColorModeContext);
+
+ const token = localStorage.getItem('request_token');
+ const sessionIdFromLocalStorage = localStorage.getItem('session_id');
+
+ useEffect(() => {
+ const logInUser = async () => {
+ if (token) {
+ if (sessionIdFromLocalStorage) {
+ const { data: userData } = await moviesApi.get(`/account?session_id=${sessionIdFromLocalStorage}`);
+ dispatch(setUser(userData));
+ } else {
+ const sessionId = await createSessionId();
+ const { data: userData } = await moviesApi.get(`/account?session_id=${sessionId}`);
+ dispatch(setUser(userData));
+ }
+ }
+ };
+
+ logInUser();
+ }, [token]);
+
+ return (
+ <>
+
+
+ {isMobile && (
+ setMobileOpen((prevMobileOpen) => !prevMobileOpen)}
+ className={classes.menuButton}
+ >
+
+
+ )}
+
+ {theme.palette.mode === 'dark' ? : }
+
+ {!isMobile && }
+
+ {!isAuthenticated ? (
+
+ ) : (
+
+ )}
+
+ {isMobile && }
+
+
+
+
+
+ >
+ );
+}
+
+export default Navbar;
diff --git a/src/components/Navbar/styles.js b/src/components/Navbar/styles.js
new file mode 100644
index 0000000..eb69bf1
--- /dev/null
+++ b/src/components/Navbar/styles.js
@@ -0,0 +1,37 @@
+import { makeStyles } from '@mui/styles';
+
+const drawerWidth = 240;
+
+export default makeStyles((theme) => ({
+ toolbar: {
+ height: '80px',
+ display: 'flex',
+ justifyContent: 'space-between',
+ marginLeft: '240px',
+ [theme.breakpoints.down('sm')]: {
+ marginLeft: 0,
+ flexWrap: 'wrap',
+ },
+ },
+ menuButton: {
+ marginRight: theme.spacing(2),
+ [theme.breakpoints.up('sm')]: {
+ display: 'none',
+ },
+ },
+ drawer: {
+ [theme.breakpoints.up('sm')]: {
+ width: drawerWidth,
+ flexShrink: 0,
+ },
+ },
+ drawerPaper: {
+ width: drawerWidth,
+ },
+ linkButton: {
+ '&:hover': {
+ color: 'white !important',
+ textDecoration: 'none',
+ },
+ },
+}));
diff --git a/src/components/Pagination/Pagination.jsx b/src/components/Pagination/Pagination.jsx
new file mode 100644
index 0000000..e0a8d84
--- /dev/null
+++ b/src/components/Pagination/Pagination.jsx
@@ -0,0 +1,26 @@
+import { Typography, Button } from '@mui/material';
+
+import useStyles from './styles';
+
+function Pagination({ currentPage, setPage, totalPages }) {
+ const classes = useStyles();
+
+ const handlePrev = () => {
+ if (currentPage !== 1) { setPage((prevPage) => prevPage - 1); }
+ };
+ const handleNext = () => {
+ if (currentPage !== totalPages) { setPage((prevPage) => prevPage + 1); }
+ };
+
+ if (totalPages === 0) return null;
+
+ return (
+
+
+ {currentPage}
+
+
+ );
+}
+
+export default Pagination;
diff --git a/src/components/Pagination/styles.js b/src/components/Pagination/styles.js
new file mode 100644
index 0000000..4b7566b
--- /dev/null
+++ b/src/components/Pagination/styles.js
@@ -0,0 +1,16 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles((theme) => ({
+ container: {
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ button: {
+ margin: '30px 2px',
+ },
+ pageNumber: {
+ margin: '0 20px !important',
+ color: theme.palette.text.primary,
+ },
+}));
diff --git a/src/components/Profile/Profile.jsx b/src/components/Profile/Profile.jsx
new file mode 100644
index 0000000..41cae2a
--- /dev/null
+++ b/src/components/Profile/Profile.jsx
@@ -0,0 +1,44 @@
+import { useEffect } from 'react';
+import { Box, Button, Typography } from '@mui/material';
+import { ExitToApp } from '@mui/icons-material';
+import { useSelector } from 'react-redux';
+
+import { useGetListQuery } from '../../services/TMDB';
+import { RatedCards } from '../index';
+
+function Profile() {
+ const { user } = useSelector((state) => state.user);
+ const { data: favoriteMovies, refetch: refetchFavorites } = useGetListQuery({ listName: 'favorite/movies', accountId: user.id, sessionId: localStorage.getItem('session_id'), page: 1 });
+ const { data: watchlistMovies, refetch: refetchWatchlisted } = useGetListQuery({ listName: 'watchlist/movies', accountId: user.id, sessionId: localStorage.getItem('session_id'), page: 1 });
+
+ useEffect(() => {
+ refetchFavorites();
+ refetchWatchlisted();
+ }, []);
+
+ const logout = () => {
+ localStorage.clear();
+ window.location.href = '/';
+ };
+
+ return (
+
+
+ My Profile
+
+
+ {!favoriteMovies?.results?.length && !watchlistMovies?.results?.length
+ ? Add favourite or watchlist same movies to see them here!
+ : (
+
+
+
+
+ )}
+
+ );
+}
+
+export default Profile;
diff --git a/src/components/RatedCards/RatedCards.jsx b/src/components/RatedCards/RatedCards.jsx
new file mode 100644
index 0000000..30d4c76
--- /dev/null
+++ b/src/components/RatedCards/RatedCards.jsx
@@ -0,0 +1,21 @@
+import { Typography, Box } from '@mui/material';
+
+import useStyles from './styles';
+import { Movie } from '../index';
+
+function RatedCards({ title, movies }) {
+ const classes = useStyles();
+
+ return (
+
+ {title}
+
+ {movies?.results.map((movie, i) => (
+
+ ))}
+
+
+ );
+}
+
+export default RatedCards;
diff --git a/src/components/RatedCards/styles.js b/src/components/RatedCards/styles.js
new file mode 100644
index 0000000..2a9c222
--- /dev/null
+++ b/src/components/RatedCards/styles.js
@@ -0,0 +1,7 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles(() => ({
+ container: {
+ margin: '20px 0',
+ },
+}));
diff --git a/src/components/Search/Search.jsx b/src/components/Search/Search.jsx
new file mode 100644
index 0000000..4def947
--- /dev/null
+++ b/src/components/Search/Search.jsx
@@ -0,0 +1,13 @@
+import { useState} from "react";
+import { TextField, InputAdornment } from '@mui/material';
+import { Search as SearchIcon } from '@mui/icons-material';
+
+import useStyles from './styles';
+
+function Search() {
+ return (
+ <>>
+ )
+}
+
+export default Search;
\ No newline at end of file
diff --git a/src/components/Search/styles.js b/src/components/Search/styles.js
new file mode 100644
index 0000000..03682b2
--- /dev/null
+++ b/src/components/Search/styles.js
@@ -0,0 +1,19 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles((theme) => ({
+ searchContainer: {
+ [theme.breakpoints.down('sm')]: {
+ display: 'flex',
+ justifyContainer: 'center',
+ width: '100%',
+ },
+ },
+ input: {
+ color: theme.palette.mode === 'light' && 'dark',
+ filter: theme.palette.mode === 'light' && 'invert(1)',
+ [theme.breakpoints.down('sm')]: {
+ marginTop: '-10px',
+ marginBottom: '10px',
+ },
+ },
+}));
diff --git a/src/components/Sidebar/Sidebar.jsx b/src/components/Sidebar/Sidebar.jsx
new file mode 100644
index 0000000..daf4446
--- /dev/null
+++ b/src/components/Sidebar/Sidebar.jsx
@@ -0,0 +1,78 @@
+import { useEffect } from 'react';
+import { Divider, List, ListItem, ListItemText, ListSubheader, ListItemIcon, Box, CircularProgress } from '@mui/material';
+import { Link } from 'react-router-dom';
+import { useTheme } from '@mui/styles';
+import { useDispatch, useSelector } from 'react-redux';
+
+import useStyles from './styles';
+import { useGetGenresQuery } from '../../services/TMDB';
+import { selectGenreOrCategory } from '../../features/currentGenreOrCategory';
+import genreIcons from '../../assets/genres';
+
+const redLogo = 'https://fontmeme.com/permalink/210930/8531c658a743debe1e1aa1a2fc82006e.png';
+const blueLogo = 'https://fontmeme.com/permalink/210930/6854ae5c7f76597cf8680e48a2c8a50a.png';
+
+const categories = [
+ { label: 'Popular', value: 'popular' },
+ { label: 'Top Rated', value: 'top_rated' },
+ { label: 'Upcoming', value: 'upcoming' },
+];
+
+function Sidebar({ setMobileOpen }) {
+ const theme = useTheme();
+ const classes = useStyles();
+ const dispatch = useDispatch();
+ const { data, isFetching } = useGetGenresQuery();
+ const { genreIdOrCategoryName } = useSelector((state) => state.currentGenreOrCategory);
+
+ useEffect(() => {
+ setMobileOpen(false);
+ }, [genreIdOrCategoryName]);
+
+ return (
+ <>
+
+

+
+
+
+ Categories
+ {categories.map(({ label, value }) => (
+
+ dispatch(selectGenreOrCategory(value))}>
+
+
+
+
+
+
+ ))}
+
+
+
+ Genres
+ {isFetching ? (
+
+
+
+ )
+ : data?.genres?.map(({ name, id }) => (
+
+ dispatch(selectGenreOrCategory(id))}>
+
+
+
+
+
+
+ ))}
+
+ >
+ );
+}
+
+export default Sidebar;
diff --git a/src/components/Sidebar/styles.js b/src/components/Sidebar/styles.js
new file mode 100644
index 0000000..e2103e0
--- /dev/null
+++ b/src/components/Sidebar/styles.js
@@ -0,0 +1,23 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles((theme) => ({
+ imageLink: {
+ display: 'flex',
+ justifyContent: 'center',
+ padding: '10% 0',
+ },
+ image: {
+ width: '70%',
+ },
+ links: {
+ color: theme.palette.text.primary,
+ textDecoration: 'none',
+ },
+ genreImages: {
+ filter: theme.palette.mode === 'dark' ? 'invert(1)' : 'dark',
+ },
+ bigText: {
+ color: 'primary',
+ fontSize: 30,
+ },
+}));
diff --git a/src/components/index.js b/src/components/index.js
new file mode 100644
index 0000000..5085ca9
--- /dev/null
+++ b/src/components/index.js
@@ -0,0 +1,12 @@
+export { default as Actors } from './Actors/Actors';
+export { default as Movies } from './Movies/Movies';
+export { default as MovieInfo } from './MovieInfo/MovieInfo';
+export { default as Profile } from './Profile/Profile';
+export { default as Navbar } from './Navbar/Navbar';
+export { default as Sidebar } from './Sidebar/Sidebar';
+export { default as MovieList } from './MovieList/MovieList';
+export { default as Movie } from './Movie/Movie';
+export { default as Search } from './Search/Search';
+export { default as Pagination } from './Pagination/Pagination';
+export { default as RatedCards } from './RatedCards/RatedCards';
+export { default as FeaturedMovie } from './FeaturedMovie/FeaturedMovie';
\ No newline at end of file
diff --git a/src/components/styles.js b/src/components/styles.js
new file mode 100644
index 0000000..b4d4746
--- /dev/null
+++ b/src/components/styles.js
@@ -0,0 +1,15 @@
+import { makeStyles } from '@mui/styles';
+
+export default makeStyles(() => ({
+ root: {
+ display: 'flex',
+ height: '100%',
+ },
+ content: {
+ flexGrow: 1,
+ padding: '6em 2em 2em',
+ },
+ toolkit: {
+ height: '70px',
+ },
+}));
diff --git a/src/features/auth.js b/src/features/auth.js
new file mode 100644
index 0000000..2e8e7f4
--- /dev/null
+++ b/src/features/auth.js
@@ -0,0 +1,25 @@
+import { createSlice } from '@reduxjs/toolkit';
+
+const initialState = {
+ user: {},
+ isAuthenticated: false,
+ sessionId: '',
+};
+
+const authSlice = createSlice({
+ name: 'user',
+ initialState,
+ reducers: {
+ setUser: (state, action) => {
+ state.user = action.payload;
+ state.isAuthenticated = true;
+ state.sessionId = localStorage.getItem('session_id');
+
+ localStorage.setItem('accountId', action.payload.id);
+ },
+ },
+});
+
+export const { setUser } = authSlice.actions;
+
+export default authSlice.reducer;
diff --git a/src/features/currentGenreOrCategory.js b/src/features/currentGenreOrCategory.js
new file mode 100644
index 0000000..233d1fb
--- /dev/null
+++ b/src/features/currentGenreOrCategory.js
@@ -0,0 +1,23 @@
+import { createSlice } from '@reduxjs/toolkit';
+
+export const genreOrCategory = createSlice({
+ name: 'genreOrCategory',
+ initialState: {
+ genreIdOrCategoryName: '',
+ page: 1,
+ searchQuery: '',
+ },
+ reducers: {
+ selectGenreOrCategory: (state, action) => {
+ state.genreIdOrCategoryName = action.payload;
+ state.searchQuery = '';
+ },
+ searchMovie: (state, action) => {
+ state.searchQuery = action.payload;
+ },
+ },
+});
+
+export const { selectGenreOrCategory, searchMovie } = genreOrCategory.actions;
+
+export default genreOrCategory.reducer;
diff --git a/src/index.css b/src/index.css
index ec2585e..c5e3f73 100644
--- a/src/index.css
+++ b/src/index.css
@@ -1,13 +1,15 @@
-body {
- margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
- sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
+::-webkit-scrollbar {
+ width: 7px;
}
-code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
- monospace;
+::-webkit-scrollbar-track {
+ background: #cfcfcf;
}
+
+::-webkit-scrollbar-thumb {
+ background: #a5a5a5;
+}
+
+* {
+ text-decoration: none;
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 2cb1087..90d6ec3 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,11 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
+import { BrowserRouter } from 'react-router-dom';
+import { Provider } from 'react-redux';
+import store from './app/store';
+import ToggleColorMode from "./utils/ToggleColorMode";
+import App from './components/App';
import './index.css';
-import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
-
-
-
+
+
+
+
+
+
+
+
);
diff --git a/src/services/TMDB.js b/src/services/TMDB.js
new file mode 100644
index 0000000..7187e66
--- /dev/null
+++ b/src/services/TMDB.js
@@ -0,0 +1,73 @@
+import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
+
+const tmdbApiKey = process.env.REACT_APP_TMDB_KEY;
+
+export const tmdbApi = createApi({
+ reducerPath: 'tmdbApi',
+ baseQuery: fetchBaseQuery({ baseUrl: 'https://api.themoviedb.org/3' }),
+ endpoints: (builder) => ({
+
+ // Get Genres
+ getGenres: builder.query({
+ query: () => `/genre/movie/list?api_key=${tmdbApiKey}`,
+ }),
+
+ // Get Movies by [Type]
+ getMovies: builder.query({
+ query: ({ genreIdOrCategoryName, page, searchQuery }) => {
+ // Get Movies by Search
+ if (searchQuery) {
+ return `/search/movie?query=${searchQuery}&page=${page}&api_key=${tmdbApiKey}`;
+ }
+
+ // Get Movies by Category
+ if (genreIdOrCategoryName && typeof genreIdOrCategoryName === 'string') {
+ return `/movie/${genreIdOrCategoryName}?page=${page}&api_key=${tmdbApiKey}`;
+ }
+
+ // Get Movies by Genre
+ if (genreIdOrCategoryName && typeof genreIdOrCategoryName === 'number') {
+ return `discover/movie?with_genres=${genreIdOrCategoryName}&page=${page}&api_key=${tmdbApiKey}`;
+ }
+
+ // Get popular movies by default
+ return `/movie/popular?page=${page}&api_key=${tmdbApiKey}`;
+ },
+ }),
+
+ // Get Movie
+ getMovie: builder.query({
+ query: (id) => `/movie/${id}?append_to_response=videos,credits&api_key=${tmdbApiKey}`,
+ }),
+
+ // Get Recommendations
+ getRecommendations: builder.query({
+ query: ({ movie_id, list }) => `/movie/${movie_id}/${list}?api_key=${tmdbApiKey}`,
+ }),
+
+ // Get Actor
+ getActor: builder.query({
+ query: (id) => `person/${id}?api_key=${tmdbApiKey}`,
+ }),
+
+ // Get Movies by Actor
+ getMoviesByActorId: builder.query({
+ query: ({ id, page }) => `/discover/movie?with_cast=${id}&page=${page}&api_key=${tmdbApiKey}`,
+ }),
+
+ // Get User Specific Lists
+ getList: builder.query({
+ query: ({ listName, accountId, sessionId, page }) => `/account/${accountId}/${listName}?api_key=${tmdbApiKey}&session_id=${sessionId}&page=${page}`,
+ }),
+ }),
+});
+
+export const {
+ useGetGenresQuery,
+ useGetMoviesQuery,
+ useGetMovieQuery,
+ useGetRecommendationsQuery,
+ useGetActorQuery,
+ useGetMoviesByActorIdQuery,
+ useGetListQuery,
+} = tmdbApi;
diff --git a/src/utils/ToggleColorMode.jsx b/src/utils/ToggleColorMode.jsx
new file mode 100644
index 0000000..b7d191d
--- /dev/null
+++ b/src/utils/ToggleColorMode.jsx
@@ -0,0 +1,28 @@
+import { useState, useMemo, createContext } from 'react';
+import { ThemeProvider, createTheme } from "@mui/material/styles";
+
+export const ColorModeContext = createContext();
+
+function ToggleColorMode({ children }) {
+ const [mode, setMode] = useState('light');
+
+ const toggleColorMode = () => {
+ setMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light'));
+ };
+
+ const theme = useMemo(() => createTheme({
+ palette: {
+ mode,
+ },
+ }), [mode]);
+
+ return (
+
+
+ {children}
+
+
+ );
+}
+
+export default ToggleColorMode;
\ No newline at end of file
diff --git a/src/utils/index.js b/src/utils/index.js
new file mode 100644
index 0000000..09ced50
--- /dev/null
+++ b/src/utils/index.js
@@ -0,0 +1,40 @@
+import axios from 'axios';
+
+export const moviesApi = axios.create({
+ baseURL: 'https://api.themoviedb.org/3',
+ params: {
+ api_key: process.env.REACT_APP_TMDB_KEY,
+ },
+});
+
+export const fetchToken = async () => {
+ try {
+ const { data } = await moviesApi.get('/authentication/token/new');
+
+ const token = data.request_token;
+
+ if (data.success) {
+ localStorage.setItem('request_token', token);
+ window.location.href = `https://www.themoviedb.org/authenticate/${token}?redirect_to=${window.location.origin}/approved`;
+ }
+ } catch (error) {
+ console.log('Sorry, your token could not be created.');
+ }
+};
+
+export const createSessionId = async () => {
+ const token = localStorage.getItem('request_token');
+
+ if (token) {
+ try {
+ const { data: { session_id } } = await moviesApi.post('authentication/session/new', {
+ request_token: token,
+ });
+ localStorage.setItem('session_id', session_id);
+
+ return session_id;
+ } catch (error) {
+ console.log(error);
+ }
+ }
+};