From 38a337e068e5926883bc2ac3b51151664c8b67e4 Mon Sep 17 00:00:00 2001 From: andyye <63383967+0ev@users.noreply.github.com> Date: Fri, 23 Feb 2024 03:49:28 +0900 Subject: [PATCH 01/29] Add referer --- .../web/src/components/Skeleton/Routes.tsx | 5 ++++ packages/web/src/pages/Home/index.tsx | 24 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/web/src/components/Skeleton/Routes.tsx b/packages/web/src/components/Skeleton/Routes.tsx index 276b1ce66..4b74a3ab8 100644 --- a/packages/web/src/components/Skeleton/Routes.tsx +++ b/packages/web/src/components/Skeleton/Routes.tsx @@ -27,6 +27,11 @@ const routeProps = [ component: lazy(() => import("@/pages/Home")), exact: true, }, + { + path: "/event/2024spring-invite/:eventStatusId", + component: lazy(() => import("@/pages/Home")), + exact: true, + }, { path: "/event/:eventName", component: lazy(() => import("@/pages/Event")), diff --git a/packages/web/src/pages/Home/index.tsx b/packages/web/src/pages/Home/index.tsx index ee5205152..6e5000097 100644 --- a/packages/web/src/pages/Home/index.tsx +++ b/packages/web/src/pages/Home/index.tsx @@ -1,5 +1,8 @@ +import { useEffect } from "react"; import { useHistory, useParams } from "react-router-dom"; +import useQuery from "@/hooks/useTaxiAPI"; + import Footer from "@/components/Footer"; import { ModalPrivacyPolicy } from "@/components/ModalPopup"; @@ -7,13 +10,31 @@ import EventSection from "./EventSection"; import InfoSection from "./InfoSection"; import RoomSection from "./RoomSection"; +import { getDynamicLink } from "@/tools/trans"; + const Home = () => { const history = useHistory(); - const { roomId: _roomId } = useParams<{ roomId: string }>(); + const { roomId: _roomId, eventStatusId: eventStatusId } = useParams<{ + roomId: string; + eventStatusId: string; + }>(); const roomId = _roomId === "privacyPolicy" ? null : _roomId; + const [, eventProfile] = useQuery.get( + `/events/2024spring/invite/search/:${roomId}`, + {}, + [eventStatusId] + ); + const onChangeIsOpenPrivacyPolicy = () => history.replace("/home"); + useEffect(() => { + if (!eventStatusId) return; + const dynamicLink = getDynamicLink(window.location.pathname); + window.location.replace(dynamicLink); + + }, [eventStatusId]); + return ( <> @@ -25,6 +46,7 @@ const Home = () => { isOpen={_roomId === "privacyPolicy"} onChangeIsOpen={onChangeIsOpenPrivacyPolicy} /> + {/* 모달 완성되면 넣을 곳 */} ); }; From 387d1c77028760b541c83abcf09e70989079a7e2 Mon Sep 17 00:00:00 2001 From: andyye <63383967+0ev@users.noreply.github.com> Date: Fri, 23 Feb 2024 04:06:41 +0900 Subject: [PATCH 02/29] Fix home --- .../ModalPopup/ModalEvent2024SpringJoin.tsx | 47 +++++++++++-------- .../web/src/pages/Event/Event2024Spring.tsx | 5 +- packages/web/src/pages/Home/index.tsx | 13 +++-- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index d5904801e..5be711a75 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -8,6 +8,7 @@ import { useValueRecoilState, } from "@/hooks/useFetchRecoilState"; import { useAxios } from "@/hooks/useTaxiAPI"; +import useQuery from "@/hooks/useTaxiAPI"; import Button from "@/components/Button"; import DottedLine from "@/components/DottedLine"; @@ -22,11 +23,14 @@ import theme from "@/tools/theme"; import FestivalRoundedIcon from "@mui/icons-material/FestivalRounded"; -type ModalEvent2024SpringJoinProps = Parameters[0]; +type ModalEvent2024SpringJoinProps = Parameters[0] & { + inviterId?: string; +}; -const ModalEvent2024SpringJoin = ( - modalProps: ModalEvent2024SpringJoinProps -) => { +const ModalEvent2024SpringJoin = ({ + inviterId, + ...modalProps +}: ModalEvent2024SpringJoinProps) => { const axios = useAxios(); const setAlert = useSetRecoilState(alertAtom); const isLogin = useIsLogin(); @@ -43,8 +47,11 @@ const ModalEvent2024SpringJoin = ( const [phoneNumber, setPhoneNumber] = useState(""); const [group, setGroup] = useState(0); - // 추천인 구현 방식에 따라 삭제가 필요할 수도 있습니다. - const [inviter] = useState(""); + const [, inviterInfo] = useQuery.get( + `/events/2024spring/invite/search/${inviterId}`, + {}, + [inviterId] + ); const isValidPhoneNumber = useMemo( () => regExpTest.phoneNumber(phoneNumber), @@ -61,7 +68,7 @@ const ModalEvent2024SpringJoin = ( axios({ url: "/events/2024spring/globalState/create", method: "post", - data: { phoneNumber, group, inviter }, + data: { phoneNumber, group, inviterId }, onSuccess: () => { fetchLoginInfo(); //#region event2024Spring @@ -178,16 +185,17 @@ const ModalEvent2024SpringJoin = ( css={{ width: "100%", marginLeft: "10px" }} /> - {/* 추천인이 있을 경우에만 표시하도록 변경 필요 */} - {/*
- 추천인 - 추천인 - 추천인닉네임 -
*/} + { +
+ 추천인 + 추천인 + 추천인닉네임 +
+ } - - ) : ( - <> -
- -
- 전화번호 - -
-
- 새터반 - { - const number = parseInt(value, 10); - setGroup(number); - }} - placeholder="숫자만 입력하세요" - css={{ width: "100%", marginLeft: "10px" }} - /> -
- {isInvited && ( + {isAgreeOnTermsOfEvent ? ( + <> +
+ +
+ 전화번호 + +
+
+ 새터반 + +
+ + + ) : ( + <> + + {isLogin && ( + <> +
+
+ 전화번호 + +
- 추천인 -
{ + const number = parseInt(value, 10); + setGroup(number); }} - > - -
- - {inviterInfo?.nickname} - + placeholder="숫자만 입력하세요" + css={{ width: "100%", marginLeft: "10px" }} + />
- )} + + )} + + {isInvited && ( +
+ 추천인 +
+ +
+ + {inviterInfo?.nickname} + +
+ )} + {isLogin ? ( + + )} + + )} ); }; diff --git a/packages/web/src/pages/Home/index.tsx b/packages/web/src/pages/Home/index.tsx index 4e8912052..d71b90921 100644 --- a/packages/web/src/pages/Home/index.tsx +++ b/packages/web/src/pages/Home/index.tsx @@ -1,7 +1,5 @@ import { useEffect } from "react"; -import { useHistory, useLocation, useParams } from "react-router-dom"; - -import { useIsLogin } from "@/hooks/useFetchRecoilState"; +import { useHistory, useParams } from "react-router-dom"; import Footer from "@/components/Footer"; import { @@ -17,9 +15,6 @@ import { getDynamicLink } from "@/tools/trans"; const Home = () => { const history = useHistory(); - const { pathname, search } = useLocation(); - - const isLogin = useIsLogin(); const { roomId: _roomId, @@ -48,14 +43,6 @@ const Home = () => { window.location.href = dynamicLink; }, [eventStatusId]); - useEffect(() => { - if (inviterId && !isLogin) { - history.replace( - `/login?redirect=${encodeURIComponent(pathname + search)}` - ); - } - }, [isLogin, inviterId]); - return ( <> From 41cc183466b92c222525d791851b25f0c8edff2b Mon Sep 17 00:00:00 2001 From: andyye <63383967+0ev@users.noreply.github.com> Date: Fri, 23 Feb 2024 07:58:33 +0900 Subject: [PATCH 17/29] Fix: filter outgoing requests --- .../ModalPopup/ModalEvent2024SpringJoin.tsx | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index f0d4bee97..b8bef5a9a 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { useLocation } from "react-router-dom"; import { useEvent2024SpringQuestComplete } from "@/hooks/event/useEvent2024SpringQuestComplete"; @@ -50,12 +50,29 @@ const ModalEvent2024SpringJoin = ({ const [phoneNumber, setPhoneNumber] = useState(""); const [group, setGroup] = useState(0); - const [, inviterInfo] = useQuery.get( - `/events/2024spring/invite/search/${inviterId}`, - {}, + + const [inviterInfo, setInvitorInfo] = useState<{ + profileImageUrl: string; + nickname: string; + }>(); + + const getInvitorInfo = useCallback( + () => + axios({ + url: `/events/2024spring/invite/search/${inviterId}`, + method: "post", + onSuccess: (data) => { + setInvitorInfo(data); + }, + onError: () => setAlert("올바르지 않은 추천인입니다."), + }), [inviterId] ); + useEffect(() => { + if (inviterId) getInvitorInfo(); + }, [inviterId]); + const isValidPhoneNumber = useMemo( () => regExpTest.phoneNumber(phoneNumber), [phoneNumber] From 1917d9feaffccb7a5b3676a32d6aa1b7f7d1814f Mon Sep 17 00:00:00 2001 From: andyye <63383967+0ev@users.noreply.github.com> Date: Fri, 23 Feb 2024 07:59:00 +0900 Subject: [PATCH 18/29] Fix: remove when none --- .../web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index b8bef5a9a..7b82e8d30 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -250,7 +250,7 @@ const ModalEvent2024SpringJoin = ({ )} - {isInvited && ( + {isInvited && inviterInfo && (
추천인
Date: Fri, 23 Feb 2024 08:17:50 +0900 Subject: [PATCH 19/29] Add: terms of 2024 spring event into my page --- packages/web/src/pages/Mypage/index.tsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/web/src/pages/Mypage/index.tsx b/packages/web/src/pages/Mypage/index.tsx index 20483f47e..eabebe601 100644 --- a/packages/web/src/pages/Mypage/index.tsx +++ b/packages/web/src/pages/Mypage/index.tsx @@ -9,6 +9,7 @@ import LinkLogout from "@/components/Link/LinkLogout"; import { ModalCredit, ModalEvent2023FallJoin, + ModalEvent2024SpringJoin, ModalMypageModify, ModalNotification, ModalPrivacyPolicy, @@ -176,11 +177,15 @@ const Mypage = () => { {t("privacy_policy")} - {eventMode === "2023fall" && ( + {eventMode === "2023fall" ? ( 한가위 송편 이벤트 참여 약관 - )} + ) : eventMode === "2024spring" ? ( + + 새내기 택시대제전 참여 약관 + + ) : null} {t("credit")} @@ -197,10 +202,17 @@ const Mypage = () => { onChangeIsOpen={setIsOpenPrivacyPolicy} /> - + {eventMode === "2023fall" ? ( + + ) : eventMode === "2024spring" ? ( + + ) : null} ); From 8e29eca7aac26e38ff5b0f644c2044f21ab04633 Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 08:25:22 +0900 Subject: [PATCH 20/29] Refactor: ModalEvent2024SpringJoin.tsx --- .../ModalPopup/ModalEvent2024SpringJoin.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index 7b82e8d30..f5242b97e 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -1,5 +1,4 @@ import { useCallback, useEffect, useMemo, useState } from "react"; -import { useLocation } from "react-router-dom"; import { useEvent2024SpringQuestComplete } from "@/hooks/event/useEvent2024SpringQuestComplete"; import { @@ -8,7 +7,6 @@ import { useValueRecoilState, } from "@/hooks/useFetchRecoilState"; import { useAxios } from "@/hooks/useTaxiAPI"; -import useQuery from "@/hooks/useTaxiAPI"; import Button from "@/components/Button"; import DottedLine from "@/components/DottedLine"; @@ -60,7 +58,7 @@ const ModalEvent2024SpringJoin = ({ () => axios({ url: `/events/2024spring/invite/search/${inviterId}`, - method: "post", + method: "get", onSuccess: (data) => { setInvitorInfo(data); }, @@ -69,8 +67,10 @@ const ModalEvent2024SpringJoin = ({ [inviterId] ); + const isInvited = !!inviterId; + useEffect(() => { - if (inviterId) getInvitorInfo(); + if (isInvited) getInvitorInfo(); }, [inviterId]); const isValidPhoneNumber = useMemo( @@ -79,10 +79,6 @@ const ModalEvent2024SpringJoin = ({ ); const isValidGroup = useMemo(() => group > 0 && group < 27, [group]); - const location = useLocation(); - const path = location.pathname; - const isInvited = path.startsWith("/home/startEvent/"); - const onClickJoin = useCallback( () => axios({ @@ -219,7 +215,7 @@ const ModalEvent2024SpringJoin = ({ ) : ( <> - + {(isLogin || (isInvited && inviterInfo)) && } {isLogin && ( <>
@@ -249,7 +245,6 @@ const ModalEvent2024SpringJoin = ({
)} - {isInvited && inviterInfo && (
추천인 From 3615d8bb2cfc1a94a2845e191b0d2dedb8223530 Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 08:36:32 +0900 Subject: [PATCH 21/29] Refactor: selectively display terms of events in my page --- .../ModalPopup/ModalEvent2024SpringJoin.tsx | 4 +- packages/web/src/pages/Mypage/index.tsx | 46 +++++++++++-------- packages/web/src/tools/day.ts | 1 + 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index f5242b97e..78dcc7290 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -37,9 +37,7 @@ const ModalEvent2024SpringJoin = ({ const isLogin = useIsLogin(); const { phoneNumber: phoneNumberFromLoginInfo } = useValueRecoilState("loginInfo") || {}; - const { isAgreeOnTermsOfEvent } = - useValueRecoilState("event2024SpringInfo") || {}; - const { group: groupFromLoginInfo } = + const { isAgreeOnTermsOfEvent, group: groupFromLoginInfo } = useValueRecoilState("event2024SpringInfo") || {}; const fetchLoginInfo = useFetchRecoilState("loginInfo"); //#region event2024Spring diff --git a/packages/web/src/pages/Mypage/index.tsx b/packages/web/src/pages/Mypage/index.tsx index eabebe601..f2d4e3005 100644 --- a/packages/web/src/pages/Mypage/index.tsx +++ b/packages/web/src/pages/Mypage/index.tsx @@ -32,6 +32,8 @@ const Mypage = () => { const loginInfo = useValueRecoilState("loginInfo"); const notificationOptions = useValueRecoilState("notificationOptions"); const { id: userId } = loginInfo || {}; + const { isAgreeOnTermsOfEvent } = + (eventMode && useValueRecoilState("event2024SpringInfo")) || {}; const [isOpenProfileModify, setIsOpenProfileModify] = useState(false); const [isOpenNotification, setIsOpenNotification] = useState(false); @@ -177,15 +179,17 @@ const Mypage = () => { {t("privacy_policy")} - {eventMode === "2023fall" ? ( - - 한가위 송편 이벤트 참여 약관 - - ) : eventMode === "2024spring" ? ( - - 새내기 택시대제전 참여 약관 - - ) : null} + {eventMode && + isAgreeOnTermsOfEvent && + (eventMode === "2023fall" ? ( + + 한가위 송편 이벤트 참여 약관 + + ) : eventMode === "2024spring" ? ( + + 새내기 택시대제전 참여 약관 + + ) : null)} {t("credit")} @@ -202,17 +206,19 @@ const Mypage = () => { onChangeIsOpen={setIsOpenPrivacyPolicy} /> - {eventMode === "2023fall" ? ( - - ) : eventMode === "2024spring" ? ( - - ) : null} + {eventMode && + isAgreeOnTermsOfEvent && + (eventMode === "2023fall" ? ( + + ) : eventMode === "2024spring" ? ( + + ) : null)} ); diff --git a/packages/web/src/tools/day.ts b/packages/web/src/tools/day.ts index 2f71db9c0..cdb4c2e4e 100644 --- a/packages/web/src/tools/day.ts +++ b/packages/web/src/tools/day.ts @@ -41,6 +41,7 @@ export const day2str = (day: Dayjs, format = "LLLL") => { return day.format(format); }; +/** 일을 기준으로 특정 날짜까지의 D-DAY를 반환합니다. */ export const getDday = (dateString: string) => { const targetDate = dayjs(dateString); const currentDate = dayNowServer().startOf("day"); // Get current server time From b7d3116ebdbae642ce3568cf7a38d1a141c03672 Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 08:47:08 +0900 Subject: [PATCH 22/29] Fix: some margin --- .../components/ModalPopup/ModalEvent2024SpringJoin.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index 78dcc7290..ee392ed84 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -176,7 +176,7 @@ const ModalEvent2024SpringJoin = ({ 지급됩니다.
-
+
• 본 약관은 동의 이후에도 {'"'}마이페이지{">"}새터반 택시대제전 이벤트 참여 약관{'"'}에서 다시 확인하실 수 있습니다.{" "}
@@ -213,10 +213,14 @@ const ModalEvent2024SpringJoin = ({ ) : ( <> - {(isLogin || (isInvited && inviterInfo)) && } - {isLogin && ( + {(isLogin || (isInvited && inviterInfo)) && ( <>
+ + + )} + {isLogin && ( + <>
전화번호 Date: Fri, 23 Feb 2024 08:56:48 +0900 Subject: [PATCH 23/29] Refactor: margin between input elements --- .../src/components/ModalPopup/ModalEvent2024SpringJoin.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index ee392ed84..719562535 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -111,7 +111,7 @@ const ModalEvent2024SpringJoin = ({ margin: "0 8px", }; const styleInputWrap = { - margin: "12px 8px", + margin: "0 8px 12px", display: "flex", alignItems: "center", color: theme.gray_text, @@ -184,6 +184,7 @@ const ModalEvent2024SpringJoin = ({ <>
+
전화번호 )} +
{isLogin && ( <>
From 0ea5bb59eebd916a90144c55d5c01646c8223cc5 Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 09:12:31 +0900 Subject: [PATCH 24/29] Refactor: ModalEvent2024SpringJoin.tsx --- .../web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx index 719562535..8ba3d5b84 100644 --- a/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx +++ b/packages/web/src/components/ModalPopup/ModalEvent2024SpringJoin.tsx @@ -68,7 +68,7 @@ const ModalEvent2024SpringJoin = ({ const isInvited = !!inviterId; useEffect(() => { - if (isInvited) getInvitorInfo(); + if (!isAgreeOnTermsOfEvent && isInvited) getInvitorInfo(); }, [inviterId]); const isValidPhoneNumber = useMemo( From a87f6bcdff273cb71b92ccdbb5dfd48a6920f3af Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 09:16:08 +0900 Subject: [PATCH 25/29] Fix: typos in Event2024Spring.tsx --- packages/web/src/pages/Event/Event2024Spring.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/web/src/pages/Event/Event2024Spring.tsx b/packages/web/src/pages/Event/Event2024Spring.tsx index 53fd34f3c..8bcf9bd8e 100644 --- a/packages/web/src/pages/Event/Event2024Spring.tsx +++ b/packages/web/src/pages/Event/Event2024Spring.tsx @@ -309,7 +309,7 @@ const Event2024Spring = () => {
{ }} > - 1등 세터반 + 1등 새터반 - 2등 세터반 + 2등 새터반
{ css={{ textDecoration: "none", width: "100%" }} > From 24471f34b8854e2d41734da0133079d5e003b1e5 Mon Sep 17 00:00:00 2001 From: andyye <63383967+0ev@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:15:31 +0900 Subject: [PATCH 26/29] =?UTF-8?q?Fix:=20error=20when=20sharing=20without?= =?UTF-8?q?=20=EC=B0=B8=EC=97=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/src/pages/Event/Event2024Spring.tsx | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/packages/web/src/pages/Event/Event2024Spring.tsx b/packages/web/src/pages/Event/Event2024Spring.tsx index 53fd34f3c..9fd81076f 100644 --- a/packages/web/src/pages/Event/Event2024Spring.tsx +++ b/packages/web/src/pages/Event/Event2024Spring.tsx @@ -1,9 +1,10 @@ -import { ReactNode, memo, useState } from "react"; +import { ReactNode, memo, useCallback, useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { QuestId } from "@/types/event2024spring"; -import useQuery from "@/hooks/useTaxiAPI"; +import { useValueRecoilState } from "@/hooks/useFetchRecoilState"; +import useQuery, { useAxios } from "@/hooks/useTaxiAPI"; import AdaptiveDiv from "@/components/AdaptiveDiv"; import EventButton from "@/components/Event/EventButton"; @@ -13,6 +14,9 @@ import { ModalEvent2024SpringShare } from "@/components/ModalPopup"; import { MissionContainer } from "./Event2024SpringMissions"; +import alertAtom from "@/atoms/alert"; +import { useSetRecoilState } from "recoil"; + import eventTheme from "@/tools/eventTheme"; import theme from "@/tools/theme"; @@ -77,11 +81,30 @@ const EventStep = ({ const Event2024Spring = () => { const [isOpenShare, setIsOpenShare] = useState(false); - const [, inviteUrl_] = useQuery.post(`/events/2024spring/invite/create`, {}, [ - isOpenShare, - ]); + const [inviteUrl, setInviteUrl] = useState(); + const setAlert = useSetRecoilState(alertAtom); + const { isAgreeOnTermsOfEvent } = + useValueRecoilState("event2024SpringInfo") || {}; + + const axios = useAxios(); - const inviteUrl = inviteUrl_?.inviteUrl; + const getInviteUrl = useCallback( + () => + axios({ + url: `/events/2024spring/invite/create`, + method: "post", + onSuccess: ({ inviteUrl }) => { + setInviteUrl(inviteUrl); + }, + onError: () => + setAlert("이벤트를 공유하기 위해서는 이벤트에 참여가 필요합니다."), + }), + [isAgreeOnTermsOfEvent] + ); + + useEffect(() => { + if (isAgreeOnTermsOfEvent) getInviteUrl(); + }, [isAgreeOnTermsOfEvent]); const styleTextBox = { ...eventTheme.font20, @@ -150,12 +173,18 @@ const Event2024Spring = () => { setIsOpenShare(true)} + onClick={() => { + if (inviteUrl) setIsOpenShare(true); + else + setAlert( + "이벤트를 공유하기 위해서는 이벤트에 참여가 필요합니다." + ); + }} /> Date: Fri, 23 Feb 2024 10:31:31 +0900 Subject: [PATCH 27/29] Refactor: some comments --- .../components/ModalPopup/Body/BodyEvent2024SpringShare.tsx | 6 +++++- packages/web/src/pages/Event/Event2024Spring.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web/src/components/ModalPopup/Body/BodyEvent2024SpringShare.tsx b/packages/web/src/components/ModalPopup/Body/BodyEvent2024SpringShare.tsx index aab3708e6..cf9e8a345 100644 --- a/packages/web/src/components/ModalPopup/Body/BodyEvent2024SpringShare.tsx +++ b/packages/web/src/components/ModalPopup/Body/BodyEvent2024SpringShare.tsx @@ -61,7 +61,11 @@ const BodyEvent2024SpringShare = ({ return (
-
이벤트를 여러 사람들에게 공유할 수 있습니다.
+
+ 이벤트를 여러 사람들에게 공유할 수 있습니다. 이 링크를 통해 다른 + 사용자가 이벤트에 참여하면, 회원님과 새 참여자 모두{" "} + 50 넙죽코인을 획득합니다. +
diff --git a/packages/web/src/pages/Event/Event2024Spring.tsx b/packages/web/src/pages/Event/Event2024Spring.tsx index 3655da775..026dc86c4 100644 --- a/packages/web/src/pages/Event/Event2024Spring.tsx +++ b/packages/web/src/pages/Event/Event2024Spring.tsx @@ -97,7 +97,7 @@ const Event2024Spring = () => { setInviteUrl(inviteUrl); }, onError: () => - setAlert("이벤트를 공유하기 위해서는 이벤트에 참여가 필요합니다."), + setAlert("이벤트를 공유하기 위해서는 이벤트에 참여해야 합니다."), }), [isAgreeOnTermsOfEvent] ); From 032c7ec2444de7c3c6a161bf804e839ca3514048 Mon Sep 17 00:00:00 2001 From: static Date: Fri, 23 Feb 2024 10:36:27 +0900 Subject: [PATCH 28/29] Fix: invalid error message --- packages/web/src/pages/Event/Event2024Spring.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/web/src/pages/Event/Event2024Spring.tsx b/packages/web/src/pages/Event/Event2024Spring.tsx index 026dc86c4..63da6b150 100644 --- a/packages/web/src/pages/Event/Event2024Spring.tsx +++ b/packages/web/src/pages/Event/Event2024Spring.tsx @@ -96,8 +96,7 @@ const Event2024Spring = () => { onSuccess: ({ inviteUrl }) => { setInviteUrl(inviteUrl); }, - onError: () => - setAlert("이벤트를 공유하기 위해서는 이벤트에 참여해야 합니다."), + onError: () => setAlert("공유 링크를 생성하지 못했습니다."), }), [isAgreeOnTermsOfEvent] ); @@ -176,9 +175,7 @@ const Event2024Spring = () => { onClick={() => { if (inviteUrl) setIsOpenShare(true); else - setAlert( - "이벤트를 공유하기 위해서는 이벤트에 참여가 필요합니다." - ); + setAlert("이벤트를 공유하기 위해서는 이벤트에 참여해야 합니다."); }} /> Date: Fri, 23 Feb 2024 10:37:55 +0900 Subject: [PATCH 29/29] Fix: build error --- packages/web/src/pages/Event/Event2024Spring.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/pages/Event/Event2024Spring.tsx b/packages/web/src/pages/Event/Event2024Spring.tsx index 63da6b150..086e28203 100644 --- a/packages/web/src/pages/Event/Event2024Spring.tsx +++ b/packages/web/src/pages/Event/Event2024Spring.tsx @@ -4,7 +4,7 @@ import { Link } from "react-router-dom"; import { QuestId } from "@/types/event2024spring"; import { useValueRecoilState } from "@/hooks/useFetchRecoilState"; -import useQuery, { useAxios } from "@/hooks/useTaxiAPI"; +import { useAxios } from "@/hooks/useTaxiAPI"; import AdaptiveDiv from "@/components/AdaptiveDiv"; import EventButton from "@/components/Event/EventButton";