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

Level 3 #2

Merged
merged 43 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
31bbcf5
feat/fix: add register/fix button in form
Chill-Peppa Jun 15, 2023
b9d7cf7
feat: add Login functional
Chill-Peppa Jun 16, 2023
65f11ff
feat: add validation to login and register
Chill-Peppa Jun 16, 2023
bf47e1e
feat: with wrong userData
Chill-Peppa Jun 17, 2023
8eca6be
feat: with right profile
Chill-Peppa Jun 18, 2023
6aee219
feat: add protected route
Chill-Peppa Jun 18, 2023
e4aee11
feat: profile without email validation and text
Chill-Peppa Jun 18, 2023
81c6866
feat: all forms without only email valid and errors-texts
Chill-Peppa Jun 18, 2023
426d17a
feat/fix: get cards from api/fix movies card style
Chill-Peppa Jun 19, 2023
c1e051c
feat: add full validation without search form!!!
Chill-Peppa Jun 20, 2023
dc3704e
feat/fix: add full register & login/fix button profile
Chill-Peppa Jun 21, 2023
ec03051
feat: add full profile
Chill-Peppa Jun 21, 2023
3bb9e49
feat: add validation to search
Chill-Peppa Jun 22, 2023
9be228d
fix: fix validation in search form
Chill-Peppa Jun 22, 2023
863986f
feat: add full main api + add delete btn for saved movies
Chill-Peppa Jun 24, 2023
5eaaf23
feat: add search without checkbox
Chill-Peppa Jun 25, 2023
ff45f56
feat: FILTERED BY CHECKBOX!!
Chill-Peppa Jun 25, 2023
6ee17a3
feat: search without localstorage input, errors & preloader
Chill-Peppa Jun 25, 2023
5204c23
feat: localStorage save input val + add preloader in movies
Chill-Peppa Jun 26, 2023
03eb3dc
feat: add mistakes in search
Chill-Peppa Jun 26, 2023
8a7463a
feat: with wrong movies errors text and validation
Chill-Peppa Jun 26, 2023
22cd199
feat: full search for movies
Chill-Peppa Jun 27, 2023
6625ef0
feat: add pagination
Chill-Peppa Jun 29, 2023
6741aac
fix: fix button more for checklist
Chill-Peppa Jun 30, 2023
f9b4189
feat/fix: add api for like and dislike/fix: fix error api in profile
Chill-Peppa Jul 1, 2023
34a1bf5
feat: add likes without save in LS
Chill-Peppa Jul 1, 2023
781ebb5
feat: with problem likes
Chill-Peppa Jul 1, 2023
df34a43
feat: full likes functional
Chill-Peppa Jul 2, 2023
4eea3d0
feat: full favorite movies, but likes dont work correct in filtered arr
Chill-Peppa Jul 2, 2023
6a35cdf
fix: fix trouble with likes
Chill-Peppa Jul 2, 2023
e89f621
hotfix: fix some little bugs befor deploy
Chill-Peppa Jul 2, 2023
72044b6
hotfix/feat: delete logs & comments/add homepage
Chill-Peppa Jul 2, 2023
18a05f4
hotfix: fix header
Chill-Peppa Jul 2, 2023
bcc1b6f
fix: fix header p.2
Chill-Peppa Jul 2, 2023
b4c59b3
feat: deploy settings
Chill-Peppa Jul 2, 2023
65fda79
docs: rewrite link in readme
Chill-Peppa Jul 2, 2023
9318ab1
docs: links in readme
Chill-Peppa Jul 2, 2023
a864560
hothix: remove last logs
Chill-Peppa Jul 2, 2023
d92f8e1
docs: add pull request
Chill-Peppa Jul 2, 2023
71da2b1
fix: rewrite about me component
Chill-Peppa Jul 3, 2023
29c8c21
fix: fix all without likes
Chill-Peppa Jul 3, 2023
6ab1bbf
fix: last fixies likes after review p.1
Chill-Peppa Jul 3, 2023
3d25bc8
fix: run build and deploy
Chill-Peppa Jul 3, 2023
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
feat: add full main api + add delete btn for saved movies
  • Loading branch information
Chill-Peppa committed Jun 24, 2023
commit 863986ff78bd0a585853eff523cfc2a3e4813b09
16 changes: 15 additions & 1 deletion src/components/Movies/Movies.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ import SearchForm from '../SearchForm/SearchForm';
import MoviesCardList from '../MoviesCardList/MoviesCardList';

