Skip to content

Commit

Permalink
navigation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Lusaya committed Jun 7, 2023
1 parent 23687dc commit 0dede9c
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 87 deletions.
18 changes: 9 additions & 9 deletions .firebase/hosting.YnVpbGQ.cache
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ logo192.png,499162500000,3ee59515172ee198f3be375979df15ac5345183e656720a381b8872
logo512.png,499162500000,ee7e2f3fdb8209c4b6fd7bef6ba50d1b9dba30a25bb5c3126df057e1cb6f5331
manifest.json,499162500000,aff3449bdc238776f5d6d967f19ec491b36aed5fb7f23ccff6500736fd58494a
robots.txt,499162500000,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
asset-manifest.json,1685945667739,4767cfb336b9a1f6986124812db830f1a421fe69e3c675f52d8fc92645b39942
static/js/787.33bd62bf.chunk.js,1685945667759,d9c13b716322f9b7ca33c50680af185054caea5c4e973c950f52f53706ab94d8
static/js/787.33bd62bf.chunk.js.map,1685945667760,c59c62b0295c024ebb17bea584868da2993e9859c98712e82a85f8f082f4c49a
index.html,1685945667734,0b4189229eaefad512603f7698733adbd2aa7436705e15ee4c0e223cbe672925
static/js/main.b80cbc3a.js.LICENSE.txt,1685945667760,2a4bb45de3586615f82c7b031d826d7e72640b3c4cf786bd4ca9427a478b7c32
static/css/main.40b9751b.css,1685945667759,cf17228ddcdb8dce3a937800ce6afcbf5392b1e7621237aca853a2f28ad7d0a4
static/css/main.40b9751b.css.map,1685945667759,af198990aeec926671b19438c56367a3a23b5e217adb98c0c7b209239c8c918a
static/js/main.b80cbc3a.js,1685945667760,6ebba748e4d85494fda1b0392bb5ab6dc89ded397b147a25b8a7fccb5cd4136c
static/js/main.b80cbc3a.js.map,1685945667763,b28efc63a0b9403730172eb5a19e4c90f7f2b2337bed7828da443603120bb6db
asset-manifest.json,1685976861173,c1cb2cf45c7e04b292201225d5b2bbd556000154271788941bd04d1986d53b1d
static/css/main.742ae3db.css.map,1685976861314,9a6d7a2a94c72e3f7dc53ab3d53cbde5748e947fecaaa6941791a71dc488828a
static/js/787.33bd62bf.chunk.js,1685976861284,d9c13b716322f9b7ca33c50680af185054caea5c4e973c950f52f53706ab94d8
static/css/main.742ae3db.css,1685976861284,f4a14bf2d30d7fe43948cc58b3b36a71fb3b4f375803be6727b6bbeeae39193f
index.html,1685976861160,6f892e095be96c440b3c0e0792cfcfcac8b3b7398c281710588eb72eed8500c2
static/js/787.33bd62bf.chunk.js.map,1685976861385,c59c62b0295c024ebb17bea584868da2993e9859c98712e82a85f8f082f4c49a
static/js/main.d05dcaf7.js.LICENSE.txt,1685976861383,2a4bb45de3586615f82c7b031d826d7e72640b3c4cf786bd4ca9427a478b7c32
static/js/main.d05dcaf7.js,1685976861406,a71d2845339cdf1f95b512ebabe1d1e86992320cd0b40d4c8657a6df017b1fb7
static/js/main.d05dcaf7.js.map,1685976861313,322b019945c2e14b7219536e9953ad70577e93fc409c7af58cfd382897b0f0e8
23 changes: 22 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,30 @@ button[type='submit']:hover {
width: 70%;

}
.allRecomendations{
.recommend{
margin-top: 10px;
color: white;
margin-left: 10px;


}
.recommend h2{
font-size: 20px;
}
.recommend p{
font-size: 20px;
}
.waveContainer{
margin-left: 10px;
}
.allRecomendations{
margin-left: 0px;
}
.subtitle{
margin: auto;
width: 100%;
font-size: 13px;
}
.auth{
margin-left: 0%;
}
Expand Down
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SeriesDetails from './components/SeriesDetails';
import Recommendations from './components/Recommendations';
import RecommendMovie from './components/RecommendMovie';
import { auth } from './components/config/firebase';
import RecommendationDetails from './components/RecommendationDetails';
class App extends Component {
handleSignOut = () => {
auth.signOut() // Sign out the user using Firebase auth
Expand Down Expand Up @@ -41,6 +42,7 @@ class App extends Component {
<Route path="/tv-shows" element={<SeriesList />}/>
<Route path="/auth" element={<Auth />}/>
<Route path="/recommendations" element={<Recommendations />}/>
<Route path="/recommendation-details/:id" element={<RecommendationDetails />}/>
<Route path="/recommend" element={<RecommendMovie />}/>
<Route path="/movie-details/:id" element={<MovieDetails />} />
<Route path="/series-details/:id" element={<SeriesDetails />} />
Expand Down
6 changes: 0 additions & 6 deletions src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ import Movie from './Movie';

class Home extends Component {


render() {




return (
<div class='home'>

<Movie/>
</div>
);
Expand Down
122 changes: 74 additions & 48 deletions src/components/Movie.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,88 @@
import React, { Component } from 'react'
import {connect} from 'react-redux';
import {Link} from 'react-router-dom'
import { fetchMovies } from '../redux/action';

import '../App.css'
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { fetchMovies, searchMovies, setSearchTerm } from '../redux/action';

import '../App.css';

class Movie extends Component {
componentDidMount() {
this.props.fetchMovies();
}
handleSearch = () => {
const searchTerm = this.props.searchTerm;
this.props.searchMovies(searchTerm);
};
handleInputChange = (event) => {
const searchTerm = event.target.value;
this.props.setSearchTerm(searchTerm);
};


componentDidMount(){
this.props.fetchMovies()
}


render() {
const { movies, error } = this.props;
render() {
const { movies, searchResults, error } = this.props;
console.log(this.props.searchTerm);

if (error) {
return <div className='movieError'> {error}: Check Your Internet connection</div>;
}
if (error) {
return <div className="movieError">{error}: Check Your Internet connection</div>;
}

return (
<div class='movie'>
<h3>Popular 🔥</h3>
<div className="movie-card-container">
{movies.length === 0 ? (
<div className='load'>
<div className="loader ">
<div className="ball"></div>
<div className="ball"></div>
<div className="ball"></div>
</div>
</div>
) : (
movies.map((movie) => (
<Link to={`/movie-details/${movie.id}`} state={movie} className="movie-card-link" key={movie.id}>
<div className="movie-card">
<img
src={`https://image.tmdb.org/t/p/w500/${movie.poster_path}`}
alt="img"
className="movie-card__image"
/>
<div className="movie-card__details">
<h2 className="movie-card__title">{movie.title}</h2>
<p className="movie-card__overview">{movie.overview}</p>
</div>
</div>
</Link>
))
)}
</div>
const displayMovies = searchResults.length > 0 ? searchResults : movies;

</div>
);
}
return (
<div className="movie">

<h2>Trending Movies</h2>

<div className="movie-card-container">
{displayMovies.length === 0 ? (
<div className="load">
<div className="loader">
<div className="ball"></div>
<div className="ball"></div>
<div className="ball"></div>
</div>
</div>
) : (
displayMovies.map((movie) => (
<Link
to={`/movie-details/${movie.id}`}
state={movie}
className="movie-card-link"
key={movie.id}
>
<div className="movie-card">
<img
src={`https://image.tmdb.org/t/p/w500/${movie.poster_path}`}
alt="img"
className="movie-card__image"
/>
<div className="movie-card__details">
<h2 className="movie-card__title">{movie.title}</h2>
<p className="movie-card__overview">{movie.overview}</p>
</div>
</div>
</Link>
))
)}
</div>
</div>
);
}
}

const mapStateToProps = (state) => ({
movies: state.movies,
searchResults: state.searchResults,
error: state.error,
searchTerm: state.searchTerm
});
const mapDispatchToProps = (dispatch) => ({
fetchMovies: () => dispatch(fetchMovies()),
searchMovies: (searchTerm) => dispatch(searchMovies(searchTerm)),
setSearchTerm: (searchTerm) => dispatch(setSearchTerm(searchTerm)),
});

export default connect(mapStateToProps, { fetchMovies })(Movie);
export default connect(mapStateToProps,mapDispatchToProps)(Movie);
33 changes: 33 additions & 0 deletions src/components/RecommendationDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'
import { Link, useLocation } from "react-router-dom";
export default function RecommendationDetails() {
const location = useLocation();
const propsData = location.state;
console.log(propsData);
return (
<div>
{propsData && (
<div className="movie-details-container">
<div className="movie-details">
<div className="movie-details-content">

<p className="movie-details-title">{propsData.title}</p>
<p className="movie-details-overview">{propsData.description}</p>
<p className="movie-details-info">
<span className="movie-details-info-label">Release Year:</span> {propsData.releaseDate} <br/>
<span className="movie-details-info-label">Recommended By:</span> {propsData.recommender}
</p>

</div>

<div className="movie-details-image">
<img src={`${propsData.movieImage}`} alt="Movie Poster" />

</div>
</div>
</div>

)}
</div>
)
}
23 changes: 17 additions & 6 deletions src/components/Recommendations.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ handleResize = () => {
return (
<div className='allRecomendations'>
{isLoggedIn && (
<p className="alert">
Welcome {user}, you have recommended {userMoviesCount}{' '}
{userMoviesCount === 1 ? 'movie' : 'movies'} so far.
</p>
)}
<p className="alert">
{userMoviesCount === 0
? `Welcome ${user}, you have not recommended any movie yet.`
: `Welcome ${user}, you have recommended ${userMoviesCount} ${userMoviesCount === 1 ? 'movie' : 'movies'} so far.`}
</p>
)}

{isLoggedIn && (
<Link to="/recommend">
<button className="round-button">
Expand All @@ -108,17 +110,22 @@ handleResize = () => {
)}

<div className='recommendationss'>

<h3>Recommended By The Public</h3>
{movies.length === 0 ? (
<div className='load'>
<div className="loader ">
<div className="ball"></div>
<div className="ball"></div>
<div className="ball"></div>
</div>

</div>

) : (movies.map((movie) => (
<div>

<div key={movie.id} className='card'>

<div className='images'>
<img
src={movie.movieImage}
Expand All @@ -130,7 +137,9 @@ handleResize = () => {
</icon>
</div>
<div className='content'>
<Link to={`/recommendation-details/${movie.id}`} state={movie} style={{textDecoration:'none'}}>
<h4>{movie.title}</h4>
</Link>
<p>
{screenWidth <= 600
? movie.description.substring(0, 25) + '...'
Expand All @@ -153,7 +162,9 @@ handleResize = () => {
createdBy={movie.userId}
/>
</div>

</div>
</div>
))
)}
</div>
Expand Down
40 changes: 37 additions & 3 deletions src/redux/action.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FETCH_MOVIES_SUCCESS, FETCH_MOVIES_FAILURE,
FETCH_MOVIE_DETAILS_SUCCESS, FETCH_MOVIE_DETAILS_FAILURE, FETCH_SERIES_FAILURE,
FETCH_SERIES_SUCCESS } from "./types"
import { fetchMoviesApi } from '../services/movieService';
FETCH_MOVIE_DETAILS_SUCCESS, FETCH_MOVIE_DETAILS_FAILURE, FETCH_SERIES_FAILURE,SEARCH_MOVIES ,
FETCH_SERIES_SUCCESS,
SET_SEARCH_TERM} from "./types"
import { fetchMoviesApi, searchByKeywordsFromApi } from '../services/movieService';
import { fetchSeriesFromApi } from "../services/seriesService";
const apiKey = 'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzYTNmZGE2YzBkOTQzNzJmNGE2MTY3OGJiYmE2M2NiZSIsInN1YiI6IjVmMzJhMTAwNjYzYjg3MDAzNzUxNmQ2YiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.amIvSiL5AFK4h-bMvCjVFco6LHk86IiEVm4LlWlVhN8';

Expand Down Expand Up @@ -36,6 +37,19 @@ export const fetchMovieSuccess = (movies) => ({
payload: error,
});




export const searchMovies = (searchTerm) => {
return {
type: SEARCH_MOVIES,
payload: {
searchTerm
}
};
};


export const fetchMovies=() =>{
return (dispatch) => {
fetchMoviesApi(apiKey)
Expand All @@ -58,6 +72,26 @@ export const fetchMovieSuccess = (movies) => ({
}
}

export const handleSearch = (searchTerm) => {
return (dispatch, getState) => {

searchByKeywordsFromApi(searchTerm)
.then((response) => {
const searchResults = response.results;
dispatch(searchMovies(searchResults));
})
.catch((error) => {

dispatch(fetchMovieFailure(error.message));
});
};
};
export const setSearchTerm = (searchTerm) => ({
type: SET_SEARCH_TERM,
payload: {
searchTerm,
},
});
export const fetchMovieDetails = (movieId) => {
return (dispatch) => {
fetchMovieDetails(movieId, apiKey) // Replace `fetchMovieDetailsApi` with your actual API function to fetch movie details
Expand Down
Loading

0 comments on commit 0dede9c

Please sign in to comment.