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

Development 369 my account page #400

Merged
merged 21 commits into from
Jun 5, 2024
Merged

Conversation

kirill-k88
Copy link
Collaborator

No description provided.

kirill-k88 added 19 commits May 21, 2024 22:11
… удаления невалидного токена из заголовков по-умолчанию.
@kirill-k88 kirill-k88 added enhancement New feature or request development разработка новой фичи/компонента labels May 30, 2024
@kirill-k88 kirill-k88 requested a review from aimenin May 30, 2024 17:03
@kirill-k88 kirill-k88 self-assigned this May 30, 2024
Copy link
Collaborator

@aimenin aimenin left a comment

Choose a reason for hiding this comment

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

Отличная работа!
Парочка комментариев и вопросов

@@ -1,15 +1,16 @@
import { useEffect, useState } from 'react'

import { IProduct } from '@/shared/model/types/ProductModel'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Такие импорты можно тоже через type импортировать

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

)

@@ -82,6 +89,32 @@ const HeaderAccount: FC<HeaderAccountProps> = ({
}
}, [isModalOpen, isAuth])

const logoutBtnHandle = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

я бы вынес это в хук, чтобы можно было переиспользовать в других компонентах, если у нас будет функциональность выхода из приложения в каком то другом компоненте

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ОК, действительно, удобнее в отдельном хуке

const handleKeyUp = (e: KeyboardEvent<HTMLDivElement>) => {
if (e.code === 'Enter' || e.code === 'Space') {
e.preventDefault()
dispatch(logout())
Copy link
Collaborator

Choose a reason for hiding this comment

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

вот здесь по сути используется тот же ход логаут, что и в компоненте выше.

const { data } = await extra.api.get(`api/${ApiRoutes.USER}/`)
return data
} catch (error) {
if (axios.isAxiosError(error) && error.response && error.response.status === 401) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

вот здесь не очень понял логику, если у нас 401-я ошибка - мы выходим из приложения?
У нас рефреш токена нет?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Да, другой ручки нет

navigate(Routes.HOME)
}

const sideBar = useMemo(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

этот хук подходит только к этому компоненту?
Имею ввиду, это уникальная логика?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Это только тут используется. Но условную отрисовку компонентов внутри вынес в HOC

@@ -5,7 +5,7 @@ export interface IProduct {
category: string
brand: string
images: IImage[]
price: string
price: string | number
Copy link
Collaborator

Choose a reason for hiding this comment

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

ты вроде в другом компоненте использовал Nullable, давай будем последовательными и здесь тоже его заиспользуем

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

так тут вроде не с null

* @param {number} number количество товаров
* @returns {string} окончание для слова товар, в зависимости от их количества
*/
export const getEndingByNumber = (number: number): string => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Обрати внимание на вот эту апишку:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

О, здорово! применил

<div className={styles.lastOrder__order}>
<Paragraph className={styles.lastOrder__text}>Вы еще не совершали покупок!</Paragraph>
</div>
<div className={styles.lastOrder__footer}></div>
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.lastOrder__footer}></div>
<div className={styles.lastOrder__footer} />

@@ -34,15 +36,21 @@ const SideBarMenu: FC<ISideBarMenu> = ({ user, handleLogOut }) => {
const handleKeyUp = (e: KeyboardEvent<HTMLLIElement>) => {
if (e.code === 'Enter' || e.code === 'Space') {
e.preventDefault()
handleLogOut()
dispatch(logout())
Copy link
Collaborator

Choose a reason for hiding this comment

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

вот здесь тоже повторяется код, как и в прошлых компонентах, для логаута из приложения

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ага, переиспользовал хук

label_hit={item.label_hit}
label_popular={item.label_popular}
quantity={item.quantity}
label_hit={item.label_hit as boolean}
Copy link
Collaborator

Choose a reason for hiding this comment

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

а почему здесь типизируется через as, не подтягиваются типы?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Нужна отдельная задачка на приведение этого типа к единому варианту в проекте

@aimenin aimenin self-requested a review June 5, 2024 12:08
Copy link
Collaborator

@aimenin aimenin left a comment

Choose a reason for hiding this comment

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

Отличная работа!

@kirill-k88 kirill-k88 merged commit 781d2e7 into master Jun 5, 2024
1 check passed
@kirill-k88 kirill-k88 deleted the development_369_my-accoun_page branch June 5, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development разработка новой фичи/компонента enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Страница профиля Breakcrumbs страница профиль Блок аккардион
2 participants