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

Feature/os 50 fe create pagination category page mob #74

Merged
merged 10 commits into from
Apr 12, 2024

Conversation

olenamshrv
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Mar 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
online-store ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 11:49am

<>
<Header />
<div className={styles.main}>{children}</div>
<div className={`${styles.main} ${isLoading ? styles.mainMaxHeight : ''}`}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<div className={`${styles.main} ${isLoading ? styles.mainMaxHeight : ''}`}>
<div className={getValidClassNames(styles.main, { [styles.mainMaxHeight]: isLoading })}>

Comment on lines 22 to 24
className={`${styles.paginationButton} ${
isDisabled ? styles.paginationDisabled : ''
}`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider using getValidClassNames

Comment on lines 28 to 38
{isDisabled ? (
isPrevious ? (
<ArrowLeftGrey />
) : (
<ArrowRightGrey />
)
) : isPrevious ? (
<ArrowLeft />
) : (
<ArrowRight />
)}
Copy link
Collaborator

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

Copy link
Collaborator

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 (
Copy link
Collaborator

Choose a reason for hiding this comment

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

direct return

Comment on lines 52 to 57
className={`${styles.pageButton}
${
pageNumber === activePage
? styles.pageButtonActive
: ''
}`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

getValidClassNames

Comment on lines 143 to 148
className={`${styles.pageButton}
${
pageNumber === activePage
? styles.pageButtonActive
: ''
}`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the same

Comment on lines 157 to 162
className={`${styles.pageButton}
${
pagesAmount === activePage
? styles.pageButtonActive
: ''
}`}
Copy link
Collaborator

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

useEffect(() => {
searchProducts({
page: FIRST_PAGE,
size: PRODUCT_GRID_SIZE,
page: Number(PageNumbers.FIRST_PAGE),
Copy link
Collaborator

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

Comment on lines 48 to 54
const handleClick = (body: BodySearchProducts) => {
searchProducts({
page: FIRST_PAGE,
size: PRODUCT_GRID_SIZE,
page: Number(PageNumbers.FIRST_PAGE),
size: gridPageSize,
body,
});
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can use useCallback

Comment on lines 56 to 69
const handlePagination = (pageNumber: PageNumbers) => {
searchProducts({
page: Number(pageNumber),
size: gridPageSize,
body:
activeButton === Category.CLOTHING || isMobile
? {
category: activeButton as Category,
}
: {
subcategory: activeButton as Subcategory,
},
});
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can use useCallback

@@ -0,0 +1,23 @@
import React from 'react';

const ArrowLeftGrey = (): JSX.Element => {
Copy link
Collaborator

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

@@ -0,0 +1,23 @@
import React from 'react';

const ArrowRight = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

@@ -0,0 +1,23 @@
import React from 'react';

const ArrowRightGrey = () => {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator Author

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:
image

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 => (
Copy link
Collaborator

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) => {
Copy link
Collaborator

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 => {
Copy link
Collaborator

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 &&
Copy link
Collaborator

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

@olenamshrv olenamshrv Mar 18, 2024

Choose a reason for hiding this comment

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

Due to design there are the following cases:
image

and additionally two more (when page 3 or the 3rd page back from the last page is active:
image
image

const { t } = useTranslation();

const [activeButton, setActiveButton] = useState<string>(
getButtons(t)[0].value,
Copy link
Collaborator

Choose a reason for hiding this comment

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

add optional chaining

@@ -6,7 +6,33 @@ export const MenuItem = {
KIDS: 'Kids',
} as const;

export const FIRST_PAGE = 1;
export enum PageNumbers {
Copy link
Collaborator

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

@olenamshrv olenamshrv merged commit 427251d into main Apr 12, 2024
4 checks passed
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.

3 participants