-
Notifications
You must be signed in to change notification settings - Fork 719
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
base: master
Are you sure you want to change the base?
Develop #192
Conversation
nazar-medushevskyi
commented
Jul 23, 2023
- DEMO LINK(https://nazar-medushevskyi.github.io/react_phone-catalog)
src/App.tsx
Outdated
import './App.scss'; | ||
import { useEffect } from 'react'; | ||
// import { Product } from './Components/ProductCards/Product'; |
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.
remove commented code
src/App.tsx
Outdated
import { HomePAge } from './Components/Pages/HomePage/HomePage'; | ||
import { Header } from './Components/Header/Header'; |
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.
- rename
Components
tocomponents
(from lower case)
createindex.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'; |
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.
HomePage*
src/App.tsx
Outdated
}, [location]); | ||
|
||
return ( | ||
<> |
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.
why do we need fragment here?
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.
I created this element before writing the provider, fixed it, thanks
src/App.tsx
Outdated
return ( | ||
<> | ||
<FavoriteContextProvider> | ||
<Header searchValue="" setSearchValue={() => null} /> |
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.
what about search functionality?)
src/App.tsx
Outdated
element={( | ||
<NotFoundPage | ||
title="Tables" | ||
h1="Tablet page under construction" |
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.
would be better to rename this h1
to header
for example
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.
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 />} /> |
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.
/favorites
src/App.tsx
Outdated
)} | ||
/> */} | ||
<Route path="/favorite" element={<Favorite />} /> | ||
<Route path="/basket" element={<Basket />} /> |
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.
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 />} /> |
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.
would be better to rename path like /privacy-policy
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.
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.
|| favorites.includes(product.phoneId.toString()), | ||
); | ||
|
||
console.log(filtration); |
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.
remove console.log
line-height: 21px; | ||
/* 150% */ | ||
} | ||
} |
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.
add an empty line
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.
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.🤔👀🥲
src/Components/Footer/Footer.tsx
Outdated
}; | ||
|
||
return ( | ||
<> |
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.
redundant fragment
src/Components/Footer/Footer.tsx
Outdated
<li className="footer__FirstChild-nav-item"> | ||
<Link | ||
to="/contacts" | ||
className={`footer__FirstChild-nav-link ${location.pathname === '/contacts' ? 'is-activee' : ''}`} |
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.
let's use classNames package for such complex classes
src/Components/Header/Header.tsx
Outdated
<NavLink to="/" className="logoLink"> | ||
<img className={`logoImage ${isHomePage ? 'is-home-page' : ''}`} src={LogoImage} alt="Logo" /> | ||
</NavLink> | ||
</div> |
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.
src/Components/Header/Header.tsx
Outdated
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) { |
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.
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
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.
- the arrow icon should have a space from the right side
- 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
- adaptive layout?
- you need to make this layout adaptive for any screens
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.
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:
- Replace default
<select>
on custom implementation. - Add minimal responsive UI
- 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 |
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.
import { useFavoriteContext } from '../../../core/context/FavoriteContext/FavoriteContext'; // Укажите правильный путь к FavoriteContext | |
import { useFavoriteContext } from '../../../core/context/FavoriteContext/FavoriteContext'; |
// | ||
}; | ||
|
||
const FavoriteContext = createContext<FavoriteContextValue>({ |
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.
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
let totalQuantity = 0; | ||
|
||
basket.forEach((product) => { | ||
totalQuantity += product.quantity; | ||
}); | ||
|
||
return totalQuantity; |
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.
Use reduce
method everywhere instead calculate it in such way
|
||
import { FavoriteContextValue } from './types'; | ||
|
||
const noop = () => { |
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.
Ha, interesting. But I don't fun of it, perhaps better repeat () => {}
or don't use default value for them
(product) => favorites.includes(product.id.toString()) | ||
|| favorites.includes(product.phoneId.toString()), |
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.
Better to choose one: id
or phoneId
and work with them
const [isChecked, setIsChecked] = useState(false); | ||
|
||
const handleToggleclickk = () => { | ||
setIsChecked(!isChecked); |
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.
setIsChecked(!isChecked); | |
setIsChecked(prev => !prev); |
return totalQuantity; | ||
}; | ||
|
||
const filtration = products.filter( |
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.
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; |
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.
Nope, don't store it Context
. use basket.length
directly in components