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

Develop #192

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

nazar-medushevskyi
Copy link

src/App.tsx Outdated
import './App.scss';
import { useEffect } from 'react';
// import { Product } from './Components/ProductCards/Product';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

src/App.tsx Outdated
Comment on lines 6 to 7
import { HomePAge } from './Components/Pages/HomePage/HomePage';
import { Header } from './Components/Header/Header';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. rename Components to components (from lower case)
    create index.ts file to each component to export it like
components
--Pages
----HomePage
------HomePage.tsx
------HomePage.scss
------index.ts   <--------- export * from './HomePage'

and add general index.ts file directly to the components folder
and do like

export * from './Header'
export * from './Pages/HomePage'

etc

and you can import all necessary components from 1 import

import { HomePage, Header, NotFoundPage } from './components'

src/App.tsx Outdated
import { useEffect } from 'react';
// import { Product } from './Components/ProductCards/Product';
import { FavoriteContextProvider } from './FavoriteContext';
import { HomePAge } from './Components/Pages/HomePage/HomePage';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HomePage*

src/App.tsx Outdated
}, [location]);

return (
<>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need fragment here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this element before writing the provider, fixed it, thanks

src/App.tsx Outdated
return (
<>
<FavoriteContextProvider>
<Header searchValue="" setSearchValue={() => null} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about search functionality?)

src/App.tsx Outdated
element={(
<NotFoundPage
title="Tables"
h1="Tablet page under construction"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to rename this h1 to header for example

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but I did it on purpose so as not to get confused, since this h1 is used at all times when it says that the page was not found, I'll figure out what to do with it

src/App.tsx Outdated
/>
)}
/> */}
<Route path="/favorite" element={<Favorite />} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/favorites

src/App.tsx Outdated
)}
/> */}
<Route path="/favorite" element={<Favorite />} />
<Route path="/basket" element={<Basket />} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: should be /cart

src/App.tsx Outdated
<Route path="/favorite" element={<Favorite />} />
<Route path="/basket" element={<Basket />} />
<Route path="/contacts" element={<ContactsPage />} />
<Route path="/rights" element={<Rights />} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to rename path like /privacy-policy

Copy link

@sTorba24 sTorba24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Lest improve it

Now url is incorrect and should be not found page
image

remove hover effect for disabled button here
image

not changed total and number of items
image

Copy link

@DarkMistyRoom DarkMistyRoom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • use cart instead of basket to pass the test
image
  • add data-cy to this button
image
  • add all required data-cy attributes to Home Page

  • please check all tests and try to fix them

  • check the font

image
  • update the total by changing the number of items in the cart
image
  • it would be great to make search order-insensitive
image

|| favorites.includes(product.phoneId.toString()),
);

console.log(filtration);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console.log

line-height: 21px;
/* 150% */
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an empty line

Copy link
Author

@nazar-medushevskyi nazar-medushevskyi Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comments, I am in the process of making corrections. Regarding the tests - I reviewed the approved tasks, and it seems none of them have been passed. I tried to complete them, but it seems impossible to me.🤔👀🥲

};

return (
<>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant fragment

<li className="footer__FirstChild-nav-item">
<Link
to="/contacts"
className={`footer__FirstChild-nav-link ${location.pathname === '/contacts' ? 'is-activee' : ''}`}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use classNames package for such complex classes

Comment on lines 50 to 53
<NavLink to="/" className="logoLink">
<img className={`logoImage ${isHomePage ? 'is-home-page' : ''}`} src={LogoImage} alt="Logo" />
</NavLink>
</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can rewrite it
Uploading image.png…

Comment on lines 16 to 28
const isHomePage = location.pathname === '/';
const contacts = location.pathname === '/contacts';
const rights = location.pathname === '/rights';
const phone = location.pathname === '/phones';
const tablets = location.pathname === '/tablets';
const accessories = location.pathname === '/accessories';
const basket = location.pathname === '/cart';
const favorite = location.pathname === '/favorites';
// const [showSearch, setShowSearch] = useState(!isHomePage);

let search = '';

if (!isHomePage && !contacts && !rights && !favorite && !basket) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isHomePage = location.pathname === '/';
const contacts = location.pathname === '/contacts';
const rights = location.pathname === '/rights';
const phone = location.pathname === '/phones';
const tablets = location.pathname === '/tablets';
const accessories = location.pathname === '/accessories';
const basket = location.pathname === '/cart';
const favorite = location.pathname === '/favorites';
// const [showSearch, setShowSearch] = useState(!isHomePage);
let search = '';
if (!isHomePage && !contacts && !rights && !favorite && !basket) {
// const [showSearch, setShowSearch] = useState(!isHomePage);
const ARRAY = ['/', '/rights', ....]
let search = '';
if (!ARRAY.includes(location.pathname)) {

you can rename this array and move out of the ccomponent

Copy link

@VitaliyBodnar VitaliyBodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the arrow icon should have a space from the right side
Screenshot 2023-07-27 at 17 21 12
  • menu should not be moved on logo hover
Screen.Recording.2023-07-27.at.17.22.13.mov
  • box-shadow is sliced
Screen.Recording.2023-07-27.at.17.22.42.mov
  • these buttons should be clickable for the slider navigation
Screen.Recording.2023-07-27.at.17.28.07.mov
  • this icon has a link for GitHub but it should have to slack
Screenshot 2023-07-27 at 17 30 34
  • adaptive layout?
  • you need to make this layout adaptive for any screens
Screenshot 2023-07-27 at 17 32 05

Copy link

@ivbutsykin ivbutsykin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the code has points for improvement, but the tasks are accomplished. Good job!

Please, take into account my comments.

You can also implement some improvements:

  1. Replace default <select> on custom implementation.
  2. Add minimal responsive UI
  3. Show another icon for favs and basket pages because it similar for "404" page)

import heartImage from './ProductsCardsFavoriteImage/heart.svg';
import './ProductsCardsFavorite.scss';
import { Product } from '../Product';
import { useFavoriteContext } from '../../../core/context/FavoriteContext/FavoriteContext'; // Укажите правильный путь к FavoriteContext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { useFavoriteContext } from '../../../core/context/FavoriteContext/FavoriteContext'; // Укажите правильный путь к FavoriteContext
import { useFavoriteContext } from '../../../core/context/FavoriteContext/FavoriteContext';

//
};

const FavoriteContext = createContext<FavoriteContextValue>({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about to rename this context in sth general (because now it takes basket and fav)

More over, better to split it in two separate contexts for favs, and basket. It will be better for perfomance and code maintainable

Comment on lines +17 to +23
let totalQuantity = 0;

basket.forEach((product) => {
totalQuantity += product.quantity;
});

return totalQuantity;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use reduce method everywhere instead calculate it in such way


import { FavoriteContextValue } from './types';

const noop = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, interesting. But I don't fun of it, perhaps better repeat () => {} or don't use default value for them

Comment on lines +9 to +10
(product) => favorites.includes(product.id.toString())
|| favorites.includes(product.phoneId.toString()),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to choose one: id or phoneId and work with them

const [isChecked, setIsChecked] = useState(false);

const handleToggleclickk = () => {
setIsChecked(!isChecked);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setIsChecked(!isChecked);
setIsChecked(prev => !prev);

return totalQuantity;
};

const filtration = products.filter(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's need to wrap in useMemo for correct work)

Theme relates on react-hooks/exhaustive-deps rule. Important rule for working with React

removeFromBasket: (productId: string) => void;
removeFromAllB: (productId: string) => void;
favoritesLength: number;
basketLength: number;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, don't store it Context. use basket.length directly in components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants