Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Movie Finder #1

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9d45d83
Remove unnecessary code and install necessary packages
jcy2704 Apr 7, 2021
77c78f5
Remove yarn.lock
jcy2704 Apr 7, 2021
c364d11
Add node version to package.json
jcy2704 Apr 7, 2021
8dbe413
Fix React error
jcy2704 Apr 7, 2021
4c67629
Divide into folders
jcy2704 Apr 7, 2021
dbe7d92
Add fonts and scss
jcy2704 Apr 7, 2021
77db71f
Start Routes
jcy2704 Apr 7, 2021
680408e
Add api calls
jcy2704 Apr 7, 2021
6ea1282
Reinstall packages
jcy2704 Apr 7, 2021
a91efb0
Add linters
jcy2704 Apr 7, 2021
623bd41
Add actions and start reducers
jcy2704 Apr 7, 2021
dc801bc
Finish reducers methods
jcy2704 Apr 7, 2021
66e76fe
Fix api issues
jcy2704 Apr 7, 2021
59b074b
Create hero component
jcy2704 Apr 7, 2021
59c3be3
Add first movie
jcy2704 Apr 7, 2021
c852e99
Finish hero section
jcy2704 Apr 8, 2021
751a166
Add random int helper
jcy2704 Apr 8, 2021
2204d98
Divide genres list from method
jcy2704 Apr 8, 2021
61eedc6
Add video api
jcy2704 Apr 8, 2021
ec5c0db
Add loading screen and start popular section
jcy2704 Apr 8, 2021
ce0f699
Create new reducer for trending only
jcy2704 Apr 8, 2021
aa19966
Finish Popular catalogue
jcy2704 Apr 8, 2021
59915e8
Finish top rated and upcoming
jcy2704 Apr 8, 2021
8752dad
Add more api calls for popular
jcy2704 Apr 8, 2021
fa1cf50
Solve environmental variables issue
jcy2704 Apr 8, 2021
26b11ca
Add Navigation and styling
jcy2704 Apr 9, 2021
9fab3cc
Start filter modal
jcy2704 Apr 9, 2021
ead435c
Finish filter modal
jcy2704 Apr 9, 2021
a088357
Add reset button to filter modal
jcy2704 Apr 9, 2021
522a3b4
Add modals for movies
jcy2704 Apr 9, 2021
72b0d34
Add close icon for movie modals
jcy2704 Apr 9, 2021
c9bf0d3
Refactor some code to helpers
jcy2704 Apr 9, 2021
6c476f9
Refactor api methods
jcy2704 Apr 9, 2021
77e7289
Finish styling filter modal
jcy2704 Apr 9, 2021
954ecc9
Finish filters
jcy2704 Apr 10, 2021
40d5cf7
Add more movies
jcy2704 Apr 10, 2021
b6cf893
Add modals container
jcy2704 Apr 10, 2021
5932329
Update README.md
jcy2704 Apr 10, 2021
201928c
Update README.md
jcy2704 Apr 10, 2021
92ac6ed
Fix linters
jcy2704 Apr 10, 2021
18e3a58
Update README.md
jcy2704 Apr 10, 2021
aa60d52
Change favicon
jcy2704 Apr 11, 2021
4053ac3
Update README.md
jcy2704 Apr 11, 2021
3fdf87d
Fix trailer links
jcy2704 Apr 11, 2021
db0944f
Update README.md
jcy2704 Apr 11, 2021
041117d
Update README.md
jcy2704 Apr 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more movies
  • Loading branch information
jcy2704 committed Apr 10, 2021
commit 40d5cf7705427fbb83bbf87330deb01c00f06111
2 changes: 2 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export const GET_TOP_RATED = 'GET_TOP_RATED';
export const ADD_FILTER = 'ADD_FILTER';
export const REMOVE_FILTER = 'REMOVE_FILTER';
export const RESET_FILTER = 'RESET_FILTER';
export const ADD_MOVIES = 'ADD_MOVIES';

export const loadTrending = movie => ({ type: GET_TRENDING, movie });
export const addMovies = movies => ({ type: ADD_MOVIES, movies });
export const loadPopular = movies => ({ type: GET_POPULAR, movies });
export const loadTopRated = movies => ({ type: GET_TOP_RATED, movies });
export const loadUpcoming = movies => ({ type: GET_UPCOMING, movies });
Expand Down
10 changes: 7 additions & 3 deletions src/containers/Popular.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { PopularMovies } from '../helpers/api_methods/api';
import { loadPopular } from '../actions';
import { addMovies, loadPopular } from '../actions';
import Loading from '../components/Loading';
import '../styles/catalogue/Catalogue.css';
import MoviePoster from './MoviePoster';
import filteredMovies from '../helpers/filter';

