Skip to content

Commit 0b317bd

Browse files
committed
FEAT :: Add PhotoCard API Needs Login.
1 parent 940ec7d commit 0b317bd

File tree

5 files changed

+100
-34
lines changed

5 files changed

+100
-34
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {BlurModal} from "./BlurModal";
2+
import {DivButton} from "../../button/DivButton";
3+
4+
export interface CheckModalProps {
5+
setModal: (value: JSX.Element | undefined) => void
6+
checkMessage: string
7+
cancelMessage: string
8+
onCheck: () => void
9+
children: JSX.Element[]
10+
}
11+
12+
export const CheckModal = (props: CheckModalProps) => {
13+
return (
14+
<BlurModal
15+
className={"w-[650px]"}
16+
setModel={props.setModal}>
17+
<div className={"flex flex-col items-center justify-center gap-[30px] py-[20px]"}>
18+
{props.children}
19+
</div>
20+
<div className={"flex flex-row gap-[30px]"}>
21+
<DivButton
22+
className={"flex items-center justify-center rounded-[10px] w-[250px] py-[20px] bg-photocard-stroke"}
23+
onClick={() => {
24+
props.setModal(undefined)
25+
}}>
26+
<p className={"text-text-black text-[26px] font-p-extra-bold"}>{props.cancelMessage}</p>
27+
</DivButton>
28+
<DivButton
29+
className={"flex items-center justify-center rounded-[10px] w-[250px] py-[20px] bg-highlight-orange"}
30+
onClick={props.onCheck}>
31+
<p className={"text-text-black text-[26px] font-p-extra-bold"}>{props.checkMessage}</p>
32+
</DivButton>
33+
</div>
34+
</BlurModal>
35+
)
36+
}
Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
1-
import {BlurModal} from "./BlurModal";
2-
import {DivButton} from "../../button/DivButton";
31
import {deleteSessionId} from "../../../module/cookie/SessionManager";
2+
import {CheckModal} from "./CheckModal";
43

54
export interface LogoutModalProps {
65
setModal: (value: JSX.Element | undefined) => void
7-
onCancel: () => void
86
}
97

108
export const LogoutModal = (props: LogoutModalProps) => {
119
return (
12-
<BlurModal
13-
className={"w-[650px]"}
14-
setModel={props.setModal}>
15-
<div className={"flex flex-col items-center justify-center gap-[30px] py-[20px]"}>
16-
<p className={"text-text-white text-[32px] font-p-semi-bold"}>이미 로그인중입니다.</p>
17-
<p className={"text-text-white text-[24px] font-p-semi-bold"}>로그아웃하시겠습니까?</p>
18-
</div>
19-
<div className={"flex flex-row gap-[30px]"}>
20-
<DivButton
21-
className={"flex items-center justify-center rounded-[10px] w-[250px] py-[20px] bg-photocard-stroke"}
22-
onClick={props.onCancel}>
23-
<p className={"text-text-black text-[26px] font-p-extra-bold"}>Back</p>
24-
</DivButton>
25-
<DivButton
26-
className={"flex items-center justify-center rounded-[10px] w-[250px] py-[20px] bg-highlight-orange"}
27-
onClick={() => {
28-
deleteSessionId()
29-
location.pathname = "/"
30-
}}>
31-
<p className={"text-text-black text-[26px] font-p-extra-bold"}>Logout</p>
32-
</DivButton>
33-
</div>
34-
</BlurModal>
10+
<CheckModal
11+
setModal={props.setModal}
12+
checkMessage={"Logout"}
13+
cancelMessage={"Back"}
14+
onCheck={() => {
15+
deleteSessionId()
16+
location.pathname = "/"
17+
}}>
18+
<p className={"text-text-white text-[32px] font-p-semi-bold"}>이미 로그인중입니다.</p>
19+
<p className={"text-text-white text-[24px] font-p-semi-bold"}>로그아웃하시겠습니까?</p>
20+
</CheckModal>
3521
)
3622
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {CheckModal} from "./CheckModal";
2+
3+
export interface NeedLoginModalProps {
4+
setModal: (value: JSX.Element | undefined) => void
5+
}
6+
7+
export const NeedLoginModal = (props: NeedLoginModalProps) => {
8+
return (
9+
<CheckModal
10+
setModal={props.setModal}
11+
checkMessage={"Login Page"}
12+
cancelMessage={"Back"}
13+
onCheck={() => {
14+
location.pathname = "/auth/login"
15+
}}>
16+
<p className={"text-text-white text-[32px] font-p-semi-bold"}>로그인이 필요한 서비스입니다.</p>
17+
<p className={"text-text-white text-[24px] font-p-semi-bold"}>로그인 페이지로 이동하시겠습니까?</p>
18+
</CheckModal>
19+
)
20+
}

src/component/header/HeaderButtons.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {DivIconButton} from "../button/DivIconButton";
77
import {LogoutModal} from "../body/modal/LogoutModal";
88
import {CurrentPage, PageName} from "../../initializer/CurrentPage";
99
import {IconTextToast} from "../body/toast/IconTextToast";
10+
import {isLoggedIn, setIsLoggedIn} from "../../module/status/StatusManager";
11+
import {NeedLoginModal} from "../body/modal/NeedLoginModal";
1012

1113
export const HeaderButtons = () => {
1214

@@ -29,6 +31,7 @@ export const HeaderButtons = () => {
2931
method: HttpMethod.GET,
3032
url: "/user"
3133
}).then((response) => {
34+
setIsLoggedIn(true);
3235
if (CurrentPage.getCurrentPage() == PageName.LOGIN ||
3336
CurrentPage.getCurrentPage() == PageName.SIGNUP) {
3437
setToast(
@@ -54,9 +57,7 @@ export const HeaderButtons = () => {
5457
className: "rounded-[10px] h-[50px] p-[10px] hover:bg-header-hover animated",
5558
onClick: () => {
5659
setModal(
57-
<LogoutModal setModal={setModal} onCancel={() => {
58-
setModal(undefined)
59-
}}/>
60+
<LogoutModal setModal={setModal}/>
6061
)
6162
}
6263
}
@@ -83,11 +84,29 @@ export const HeaderButtons = () => {
8384
}}
8485
text={"내 포토카드"}
8586
/>*/}
86-
<HeaderButton
87-
iconUri={"/Plus.svg"}
88-
text={"포토카드 추가"}
89-
gotoPath={"/add"}
90-
/>
87+
<div
88+
onClick={(event) => {
89+
if (!isLoggedIn) {
90+
event.stopPropagation()
91+
setModal(
92+
<NeedLoginModal setModal={setModal}/>
93+
)
94+
} else {
95+
location.pathname = "/add"
96+
}
97+
}}>
98+
<DivIconButton
99+
iconProps={{
100+
iconUri: "/Plus.svg",
101+
iconWidth: "20px",
102+
iconHeight: "20px"
103+
}}
104+
gap={"10px"}
105+
text={"포토카드 추가"}
106+
textSize={"16px"}
107+
className={"rounded-[10px] h-[50px] p-[10px] hover:bg-header-hover animated"}
108+
/>
109+
</div>
91110
{authButton}
92111
{modal && modal}
93112
{toast && toast}

src/module/status/StatusManager.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export let isLoggedIn = false;
2+
3+
export let setIsLoggedIn = (bool: boolean) => {
4+
isLoggedIn = bool
5+
}

0 commit comments

Comments
 (0)