diff --git a/src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx b/src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx index 943a6cc6c..daa41b53b 100644 --- a/src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx +++ b/src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx @@ -3,7 +3,6 @@ import { HTMLAttributes, ReactNode, useCallback, useState } from "react"; import { useEvent2023FallQuestComplete } from "hooks/event/useEvent2023FallQuestComplete"; import { sendPopupInstagramStoryShareToFlutter } from "hooks/skeleton/useFlutterEventCommunicationEffect"; import { useValueRecoilState } from "hooks/useFetchRecoilState"; -import { useAxios } from "hooks/useTaxiAPI"; import ModalEvent2023FallJoin from "components/ModalPopup/ModalEvent2023FallJoin"; @@ -31,7 +30,6 @@ const LinkEvent2023FallInstagramStoryShare = ({ children, ...aProps }: LinkEvent2023FallInstagramStoryShareProps) => { - const axios = useAxios(); const setAlert = useSetRecoilState(alertAtom); const isLogin = !!useValueRecoilState("loginInfo")?.id; const { isAgreeOnTermsOfEvent } = @@ -54,19 +52,12 @@ const LinkEvent2023FallInstagramStoryShare = ({ backgroundLayerUrl, stickerLayerUrl, }); - if (!result) { + if (result) { + event2023FallQuestComplete(type); + } else { setAlert("인스타그램 실행에 실패하였습니다."); return; } - axios({ - url: `/events/2023fall/quests/complete/${type}`, - method: "post", - onSuccess: () => { - //#region event2023Fall - event2023FallQuestComplete(type); - //#endregion - }, - }); } }, [ isLogin, diff --git a/src/hooks/event/useEvent2023FallQuestComplete.ts b/src/hooks/event/useEvent2023FallQuestComplete.ts index 5dda28b06..5dec63c40 100644 --- a/src/hooks/event/useEvent2023FallQuestComplete.ts +++ b/src/hooks/event/useEvent2023FallQuestComplete.ts @@ -6,10 +6,11 @@ import { useFetchRecoilState, useValueRecoilState, } from "hooks/useFetchRecoilState"; +import { useAxios } from "hooks/useTaxiAPI"; export const useEvent2023FallQuestComplete = () => { + const axios = useAxios(); const fetchEvent2023FallInfo = useFetchRecoilState("event2023FallInfo"); - const { completedQuests, quests } = useValueRecoilState("event2023FallInfo") || {}; @@ -21,7 +22,20 @@ export const useEvent2023FallQuestComplete = () => { const questCompletedCount = completedQuests?.filter( (questId) => questId === id ).length; - questCompletedCount < questMaxCount && fetchEvent2023FallInfo(); + if (questCompletedCount >= questMaxCount) return; + if ( + [ + "roomSharing", + "eventSharingOnInstagram", + "purchaseSharingOnInstagram", + ].includes(id) + ) { + axios({ + url: `/events/2023fall/quests/complete/${id}`, + method: "post", + onSuccess: () => fetchEvent2023FallInfo(), + }); + } else fetchEvent2023FallInfo(); }, [completedQuests, fetchEvent2023FallInfo, quests] );