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

Main branch update from Dev branch #677

Merged
merged 4 commits into from
Sep 27, 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
1 change: 1 addition & 0 deletions src/atoms/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type LoginInfoType = Nullable<{
profileImgUrl: string;
subinfo: { kaist: string; sparcs: string; facebook: string; twitter: string };
withdraw: boolean;
phoneNumber?: string;
account: string;
// deviceType: "web" | "app"; // #580 - loadenv의 deviceType을 사용하여야 합니다.
deviceToken: Nullable<string>;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Event/WhiteContainerSuggestJoinEvent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, useState } from "react";

import { useValueRecoilState } from "hooks/useFetchRecoilState";
import { useIsLogin, useValueRecoilState } from "hooks/useFetchRecoilState";

import Button from "components/Button";
import LinkEvent2023FallInstagramStoryShare from "components/Link/LinkEvent2023FallInstagramStoryShare";
Expand All @@ -14,7 +14,7 @@ import { deviceType } from "tools/loadenv";
import theme from "tools/theme";

const WhiteContainerSuggestJoinEvent = () => {
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const isLogin = useIsLogin();
const { isAgreeOnTermsOfEvent, completedQuests } =
useValueRecoilState("event2023FallInfo") || {};

Expand Down
4 changes: 2 additions & 2 deletions src/components/Link/LinkEvent2023FallInstagramStoryShare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 { useIsLogin, useValueRecoilState } from "hooks/useFetchRecoilState";

import ModalEvent2023FallJoin from "components/ModalPopup/ModalEvent2023FallJoin";

Expand Down Expand Up @@ -31,7 +31,7 @@ const LinkEvent2023FallInstagramStoryShare = ({
...aProps
}: LinkEvent2023FallInstagramStoryShareProps) => {
const setAlert = useSetRecoilState(alertAtom);
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const isLogin = useIsLogin();
const { isAgreeOnTermsOfEvent } =
useValueRecoilState("event2023FallInfo") || {};
const [isOpenJoin, setIsOpenJoin] = useState<boolean>(false);
Expand Down
3 changes: 2 additions & 1 deletion src/components/ModalPopup/Body/BodyRoomSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useHistory } from "react-router-dom";

import {
useFetchRecoilState,
useIsLogin,
useValueRecoilState,
} from "hooks/useFetchRecoilState";
import useIsTimeOver from "hooks/useIsTimeOver";
Expand Down Expand Up @@ -110,7 +111,7 @@ const BodyRoomSelection = ({ roomInfo }: BodyRoomSelectionProps) => {
const fetchMyRooms = useFetchRecoilState("myRooms");
const setAlert = useSetRecoilState(alertAtom);

const isLogin = !!loginInfo?.id; // 로그인 여부
const isLogin = useIsLogin() && !!loginInfo?.id; // 로그인 여부
const isRoomFull = roomInfo && roomInfo.part.length >= roomInfo.maxPartLength; // 방이 꽉 찼는지 여부
const isAlreadyPart =
isLogin &&
Expand Down
3 changes: 2 additions & 1 deletion src/components/ModalPopup/ModalEvent2023FallItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { EventItem } from "types/event2023fall";
import { useDelayBoolean } from "hooks/useDelay";
import {
useFetchRecoilState,
useIsLogin,
useValueRecoilState,
} from "hooks/useFetchRecoilState";
import { useAxios } from "hooks/useTaxiAPI";
Expand Down Expand Up @@ -39,7 +40,7 @@ const ModalEvent2023FallItem = ({
}: ModalEvent2023FallItemProps) => {
const fetchEvent2023FallInfo = useFetchRecoilState("event2023FallInfo");
const event2023FallInfo = useValueRecoilState("event2023FallInfo");
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const isLogin = useIsLogin();

const axios = useAxios();
const setAlert = useSetRecoilState(alertAtom);
Expand Down
99 changes: 74 additions & 25 deletions src/components/ModalPopup/ModalEvent2023FallJoin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useCallback, useMemo, useState } from "react";

import { useEvent2023FallQuestComplete } from "hooks/event/useEvent2023FallQuestComplete";
import {
useFetchRecoilState,
useIsLogin,
useValueRecoilState,
} from "hooks/useFetchRecoilState";
import { useAxios } from "hooks/useTaxiAPI";

import Button from "components/Button";
Expand All @@ -21,6 +26,12 @@ type ModalEvent2023FallJoinProps = Parameters<typeof Modal>[0];
const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
const axios = useAxios();
const setAlert = useSetRecoilState(alertAtom);
const isLogin = useIsLogin();
const { phoneNumber: phoneNumberFromLoginInfo } =
useValueRecoilState("loginInfo") || {};
const { isAgreeOnTermsOfEvent } =
useValueRecoilState("event2023FallInfo") || {};
const fetchLoginInfo = useFetchRecoilState("loginInfo");
//#region event2023Fall
const event2023FallQuestComplete = useEvent2023FallQuestComplete();
//#endregion
Expand All @@ -38,6 +49,7 @@ const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
method: "post",
data: { phoneNumber },
onSuccess: () => {
fetchLoginInfo();
//#region event2023Fall
event2023FallQuestComplete("firstLogin");
//#endregion
Expand All @@ -61,7 +73,7 @@ const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
const styleText = {
...theme.font12,
color: theme.gray_text,
margin: "0 8px 12px",
margin: "0 8px",
};
const styleInputWrap = {
margin: "12px 8px",
Expand All @@ -85,6 +97,7 @@ const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
</b>
를 하여 방에서 나가야 합니다.
</div>
<div css={{ height: "12px" }} />
<div css={styleText}>
• 실제 Taxi 동승을 하지 않고{" "}
<b css={{ color: theme.black }}>허위로 방을 개설하거나 참여</b>하여
Expand All @@ -101,6 +114,7 @@ const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
요청할 수 있습니다. 또한, 본 서비스를 부정 이용하는 사용자에게는 택시
서비스 이용 제한 및 법적 조치를 취할 수 있습니다.
</div>
<div css={{ height: "12px" }} />
<div css={styleText}>
•{" "}
<b css={{ color: theme.red_text }}>
Expand All @@ -111,31 +125,66 @@ const ModalEvent2023FallJoin = (modalProps: ModalEvent2023FallJoinProps) => {
입력해주신 연락처는 이후 수정이 불가능합니다.
</b>
</div>
<DottedLine />
<div css={styleInputWrap}>
전화번호
<Input
value={phoneNumber}
onChangeValue={setPhoneNumber}
placeholder="010-0000-0000 형식으로 입력하세요"
css={{ width: "100%", marginLeft: "10px" }}
/>
<div css={{ height: "12px" }} />
<div css={styleText}>
• 본 약관은 동의 이후에도 {'"'}마이페이지{">"}한가위 송편 이벤트 참여
약관{'"'}에서 다시 확인하실 수 있습니다.{" "}
</div>
<Button
type="purple_inset"
css={{
width: "100%",
padding: "10px 0 9px",
borderRadius: "8px",
...theme.font14_bold,
}}
onClick={onClickJoin}
disabled={!isValidPhoneNumber}
>
{!isValidPhoneNumber
? "올바른 전화번호를 입력하세요"
: "동의 후 이벤트 참여하기"}
</Button>
{isLogin &&
(isAgreeOnTermsOfEvent ? (
<>
<div css={{ height: "12px" }} />
<DottedLine />
<div css={styleInputWrap}>
전화번호
<Input
value={phoneNumberFromLoginInfo || ""}
css={{ width: "100%", marginLeft: "10px" }}
/>
</div>
<Button
type="purple_inset"
css={{
width: "100%",
padding: "10px 0 9px",
borderRadius: "8px",
...theme.font14_bold,
}}
disabled
>
이미 동의하셨습니다
</Button>
</>
) : (
<>
<div css={{ height: "12px" }} />
<DottedLine />
<div css={styleInputWrap}>
전화번호
<Input
value={phoneNumber}
onChangeValue={setPhoneNumber}
placeholder="010-0000-0000 형식으로 입력하세요"
css={{ width: "100%", marginLeft: "10px" }}
/>
</div>
<Button
type="purple_inset"
css={{
width: "100%",
padding: "10px 0 9px",
borderRadius: "8px",
...theme.font14_bold,
}}
onClick={onClickJoin}
disabled={!isValidPhoneNumber}
>
{!isValidPhoneNumber
? "올바른 전화번호를 입력하세요"
: "동의 후 이벤트 참여하기"}
</Button>
</>
))}
</Modal>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/ModalPopup/ModalTerms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";

import {
useFetchRecoilState,
useIsLogin,
useValueRecoilState,
} from "hooks/useFetchRecoilState";
import { useAxios } from "hooks/useTaxiAPI";
Expand Down Expand Up @@ -36,7 +37,7 @@ const ModalTerms = ({ isOpen, onChangeIsOpen = () => {} }: ModalTermsProps) => {

const loginInfo = useValueRecoilState("loginInfo");
const fetchLoginInfo = useFetchRecoilState("loginInfo");
const isLogin = !!loginInfo?.id; // 로그인 여부
const isLogin = useIsLogin(); // 로그인 여부
const isAgree = !!loginInfo?.agreeOnTermsOfService; // 이용약관 동의 여부

useEffect(() => {
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useFetchRecoilState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ export const useSyncRecoilStateEffect = () => {
const fetchEvent2023FallInfo = useFetchRecoilState("event2023FallInfo");
useEffect(fetchEvent2023FallInfo, [userId]);
};

export const useIsLogin = (): boolean => {
const isLogin = !!useValueRecoilState("loginInfo")?.id;
return isLogin;
};
3 changes: 2 additions & 1 deletion src/pages/Addroom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useHistory } from "react-router-dom";
import { useEvent2023FallQuestComplete } from "hooks/event/useEvent2023FallQuestComplete";
import {
useFetchRecoilState,
useIsLogin,
useValueRecoilState,
} from "hooks/useFetchRecoilState";
import { useAxios } from "hooks/useTaxiAPI";
Expand Down Expand Up @@ -57,7 +58,7 @@ const AddRoom = () => {
const randomRoomName = useMemo(randomRoomNameGenerator, []);

const setAlert = useSetRecoilState(alertAtom);
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const isLogin = useIsLogin();
const myRooms = useValueRecoilState("myRooms");
const fetchMyRooms = useFetchRecoilState("myRooms");
//#region event2023Fall
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Event/Event2023FallHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { memo, useMemo } from "react";

import type { Transaction } from "types/event2023fall";

import { useValueRecoilState } from "hooks/useFetchRecoilState";
import { useIsLogin, useValueRecoilState } from "hooks/useFetchRecoilState";
import useQuery from "hooks/useTaxiAPI";

import AdaptiveDiv from "components/AdaptiveDiv";
Expand Down Expand Up @@ -129,7 +129,7 @@ const HistorySection = () => {
};

const Event2023FallHistory = () => {
const isLogin = !!useValueRecoilState("loginInfo")?.id;
const isLogin = useIsLogin();
return (
<>
<HeaderWithLeftNav
Expand Down
7 changes: 4 additions & 3 deletions src/pages/Home/InfoSection.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useMemo } from "react";
import { Link } from "react-router-dom";

import { useIsLogin, useValueRecoilState } from "hooks/useFetchRecoilState";

import AdaptiveDiv from "components/AdaptiveDiv";
import Button from "components/Button";
import LinkLogin from "components/Link/LinkLogin";
import Room from "components/Room";

import loginInfoAtom from "atoms/loginInfo";
import myRoomsAtom from "atoms/myRooms";
import { useRecoilValue } from "recoil";

import moment, { getToday } from "tools/moment";
Expand All @@ -21,8 +22,8 @@ import { ReactComponent as TaxiLogoWhite } from "static/assets/sparcsLogos/TaxiL

const InfoSection = () => {
const loginInfo = useRecoilValue(loginInfoAtom);
const isLogin = !!loginInfo?.id;
const myRooms = useRecoilValue(myRoomsAtom);
const isLogin = useIsLogin();
const myRooms = useValueRecoilState("myRooms");
const randomTaxiSlogan = useMemo(randomTaxiSloganGenerator, []);

const styleContainer = {
Expand Down
35 changes: 19 additions & 16 deletions src/pages/Mypage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Footer from "components/Footer";
import LinkLogout from "components/Link/LinkLogout";
import {
ModalCredit,
ModalEvent2023FallJoin,
ModalMypageModify,
ModalNotification,
ModalPrivacyPolicy,
Expand All @@ -22,7 +23,7 @@ import WhiteContainerSuggestLogin from "components/WhiteContainer/WhiteContainer

import Menu from "./Menu";

import { nodeEnv } from "tools/loadenv";
import { eventMode, nodeEnv } from "tools/loadenv";
import theme from "tools/theme";
import { isNotificationOn } from "tools/trans";

Expand All @@ -38,36 +39,29 @@ const Mypage = () => {
const [isOpenReport, setIsOpenReport] = useState(false);
const [isOpenPolicy, setIsOpenPolicy] = useState(false);
const [isOpenPrivacyPolicy, setIsOpenPrivacyPolicy] = useState(false);
const [isOpenEventPolicy, setIsOpenEventPolicy] = useState(false);
const [isOpenMembers, setOpenIsMembers] = useState(false);

const onClickProfileModify = useCallback(
() => setIsOpenProfileModify(true),
[setIsOpenProfileModify]
[]
);
const onClickTranslation = useCallback(
() => i18n.changeLanguage(i18n.language === "ko" ? "en" : "ko"),
[i18n.changeLanguage, i18n.language]
);
const onClickNotification = useCallback(
() => setIsOpenNotification(true),
[setIsOpenNotification]
);
const onClickReport = useCallback(
() => setIsOpenReport(true),
[setIsOpenReport]
);
const onClickPolicy = useCallback(
() => setIsOpenPolicy(true),
[setIsOpenPolicy]
[]
);
const onClickReport = useCallback(() => setIsOpenReport(true), []);
const onClickPolicy = useCallback(() => setIsOpenPolicy(true), []);
const onClickPrivacyPolicy = useCallback(
() => setIsOpenPrivacyPolicy(true),
[setIsOpenPrivacyPolicy]
);
const onClickMembers = useCallback(
() => setOpenIsMembers(true),
[setOpenIsMembers]
[]
);
const onClickEventPolicy = useCallback(() => setIsOpenEventPolicy(true), []);
const onClickMembers = useCallback(() => setOpenIsMembers(true), []);

const styleProfImg = {
width: "50px",
Expand Down Expand Up @@ -189,6 +183,11 @@ const Mypage = () => {
<Menu icon="policy" onClick={onClickPrivacyPolicy}>
{t("privacy_policy")}
</Menu>
{eventMode === "2023fall" && (
<Menu icon="policy" onClick={onClickEventPolicy}>
한가위 송편 이벤트 참여 약관
</Menu>
)}
<Menu icon="credit" onClick={onClickMembers}>
{t("credit")}
</Menu>
Expand All @@ -205,6 +204,10 @@ const Mypage = () => {
onChangeIsOpen={setIsOpenPrivacyPolicy}
/>
<ModalTerms isOpen={isOpenPolicy} onChangeIsOpen={setIsOpenPolicy} />
<ModalEvent2023FallJoin
isOpen={isOpenEventPolicy}
onChangeIsOpen={setIsOpenEventPolicy}
/>
<ModalCredit isOpen={isOpenMembers} onChangeIsOpen={setOpenIsMembers} />
</AdaptiveDiv>
);
Expand Down
Loading
Loading