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 291 add to cart #321

Merged
merged 17 commits into from
Apr 22, 2024
Merged

Development 291 add to cart #321

merged 17 commits into from
Apr 22, 2024

Conversation

kirill-k88
Copy link
Collaborator

Подключил к кнопка добавления в корзину API и маршрутизацию на страницу корзины.
Немного подправил стили.

…ки. Изменил настройки сборки в webpack, увеличил размер файлов в бандле, поскольку файлы в проекте большие и иначе не собирается.
… Чуть исправил стили для адаптивности верстки.
Merge branch 'master' of github.com:Studio-Yandex-Practicum/maxboom_frontend into development_291_add-to-cart
@kirill-k88 kirill-k88 added the api label Apr 17, 2024
@kirill-k88 kirill-k88 requested a review from aimenin April 17, 2024 17:27
@kirill-k88 kirill-k88 self-assigned this Apr 17, 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.

Селекторы + переиспользуемый хук

src/entities/CartEntity/model/functions/cartHelper.ts Outdated Show resolved Hide resolved
src/shared/api/api.ts Show resolved Hide resolved
src/widgets/Product/Product.tsx Outdated Show resolved Hide resolved
src/widgets/Product/Product.tsx Outdated Show resolved Hide resolved
src/widgets/Product/Product.tsx Outdated Show resolved Hide resolved
src/widgets/ProductItem/CardPreview/CardPreview.tsx Outdated Show resolved Hide resolved
src/widgets/ProductItem/CardPreview/CardPreview.tsx Outdated Show resolved Hide resolved
src/widgets/ProductItem/ProductItem.tsx Outdated Show resolved Hide resolved
@aimenin aimenin self-requested a review April 22, 2024 08:28
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.

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

const [showPopup, setShowPopup] = useState<boolean>(false)

const addThisToCart = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

гляди, ты вынес в хук useEffect, но так же повторяются функции addThisToCart и handleAddToCart, их тоже можно объявить в хуке и вернуть из него.
В кастомных хуках так же можно использовать useNavigate, useDispatch и тд.

const [showPopup, setShowPopup] = useState<boolean>(false)

const addThisToCart = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

тоже выносим функции по добавлению в корзину в хук

@@ -24,6 +29,7 @@ type Props = {
slug: string
images: TImgList
quantity: number
id: number
Copy link
Collaborator

Choose a reason for hiding this comment

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

если добавляешь новый пропс в типы, не забывай обновлять документацию у компонента

const [isModalOpen, setIsModalOpen] = useState(false)
const [isModalClosing, setIsModalClosing] = useState(false)

const addThisToCart = () => {
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

@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 1ba3a96 into master Apr 22, 2024
1 check passed
@kirill-k88 kirill-k88 deleted the development_291_add-to-cart branch April 22, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Внедрение api в кнопку добавить в корзину
2 participants