const PopularCatalogue = ({ movies, loader, filters }) => {
const PopularCatalogue = ({
movies, loader, filters, adder,
}) => {
const [isLoading, setLoading] = useState(true);

useEffect(() => {
PopularMovies(loader, setLoading);
PopularMovies(loader, setLoading, adder);
}, [loader]);

if (isLoading) {
Expand All @@ -32,12 +34,14 @@ PopularCatalogue.propTypes = {
filters: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
movies: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
loader: PropTypes.func.isRequired,
adder: PropTypes.func.isRequired,
};

const mapStateToProps = state => ({ movies: state.movies, filters: state.filter });

const mapDispatchToProps = dispatch => ({
loader: movies => dispatch(loadPopular(movies)),
adder: movies => dispatch(addMovies(movies)),
});

export default connect(mapStateToProps, mapDispatchToProps)(PopularCatalogue);
10 changes: 7 additions & 3 deletions src/containers/TopRated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { TopRatedMovies } from '../helpers/api_methods/api';
import { loadTopRated } from '../actions';
import { addMovies, loadTopRated } from '../actions';
import Loading from '../components/Loading';
import '../styles/catalogue/Catalogue.css';
import MoviePoster from './MoviePoster';
import filteredMovies from '../helpers/filter';

const PopularCatalogue = ({ movies, loader, filters }) => {
const PopularCatalogue = ({
movies, loader, filters, adder,
}) => {
const [isLoading, setLoading] = useState(true);

useEffect(() => {
TopRatedMovies(loader, setLoading);
TopRatedMovies(loader, setLoading, adder);
}, [loader]);

if (isLoading) {
Expand All @@ -32,12 +34,14 @@ PopularCatalogue.propTypes = {
movies: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
filters: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
loader: PropTypes.func.isRequired,
adder: PropTypes.func.isRequired,
};

const mapStateToProps = state => ({ movies: state.movies, filters: state.filter });

const mapDispatchToProps = dispatch => ({
loader: movies => dispatch(loadTopRated(movies)),
adder: movies => dispatch(addMovies(movies)),
});

export default connect(mapStateToProps, mapDispatchToProps)(PopularCatalogue);
10 changes: 7 additions & 3 deletions src/containers/Upcoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { UpcomingMovies } from '../helpers/api_methods/api';
import { loadUpcoming } from '../actions';
import { addMovies, loadUpcoming } from '../actions';
import Loading from '../components/Loading';
import '../styles/catalogue/Catalogue.css';
import MoviePoster from './MoviePoster';
import filteredMovies from '../helpers/filter';

const PopularCatalogue = ({ movies, loader, filters }) => {
const PopularCatalogue = ({
movies, loader, filters, adder,
}) => {
const [isLoading, setLoading] = useState(true);

useEffect(() => {
UpcomingMovies(loader, setLoading);
UpcomingMovies(loader, setLoading, adder);
}, [loader]);

if (isLoading) {
Expand All @@ -32,12 +34,14 @@ PopularCatalogue.propTypes = {
movies: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
filters: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
loader: PropTypes.func.isRequired,
adder: PropTypes.func.isRequired,
};

const mapStateToProps = state => ({ movies: state.movies, filters: state.filter });

const mapDispatchToProps = dispatch => ({
loader: movies => dispatch(loadUpcoming(movies)),
adder: movies => dispatch(addMovies(movies)),
});

export default connect(mapStateToProps, mapDispatchToProps)(PopularCatalogue);
18 changes: 15 additions & 3 deletions src/helpers/api_methods/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,38 @@ export const topTrending = async (loader, setLoading, setVideoURL) => {
});
};

export const PopularMovies = async (loader, setLoading) => {
export const PopularMovies = async (loader, setLoading, adder) => {
await axios.get(`${process.env.REACT_APP_POPULAR}?api_key=${process.env.REACT_APP_API_KEY}`)
.then(response => {
loader(response.data.results);
axios.get(`${process.env.REACT_APP_POPULAR}?api_key=${process.env.REACT_APP_API_KEY}&page=2`)
.then(response => adder(response.data.results));
axios.get(`${process.env.REACT_APP_POPULAR}?api_key=${process.env.REACT_APP_API_KEY}&page=3`)
.then(response => adder(response.data.results));
setLoading(false);
});
};

export const TopRatedMovies = async (loader, setLoading) => {
export const TopRatedMovies = async (loader, setLoading, adder) => {
await axios.get(`${process.env.REACT_APP_TOP_RATED}?api_key=${process.env.REACT_APP_API_KEY}`)
.then(response => {
loader(response.data.results);
axios.get(`${process.env.REACT_APP_TOP_RATED}?api_key=${process.env.REACT_APP_API_KEY}&page=2`)
.then(response => adder(response.data.results));
axios.get(`${process.env.REACT_APP_TOP_RATED}?api_key=${process.env.REACT_APP_API_KEY}&page=3`)
.then(response => adder(response.data.results));
setLoading(false);
});
};

export const UpcomingMovies = async (loader, setLoading) => {
export const UpcomingMovies = async (loader, setLoading, adder) => {
await axios.get(`${process.env.REACT_APP_UPCOMING}?api_key=${process.env.REACT_APP_API_KEY}`)
.then(response => {
loader(response.data.results);
axios.get(`${process.env.REACT_APP_UPCOMING}?api_key=${process.env.REACT_APP_API_KEY}&page=2`)
.then(response => adder(response.data.results));
axios.get(`${process.env.REACT_APP_UPCOMING}?api_key=${process.env.REACT_APP_API_KEY}&page=3`)
.then(response => adder(response.data.results));
setLoading(false);
});
};
4 changes: 3 additions & 1 deletion src/reducers/movies.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
GET_UPCOMING, GET_POPULAR, GET_TOP_RATED,
GET_UPCOMING, GET_POPULAR, GET_TOP_RATED, ADD_MOVIES,
} from '../actions';

const moviesReducer = (state = [], action) => {
switch (action.type) {
case ADD_MOVIES:
return [...state, ...action.movies];
case GET_POPULAR:
return action.movies;
case GET_TOP_RATED:
Expand Down