Skip to content

Commit

Permalink
Merge pull request #368 from KakaoFunding/bug/333
Browse files Browse the repository at this point in the history
Bug/333
  • Loading branch information
devkyoung2 authored Jun 18, 2024
2 parents b6ff9c3 + ae9b7de commit ae8e7a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/components/ui/Modal/FundingModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const FundingModal = ({
});

const handleAddFunding = async () => {
if (formatCommaToNumber(goalAmount) === 0) {
alert('목표 금액은 0원일 수 없습니다.');

return;
}
await sendRequest();
close();
};
Expand Down
14 changes: 14 additions & 0 deletions src/layouts/Product/BuyInfo/ButtonBundles/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useQuery } from '@tanstack/react-query';

import clsx from 'clsx';
import { useNavigate } from 'react-router-dom';

Expand All @@ -11,7 +13,9 @@ import { useAxios } from 'hooks/useAxios';
import { useKakaoPicker } from 'hooks/useKakaoPicker';
import { useLogin } from 'hooks/useLogin';
import { useModal } from 'hooks/useModal';
import { getMyFundingItem } from 'services/api/v1/funding';
import { formatNumberWithPlus } from 'utils/format';
import { isEmptyObject } from 'utils/validate';

import { RequestOrderPreview } from 'types/payment';
import { OptionDetail, ProductDescriptionResponse } from 'types/product';
Expand Down Expand Up @@ -48,6 +52,11 @@ const ButtonBundles = ({
useSelectedFriendsStore();
const { openKakaoPicker } = useKakaoPicker();

const { data } = useQuery({
queryKey: ['myFundingItem'],
queryFn: () => getMyFundingItem(),
});

const {
isOpen: isFundingOpen,
open: openFundingModal,
Expand Down Expand Up @@ -104,6 +113,11 @@ const ButtonBundles = ({
// 펀딩 등록 버튼 핸들러
const handleClickFunding = () => {
checkLoginBeforeAction(() => {
if (!isEmptyObject(data!)) {
alert('이미 등록된 펀딩 아이템이 있습니다.');
return;
}

checkOptionBeforeAction(openFundingModal);
});
};
Expand Down
5 changes: 1 addition & 4 deletions src/pages/MyPage/Funding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import FundingProgress from 'layouts/MyPage/Funding/FundingProgress';
import { useUserStore } from 'store/useUserStore';

import { getMyFundingItem } from 'services/api/v1/funding';
import { isEmptyObject } from 'utils/validate';

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

const isEmptyObject = (obj: object): boolean => {
return Object.keys(obj).length === 0;
};

const Funding = () => {
const { name } = useUserStore();
const { data, isFetched, isLoading } = useQuery({
Expand Down
4 changes: 4 additions & 0 deletions src/utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ export const isValidQuantity = (quantity: string) => {
export const isValidPrice = (price: string) => {
return isPositiveInteger(price) || isZero(price);
};

export const isEmptyObject = (obj: object): boolean => {
return Object.keys(obj).length === 0;
};

0 comments on commit ae8e7a9

Please sign in to comment.