-
Notifications
You must be signed in to change notification settings - Fork 223
[Don't Pull] MR for review purposes #60
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
Draft
SyedShahriar
wants to merge
12
commits into
codepath:main
Choose a base branch
from
Jenn-jaee:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
16d7387
My First Commit
c25beb4
Added the watch feature
7ebd4b2
Added the Side bar for watched and likes
c2d0df1
attempt to fix image on render deploy
c2fd32a
trying to fix watch status on render
03dcb3f
worked on my home nav bar
c808b9c
fixed nav bar issue, allow for overlay display and my home page rende…
9c43ced
modified my README file
640cc05
Update README.md
Jenn-jaee e000b56
Update README.md
Jenn-jaee 19aac60
made chages to my CSS to make it more moibile responsive
3921ba8
Modified movielist & moviecard code comments in response to IM's feed…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ const MovieList = () => { | |
| const [favorites, setFavorites] = useState([]); | ||
| const [watched, setWatched] = useState([]); | ||
| const [sidebarOpen, setSidebarOpen] = useState(false); | ||
| const [viewMode, setViewMode] = useState('all'); | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -89,34 +90,48 @@ const MovieList = () => { | |
| setSelectedMovie(data); | ||
| }; | ||
|
|
||
| const toggleFavorite = (movieId) => { | ||
| setFavorites((prevFavorites) => | ||
| prevFavorites.includes(movieId) | ||
| ? prevFavorites.filter((id) => id !== movieId) | ||
| : [...prevFavorites, movieId] | ||
| ); | ||
| }; | ||
| const toggleFavorite = (movie) => { | ||
| setFavorites((prevFavorites) => { | ||
| const isAlreadyFavorited = prevFavorites.some((m) => m.id === movie.id); | ||
| return isAlreadyFavorited | ||
| ? prevFavorites.filter((m) => m.id !== movie.id) | ||
| : [...prevFavorites, movie]; | ||
| }); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| const toggleWatched = (movie) => { | ||
| setWatched((prevWatched) => { | ||
| const isAlreadyWatched = prevWatched.some((m) => m.id === movie.id); | ||
| return isAlreadyWatched | ||
| ? prevWatched.filter((m) => m.id !== movie.id) | ||
| : [...prevWatched, movie]; | ||
| }); | ||
| }; | ||
|
|
||
| const toggleWatched = (movieId) => { | ||
| setWatched((prev) => | ||
| prev.includes(movieId) | ||
| ? prev.filter((id) => id !== movieId) | ||
| : [...prev, movieId] | ||
| ); | ||
| }; | ||
|
|
||
| const getSortedMovies = () => { | ||
| let sorted = [...movies]; | ||
|
|
||
| let filteredMovies; | ||
|
|
||
| if (viewMode === 'favorites') { | ||
| filteredMovies = [...favorites]; | ||
| } else if (viewMode === 'watched') { | ||
| filteredMovies = [...watched]; | ||
| } else { | ||
| filteredMovies = [...movies]; | ||
| } | ||
|
|
||
| if (sortOption === 'title') { | ||
| sorted.sort((a, b) => a.title.localeCompare(b.title)); | ||
| filteredMovies.sort((a, b) => a.title.localeCompare(b.title)); | ||
| } else if (sortOption === 'release') { | ||
| sorted.sort((a, b) => new Date(b.release_date) - new Date(a.release_date)); | ||
| filteredMovies.sort((a, b) => new Date(b.release_date) - new Date(a.release_date)); | ||
| } else if (sortOption === 'rating') { | ||
| sorted.sort((a, b) => b.vote_average - a.vote_average); | ||
| filteredMovies.sort((a, b) => b.vote_average - a.vote_average); | ||
| } | ||
|
|
||
| return sorted; | ||
| return filteredMovies; | ||
| }; | ||
|
|
||
| const clearSearchBtn = () => { | ||
|
|
@@ -127,31 +142,38 @@ const MovieList = () => { | |
|
|
||
| // for sidebar home | ||
| const homePage = () => { | ||
| setSearchQuery(''); | ||
| setViewMode('all'); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets add a comment as to why we set the view Mode here to 'all' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a more explanatory comment on why |
||
| setMode('nowPlaying'); | ||
| setSidebarOpen(!sidebarOpen) | ||
| setPage(1); | ||
| setHasMore(true); | ||
| fetchMovies(1, 'nowPlaying'); | ||
| setSidebarOpen(false); | ||
| } | ||
|
|
||
| // Function to pass to the child component for the "Favorites" button click | ||
| // const handleShowFavorites = () => { | ||
| // alert("Displaying liked movies: " + prevFavorites.map(movieId => movie.title).join(', ')); | ||
| // }; | ||
|
|
||
|
|
||
|
|
||
| return ( | ||
|
|
||
| return ( | ||
| <div className="layout-container"> | ||
| <button className="sidebar-toggle" onClick={() => setSidebarOpen(!sidebarOpen)}> | ||
| ☰ | ||
| </button> | ||
| {sidebarOpen && ( | ||
|
|
||
| <Sidebar | ||
| mode = {homePage} | ||
| favorites={movies.filter((m) => favorites.includes(m.id))} | ||
| watched={movies.filter((m) => watched.includes(m.id))} | ||
| onClose={() => setSidebarOpen(false)} | ||
| mode={homePage} | ||
| favorites={favorites} | ||
| watched={watched} | ||
| onSelectView={(mode) => { | ||
| setViewMode(mode); | ||
| setSidebarOpen(false); // close after click | ||
| }} | ||
| /> | ||
|
|
||
| )} | ||
|
|
||
|
|
||
| <main> | ||
| {selectedMovie && ( | ||
| <MovieModal | ||
|
|
@@ -193,11 +215,12 @@ const MovieList = () => { | |
| title={movie.title} | ||
| posterPath={movie.poster_path} | ||
| voteAverage={movie.vote_average} | ||
| isFavorite={favorites.includes(movie.id)} | ||
| onToggleFavorite={() => toggleFavorite(movie.id)} | ||
| hasWatched={watched.includes(movie.id)} | ||
| onToggleWatched={() => toggleWatched(movie.id)} | ||
| isFavorite={favorites.some((fav) => fav.id === movie.id)} | ||
| onToggleFavorite={() => toggleFavorite(movie)} | ||
| hasWatched={watched.some((w) => w.id === movie.id)} | ||
| onToggleWatched={() => toggleWatched(movie)} | ||
| /> | ||
|
|
||
| </div> | ||
| ))} | ||
| </div> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this, because its for the side bar on the homepage. This way it better represents what we are setting up for.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the comment to reflect where the homepage is located for better clarity