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

Feat/334 #353

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/ui/Modal/WishModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useQueryClient } from '@tanstack/react-query';

import { useState, useEffect } from 'react';

import { Button } from 'components/ui/Button';
Expand Down Expand Up @@ -33,6 +35,7 @@ const WishModal = ({
productId,
onWishAdded = () => null,
}: WishModalProps) => {
const queryClient = useQueryClient();
const [radioStatus, setRadioStatus] = useState<WishRadioType>(
WISH_RADIO_STATUS.OTHERS as WishRadioType,
);
Expand All @@ -45,6 +48,8 @@ const WishModal = ({
const handleAddWish = async () => {
await addWish();
close();

queryClient.invalidateQueries({ queryKey: ['productDescription'] });
};

useEffect(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/layouts/Product/BuyInfo/ButtonBundles/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
@include ico-pd-detail(-110px, -420px, 26px, 22px);

margin-bottom: 5px;

&.on {
@include ico-pd-detail(-110px, -450px, 26px, 22px);
}
}
}

Expand Down
23 changes: 15 additions & 8 deletions src/layouts/Product/BuyInfo/ButtonBundles/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import clsx from 'clsx';
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

import { Button } from 'components/ui/Button';
Expand All @@ -18,10 +20,6 @@

import styles from './index.module.scss';

const mockData = {
wishCnt: 999999,
};

type ButtonBundlesProps = {
productDescription: ProductDescriptionResponse;
hasOption: boolean;
Expand All @@ -35,8 +33,15 @@
selectedOption,
quantity,
}: ButtonBundlesProps) => {
const { productId, name, price, productThumbnails, options } =
productDescription;
const {
productId,
name,
price,
productThumbnails,
options,
wishCount,
wish,
} = productDescription;
Copy link
Contributor

Choose a reason for hiding this comment

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

wish가 위시 여부를 의미하는 건가요?
그렇다면 isWishedwished처럼 이름을 짓는 건 어떨까용?

Copy link
Member Author

Choose a reason for hiding this comment

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

반영했습니다. b0bcc25

const navigate = useNavigate();
const { isLoggedIn, login, confirmLogin } = useLogin();
const { isSelected, isSelfSelected, selectedFriends, getImgUrl } =
Expand Down Expand Up @@ -85,7 +90,7 @@
// 옵션 선택 여부 확인
const checkOptionBeforeAction = (action: () => void) => {
if (hasOption && !selectedOption) {
alert('옵션을 선택해주세요');

Check warning on line 93 in src/layouts/Product/BuyInfo/ButtonBundles/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected alert
return;
}
action();
Expand Down Expand Up @@ -125,7 +130,7 @@
} else if (selectedFriends.length === 1) {
navigate('/bill/gift', { state: { orderInfos, giftFor: 'friends' } });
} else {
alert('지금은 한 번에 한 명에게만 선물할 수 있어요.');

Check warning on line 133 in src/layouts/Product/BuyInfo/ButtonBundles/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected alert
}
});
};
Expand All @@ -141,6 +146,8 @@
// console.log('선물상자 담기');
};

useEffect(() => {}, [wish]);

Copy link
Contributor

Choose a reason for hiding this comment

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

위시 상품이 변경되면 재렌더링을 하기 위한 건가요??

Copy link
Contributor

Choose a reason for hiding this comment

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

저도 궁금합니다! 어떤 코드인지 잘 모르겠습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

이 코드 의미 없는 코드인데 제가 지우는것을 깜빡한것같아요 제거했습니다! b7b4000

return (
<section className={styles.wrapper_bundle}>
<FundingModal
Expand Down Expand Up @@ -179,8 +186,8 @@
</Button>
<section className={styles.wrapper_gift}>
<Button className={styles.btn_wish} onClick={handleClickWish}>
<span className={styles.ico_wish} />
{formatNumberWithPlus(mockData.wishCnt, 100000)}
<span className={clsx(styles.ico_wish, { [styles.on]: wish })} />
{formatNumberWithPlus(wishCount, 100000)}
</Button>
<Button
color="black"
Expand Down
2 changes: 2 additions & 0 deletions src/types/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Product = {
brandName: string;
brandId: number;
brandThumbnail: string;
wishCount: number;
wish: boolean;
};

export type ProductDescriptionResponse = Product & {
Expand Down
Loading