-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/os 50 fe create pagination category page mob #74
Feature/os 50 fe create pagination category page mob #74
Conversation
….com/Vadim-Kostetskyi/Online-store into feature/OS-50-FE-Create-pagination-Category-Page-mob
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<> | ||
<Header /> | ||
<div className={styles.main}>{children}</div> | ||
<div className={`${styles.main} ${isLoading ? styles.mainMaxHeight : ''}`}> |
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.
<div className={`${styles.main} ${isLoading ? styles.mainMaxHeight : ''}`}> | |
<div className={getValidClassNames(styles.main, { [styles.mainMaxHeight]: isLoading })}> | |
className={`${styles.paginationButton} ${ | ||
isDisabled ? styles.paginationDisabled : '' | ||
}`} |
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.
consider using getValidClassNames
{isDisabled ? ( | ||
isPrevious ? ( | ||
<ArrowLeftGrey /> | ||
) : ( | ||
<ArrowRightGrey /> | ||
) | ||
) : isPrevious ? ( | ||
<ArrowLeft /> | ||
) : ( | ||
<ArrowRight /> | ||
)} |
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.
consider using a helper for readability
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.
at least create a separate constant in this component and don't use nested ternary operator
isDisabled, | ||
handleClick, | ||
}) => { | ||
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.
direct return
className={`${styles.pageButton} | ||
${ | ||
pageNumber === activePage | ||
? styles.pageButtonActive | ||
: '' | ||
}`} |
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.
getValidClassNames
className={`${styles.pageButton} | ||
${ | ||
pageNumber === activePage | ||
? styles.pageButtonActive | ||
: '' | ||
}`} |
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 same
className={`${styles.pageButton} | ||
${ | ||
pagesAmount === activePage | ||
? styles.pageButtonActive | ||
: '' | ||
}`} |
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 same
too much repetitive code, consider using a function
src/pages/ProductsGridPage/index.tsx
Outdated
useEffect(() => { | ||
searchProducts({ | ||
page: FIRST_PAGE, | ||
size: PRODUCT_GRID_SIZE, | ||
page: Number(PageNumbers.FIRST_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.
it already seems like a number
src/pages/ProductsGridPage/index.tsx
Outdated
const handleClick = (body: BodySearchProducts) => { | ||
searchProducts({ | ||
page: FIRST_PAGE, | ||
size: PRODUCT_GRID_SIZE, | ||
page: Number(PageNumbers.FIRST_PAGE), | ||
size: gridPageSize, | ||
body, | ||
}); | ||
}; |
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.
we can use useCallback
src/pages/ProductsGridPage/index.tsx
Outdated
const handlePagination = (pageNumber: PageNumbers) => { | ||
searchProducts({ | ||
page: Number(pageNumber), | ||
size: gridPageSize, | ||
body: | ||
activeButton === Category.CLOTHING || isMobile | ||
? { | ||
category: activeButton as Category, | ||
} | ||
: { | ||
subcategory: activeButton as Subcategory, | ||
}, | ||
}); | ||
}; |
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.
we can use useCallback
src/assets/svgs/ArrowLeftGrey.tsx
Outdated
@@ -0,0 +1,23 @@ | |||
import React from 'react'; | |||
|
|||
const ArrowLeftGrey = (): JSX.Element => { |
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.
is it the same icon as ArrowLeft?
please use ArrowLeft and change color
src/assets/svgs/ArrowRight.tsx
Outdated
@@ -0,0 +1,23 @@ | |||
import React from 'react'; | |||
|
|||
const ArrowRight = () => { |
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.
same as above
src/assets/svgs/ArrowRightGrey.tsx
Outdated
@@ -0,0 +1,23 @@ | |||
import React from 'react'; | |||
|
|||
const ArrowRightGrey = () => { |
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.
same as above
@@ -31,7 +31,6 @@ const CoreSwiper: FC<CoreSwiperProps> = ({ | |||
effect="fade" | |||
fadeEffect={{ crossFade: true }} | |||
rewind | |||
loop |
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?
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.
In case of using "loop" the following error occurs while resizing the window:
It is mentioned here:
"Uncaught error when unmounting Swiper with loop on window resize #7265"
nolimits4web/swiper#7265
Also it seems the functionality has not been impacted by removing the "loop".
|
||
import styles from './index.module.scss'; | ||
|
||
const Ellipsis = (): React.JSX.Element => ( |
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.
JSX.Element
setActivePage(pageNumber); | ||
}, []); | ||
|
||
const handleButtonClick = useCallback((increment: 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.
please use currying
<ul className={styles.pager}> | ||
<li className={styles.pageText}>{t('page')}</li> | ||
{Number(pagesAmount) <= DEFAULT_PAGES_AMOUNT ? ( | ||
pagesList.map(pageNumber => { |
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.
move to a separate constant and wrap into useMemo
{Number(pagesAmount) - 3} | ||
</li> | ||
)} | ||
{Number(activePage) > Number(pagesAmount) - 3 && |
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.
sorry, but this component is unreadable
we have to rewrite it
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 you need so many separate cases?
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/pages/ProductsGridPage/index.tsx
Outdated
const { t } = useTranslation(); | ||
|
||
const [activeButton, setActiveButton] = useState<string>( | ||
getButtons(t)[0].value, |
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 optional chaining
src/utils/constants.ts
Outdated
@@ -6,7 +6,33 @@ export const MenuItem = { | |||
KIDS: 'Kids', | |||
} as const; | |||
|
|||
export const FIRST_PAGE = 1; | |||
export enum PageNumbers { |
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.
doesn't seem right to me
No description provided.