Skip to content

Commit

Permalink
Merge pull request #668 from sparcs-kaist/#633.1-share-quest
Browse files Browse the repository at this point in the history
#633.1 공유하기 퀘스트 달성
  • Loading branch information
14KGun authored Sep 24, 2023
2 parents afcaf5f + 95decfc commit 509473c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
15 changes: 3 additions & 12 deletions src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -31,7 +30,6 @@ const LinkEvent2023FallInstagramStoryShare = ({
children,
...aProps
}: LinkEvent2023FallInstagramStoryShareProps) => {
const axios = useAxios();
const setAlert = useSetRecoilState(alertAtom);
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const { isAgreeOnTermsOfEvent } =
Expand All @@ -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,
Expand Down
18 changes: 16 additions & 2 deletions src/hooks/event/useEvent2023FallQuestComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") || {};

Expand All @@ -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]
);
Expand Down

0 comments on commit 509473c

Please sign in to comment.