Skip to content

Commit

Permalink
Merge pull request #530 from sparcs-kaist/dev
Browse files Browse the repository at this point in the history
Main branch update from Dev branch
  • Loading branch information
14KGun authored Apr 15, 2023
2 parents 1166a1d + ab0c09c commit 91797f0
Show file tree
Hide file tree
Showing 84 changed files with 1,204 additions and 784 deletions.
10 changes: 5 additions & 5 deletions src/atoms/loginInfoDetail.ts → src/atoms/loginInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from "recoil";

export type LoginInfoDetailType = {
export type LoginInfoType = Nullable<{
agreeOnTermsOfService: boolean;
ban: boolean;
email: string;
Expand All @@ -15,11 +15,11 @@ export type LoginInfoDetailType = {
account: string;
deviceToken: Nullable<string>;
deviceType: "web" | "app";
};
}>;

const loginInfoDetailAtom = atom<Nullable<LoginInfoDetailType>>({
key: "loginInfoDetailAtom",
const loginInfoAtom = atom<LoginInfoType>({
key: "loginInfoAtom",
default: null,
});

export default loginInfoDetailAtom;
export default loginInfoAtom;
13 changes: 0 additions & 13 deletions src/atoms/myRoom.ts

This file was deleted.

16 changes: 16 additions & 0 deletions src/atoms/myRooms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { atom } from "recoil";

export type MyRoomsType = {
ongoing: Array<any>; // FIXME: 방의 타입 정의
done: Array<any>;
};

const myRoomsAtom = atom<MyRoomsType>({
key: "myRoomsAtom",
default: {
ongoing: [],
done: [],
},
});

export default myRoomsAtom;
6 changes: 3 additions & 3 deletions src/atoms/notificationOptions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { atom } from "recoil";

export type notificationOptionsType = {
export type notificationOptionsType = Nullable<{
advertisement: boolean;
beforeDepart: boolean;
chatting: boolean;
notice: boolean;
keywords: [string];
};
}>;

const notificationOptionsAtom = atom<Nullable<notificationOptionsType>>({
const notificationOptionsAtom = atom<notificationOptionsType>({
key: "notificationOptionsAtom",
default: null,
});
Expand Down
8 changes: 0 additions & 8 deletions src/atoms/taxiLocation.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/atoms/taxiLocations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { atom } from "recoil";

export type TaxiLocationsType = Array<any>;

const taxiLocationsAtom = atom<TaxiLocationsType>({
key: "taxiLocationsAtom",
default: [],
});

export default taxiLocationsAtom;
17 changes: 9 additions & 8 deletions src/components/AccountSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import regExpTest from "tools/regExpTest";
import theme from "tools/theme";

import bankNames from "static/bankNames";
Expand All @@ -12,20 +11,22 @@ type AccountSelectorProps = {
};

const AccountSelector = (props: AccountSelectorProps) => {
const initializeAccountState = () => {
const account = props.accountNumber.split(" ");
return [account?.[0] || bankNames[0], account?.[1] || ""];
};

const { t } = useTranslation("mypage");
const [bankNumber, setBankNumber] = useState("");
const [bankName, setBankName] = useState(bankNames[0]);
const [bankName, setBankName] = useState(initializeAccountState()[0]);
const [bankNumber, setBankNumber] = useState(initializeAccountState()[1]);

useEffect(() => {
props.setAccountNumber(bankName + " " + bankNumber);
}, [bankName, bankNumber]);

useEffect(() => {
if (regExpTest.account(props.accountNumber)) {
const account = props.accountNumber.split(" ");
setBankName(account[0]);
setBankNumber(account[1]);
}
setBankName(initializeAccountState()[0]);
setBankNumber(initializeAccountState()[1]);
}, [props.accountNumber]);

const styleTitle: CSS = {
Expand Down
File renamed without changes.
30 changes: 16 additions & 14 deletions src/components/HeaderBar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import theme from "tools/theme";

const HeaderBar = () => {
return (
<div
style={{
background: theme.purple,
width: "100%",
height: "max(5px, env(safe-area-inset-top))",
position: "fixed",
top: "0px",
left: "0px",
zIndex: theme.zIndex_headerBar,
}}
/>
);
type HeaderBarProps = {
position?: "fixed" | "absolute";
};

const HeaderBar = ({ position = "fixed" }: HeaderBarProps) => (
<div
style={{
background: theme.purple,
width: "100%",
height: "max(5px, env(safe-area-inset-top))",
position,
top: "0px",
left: "0px",
zIndex: theme.zIndex_headerBar,
}}
/>
);

export default HeaderBar;
25 changes: 25 additions & 0 deletions src/components/Link/LinkLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useLocation } from "react-router-dom";

import { backServer } from "loadenv";

type LinkLoginProps = {
children: React.ReactNode;
redirect?: string;
};

const LinkLogin = ({ children, redirect }: LinkLoginProps) => {
const { pathname, search } = useLocation();
const redirectPath = redirect || pathname + search;
return (
<a
href={`${backServer}/auth/sparcssso?redirect=${encodeURIComponent(
redirectPath
)}`}
css={{ textDecoration: "none" }}
>
{children}
</a>
);
};

export default LinkLogin;
28 changes: 28 additions & 0 deletions src/components/Link/LinkLogout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useCallback, useRef } from "react";
import { useHistory, useLocation } from "react-router-dom";

type LinkLogoutProps = {
children: React.ReactNode;
redirect?: string;
};

export const useOnClickLogout = (redirect?: string) => {
const history = useHistory();
const { pathname, search } = useLocation();
const redirectPath = redirect || pathname + search;
const isClicked = useRef(false);

return useCallback(async () => {
if (isClicked.current) return;
isClicked.current = true;
history.replace(`/logout?redirect=${encodeURIComponent(redirectPath)}`);
isClicked.current = false;
}, [history, redirectPath]);
};

const LinkLogout = ({ children, redirect }: LinkLogoutProps) => {
const onClickLogout = useOnClickLogout(redirect);
return <div onClick={onClickLogout}>{children}</div>;
};

export default LinkLogout;
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Member.propTypes = {
period: PropTypes.string,
};

const PopupMembers = (props) => {
const ModalCredit = (props) => {
const { t } = useTranslation("mypage");

const styleTitle = {
Expand Down Expand Up @@ -95,7 +95,7 @@ const PopupMembers = (props) => {
return (
<Modal
isOpen={props.isOpen}
onChangeIsOpen={props.onClose}
onChangeIsOpen={props.onChangeIsOpen}
width={theme.modal_width_large}
padding="16px 12px 12px"
>
Expand Down Expand Up @@ -127,9 +127,9 @@ const PopupMembers = (props) => {
</Modal>
);
};
PopupMembers.propTypes = {
ModalCredit.propTypes = {
isOpen: PropTypes.bool,
onClose: PropTypes.func,
onChangeIsOpen: PropTypes.func,
};

export default PopupMembers;
export default ModalCredit;
Loading

0 comments on commit 91797f0

Please sign in to comment.