function Movies({ movies }) {
//стейт отфильтрованного массива с результатом
/*const [filteredMovies, setFilteredMovies] = React.useState([]);

const handleFilterMovies = (inputValue) => {
setFilteredMovies(
movies.filter((movie) => {
return (
movie.nameRU.toLowerCase().includes(inputValue) ||
movie.nameEN.toLowerCase().includes(inputValue)
);
}),
);
};*/

return (
<section className="movies">
<SearchForm />
<SearchForm /*onFilter={handleFilterMovies}*/ />
<MoviesCardList movies={movies} />
<div className="movies__button-zone">
<button className="movies__button" type="button">
Expand Down
18 changes: 18 additions & 0 deletions src/components/MoviesCard/MoviesCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@
}
}

.movies-card__delete {
cursor: pointer;
border: none;
box-sizing: border-box;
background: url('../../images/delete.svg');
background-position: center;
background-repeat: no-repeat;
background-color: transparent;
border: none;
width: 14px;
}

@media screen and (max-width: 450px) {
.movies-card__delete {
margin: 0;
}
}

.movies-card__duration {
padding: 0 0 16px 16px;
font-style: normal;
Expand Down
12 changes: 10 additions & 2 deletions src/components/MoviesCard/MoviesCard.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { useLocation, Link } from 'react-router-dom';

import './MoviesCard.css';
import { timeConverter } from '../../utils/functions/timeConverter';
import { baseImgLink } from '../../utils/constants';

function MoviesCard({ movie }) {
const { pathname } = useLocation();

return (
<li className="movies-card">
<Link
Expand All @@ -20,7 +22,13 @@ function MoviesCard({ movie }) {
</Link>
<div className="movies-card__about">
<h2 className="movies-card__header">{movie.nameRU}</h2>
<button type="button" className="movies-card__icon" alt="Лайк" />

{pathname === '/movies' && (
<button type="button" className="movies-card__icon" alt="Лайк" />
)}
{pathname === '/saved-movies' && (
<button type="button" className="movies-card__delete" alt="Крестик" />
)}
</div>
<span className="movies-card__duration">
{timeConverter(movie.duration)}
Expand Down
10 changes: 8 additions & 2 deletions src/components/SearchForm/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import FilterCheckbox from '../FilterCheckbox/FilterCheckbox';
import { useFormAndValidation } from '../../hooks/useFormAndValidation';
import { validateSearch } from '../../utils/functions/validators';

function SearchForm() {
function SearchForm({ onFilter }) {
const { values, handleChange, isValid } = useFormAndValidation();

const handleSubmit = (e) => {
e.preventDefault();
//тут будет функция на поиск и отображение фильмов (отфильтрованных)
onFilter(values.search);
};

return (
<section className="search-form">
<form className="search-form__input-zone">
<form className="search-form__input-zone" onSubmit={handleSubmit}>
<input
className="search-form__input"
name="search"
Expand Down
3 changes: 3 additions & 0 deletions src/images/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions src/utils/api/MainApi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { baseImgLink } from '../constants';

export default class MainApi {
constructor({ url, headers }) {
this._url = url;
Expand Down Expand Up @@ -35,4 +37,40 @@ export default class MainApi {
}),
});
}

//получаем сохраненные фильмы
getSavedMovies() {
return this._request(`${this._url}/movies`, {
headers: this._headers,
});
}

//добавить в избранное
saveMovie(movie) {
return this._request(`${this._url}/movies`, {
method: 'POST',
body: JSON.stringify({
country: movie.country,
director: movie.director,
duration: movie.duration,
year: movie.year,
description: movie.description,
image: `${baseImgLink}${movie.image.url}`,
trailerLink: movie.trailerLink,
thumbnail: `${baseImgLink}${movie.image.formats.thumbnail.url}`,
movieId: movie.id,
nameRU: movie.nameRU,
nameEN: movie.nameEN,
}),
headers: this._headers,
}).then(this._returnResponse);
}

//удалить из избранного
deleteMovie(id) {
return this._request(`${this._url}/movies/${id}`, {
method: 'DELETE',
headers: this._headers,
}).then(this._returnResponse);
}
}