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

#633.1 공유하기 퀘스트 달성 #668

Merged
merged 1 commit into from
Sep 24, 2023
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
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
Loading