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 all 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
20 changes: 12 additions & 8 deletions src/layouts/Product/BuyInfo/ButtonBundles/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import clsx from 'clsx';
import { useNavigate } from 'react-router-dom';

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

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

const mockData = {
wishCnt: 999999,
};

type ButtonBundlesProps = {
productDescription: ProductDescriptionResponse;
hasOption: boolean;
Expand All @@ -35,8 +32,15 @@
selectedOption,
quantity,
}: ButtonBundlesProps) => {
const { productId, name, price, productThumbnails, options } =
productDescription;
const {
productId,
name,
price,
productThumbnails,
options,
wishCount,
wish: isWished,
} = productDescription;
const navigate = useNavigate();
const { isLoggedIn, login, confirmLogin } = useLogin();
const { isSelected, isSelfSelected, selectedFriends, getImgUrl } =
Expand Down Expand Up @@ -85,7 +89,7 @@
// 옵션 선택 여부 확인
const checkOptionBeforeAction = (action: () => void) => {
if (hasOption && !selectedOption) {
alert('옵션을 선택해주세요');

Check warning on line 92 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 +129,7 @@
} else if (selectedFriends.length === 1) {
navigate('/bill/gift', { state: { orderInfos, giftFor: 'friends' } });
} else {
alert('지금은 한 번에 한 명에게만 선물할 수 있어요.');

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

View workflow job for this annotation

GitHub Actions / build

Unexpected alert
}
});
};
Expand Down Expand Up @@ -179,8 +183,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]: isWished })} />
{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