Skip to content

Commit 271e9e0

Browse files
authored
[FRONTEND] 초기 설정화면 리뉴얼 (#111)
## 📝작업 내용 초기 설정 화면에서 현재 로그인된 이메일 주소 확인하고 로그아웃까지 할 수 있게 추가 현재 설정 진행 상태 저장해서 이후 로그인시에도 해당 단계로 자동 라우팅 + 설정안하고 다음 단계로 넘어가면 이전 단계로 강제 라우팅 ## 💬리뷰 요구사항(선택) 뒤로 가기 버튼도 필요할지
1 parent dc33ff4 commit 271e9e0

File tree

8 files changed

+104
-31
lines changed

8 files changed

+104
-31
lines changed

frontend/src/components/common/setting/NextButton/nextButton.module.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.nextBtn{
1+
.nextBtn {
22
width: 145px;
33
height: 50px;
44
border-radius: 999px;
@@ -9,6 +9,7 @@
99
font-weight: bold;
1010
}
1111

12-
.able{
12+
.able {
1313
background-color: #ff5525;
14+
cursor: pointer;
1415
}

frontend/src/components/common/setting/interestSelector/InterestSelector.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ import AddInterestButton from "../AddInterestButton/AddInterestButton";
55
import { useState, useEffect } from "react";
66
import { useProfileSetupStore } from "../../../../stores/useProfileSetupStore";
77

8-
// 임시 데이터 (dummy_interest.json이 없으므로)
9-
const data: InterestItem[] = [];
8+
// 관심사 데이터
9+
const data: InterestItem[] = [
10+
{ id: 1, interest: "게임" },
11+
{ id: 2, interest: "프로그래밍" },
12+
{ id: 3, interest: "디자인" },
13+
{ id: 4, interest: "영상 편집" },
14+
{ id: 5, interest: "음악" },
15+
{ id: 6, interest: "사진" },
16+
{ id: 7, interest: "3D 모델링" },
17+
{ id: 8, interest: "문서 작업" },
18+
{ id: 9, interest: "데이터 분석" },
19+
{ id: 10, interest: "AI/머신러닝" },
20+
];
1021

1122
type InterestItem = {
1223
id: number;
@@ -88,16 +99,16 @@ export default function InterestSelector({
8899
<div className={style.container}>
89100
{data.map((interestItem: InterestItem) => (
90101
<InterestButton
91-
key={interestItem.interest}
102+
key={`interest-${interestItem.id}`}
92103
onClick={() => handleClick(interestItem.interest)}
93104
selected={selectedInterests.includes(interestItem.interest)}
94105
>
95106
<div className={style.inputContainer}>{interestItem.interest}</div>
96107
</InterestButton>
97108
))}
98-
{customInterests.map((interest: string) => (
109+
{customInterests.map((interest: string, index: number) => (
99110
<InterestButton
100-
key={interest}
111+
key={`custom-${index}-${interest}`}
101112
onClick={() => handleClick(interest)}
102113
selected={selectedInterests.includes(interest)}
103114
>

frontend/src/components/layout/ExpertVerifyLayout.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ import { useNavigate } from "react-router";
1111
import Button from "../common/Button/Button";
1212
import { useProfileSetupStore } from "@/stores/useProfileSetupStore";
1313
import { useEffect } from "react";
14+
import { useAuthStore } from "@/stores/useAuthStore";
1415

1516
export default function ExpertVerifyLayout() {
1617
const { mutate: logout } = useLogout();
1718
const navigate = useNavigate();
1819
const { data: certifications, isLoading } = useCertificationGet();
1920
const { mutate: deleteCertification } = useCertificationDelete();
20-
const { setCurrentStep } = useProfileSetupStore();
21+
const { setCurrentStep, tempRole } = useProfileSetupStore();
22+
const { user } = useAuthStore();
2123

2224
useEffect(() => {
25+
// tempRole이 EXPERT가 아니면 Setting 페이지로 리다이렉트
26+
if (tempRole !== "EXPERT") {
27+
navigate("/setting");
28+
return;
29+
}
30+
2331
// 페이지 진입 시 현재 단계 저장
2432
setCurrentStep("expert-verify");
25-
}, [setCurrentStep]);
26-
33+
}, [tempRole, setCurrentStep, navigate]);
2734
const instructionItems = [
2835
"컴퓨터공학 관련 학위증명서",
2936
"IT 관련 자격증 (정보처리기사, 컴활 등)",
@@ -66,10 +73,12 @@ export default function ExpertVerifyLayout() {
6673
title="전문가 인증"
6774
description="전문가임을 인증할 수 있는 다음 중 하나의 문서를 첨부해주세요."
6875
>
69-
<button onClick={handleLogout} className={styles.logoutBtn}>
70-
로그아웃
71-
</button>
72-
76+
<div className={styles.userInfo}>
77+
<button onClick={handleLogout} className={styles.logoutBtn}>
78+
로그아웃
79+
</button>
80+
{user?.email && <span className={styles.userEmail}>{user.email}</span>}
81+
</div>
7382
{isLoading ? (
7483
<div className={styles.loadingContainer}>
7584
<p>인증 상태를 확인하는 중...</p>

frontend/src/components/layout/SecondSettingLayout.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,29 @@ import { useInitializeUser } from "../../api/services/useInitializeUser";
88
import { useProfileSetupStore } from "../../stores/useProfileSetupStore";
99
import { useLogout } from "@/api/services/useLogout";
1010
import Button from "../common/Button/Button";
11+
import { useAuthStore } from "@/stores/useAuthStore";
12+
import { useNavigate } from "react-router";
1113

1214
export default function SecondSettingLayout() {
1315
const [count, setCount] = useState(0);
1416
const initializeMutation = useInitializeUser();
1517
const { tempRole, tempInterestIds, setCurrentStep } = useProfileSetupStore();
1618
const { mutate: logout } = useLogout();
19+
const { user } = useAuthStore();
20+
const navigate = useNavigate();
1721

1822
useEffect(() => {
23+
// tempRole이 없으면 Setting 페이지로 리다이렉트
24+
if (!tempRole) {
25+
navigate("/setting");
26+
return;
27+
}
28+
1929
// 페이지 진입 시 현재 단계 저장
2030
setCurrentStep("interest-selection");
21-
}, [setCurrentStep]);
22-
31+
}, [tempRole, setCurrentStep, navigate]);
2332
const handleNext = () => {
2433
if (count > 0 && tempRole) {
25-
console.log("🎯 사용자 초기화 시작");
2634
initializeMutation.mutate({
2735
role: tempRole,
2836
interest_ids: tempInterestIds,
@@ -45,7 +53,7 @@ export default function SecondSettingLayout() {
4553
<InterestSelector count={count} setCount={setCount} />
4654
</div>
4755
<div className={style.interestFooter}>
48-
<div className={style.leftSection}>
56+
<div className={style.userInfo}>
4957
<div className={style.logoutBtnWrapper}>
5058
<Button
5159
color="white"
@@ -55,6 +63,7 @@ export default function SecondSettingLayout() {
5563
size="md"
5664
/>
5765
</div>
66+
{user?.email && <span className={style.userEmail}>{user.email}</span>}
5867
<div className={style.interestCount}>선택된 관심사: {count}</div>
5968
</div>
6069
<NextButton

frontend/src/components/layout/SettingLayout.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useState, useEffect } from "react";
1111
import { useProfileSetupStore } from "../../stores/useProfileSetupStore";
1212
import { useLogout } from "@/api/services/useLogout";
1313
import Button from "../common/Button/Button";
14+
import { useAuthStore } from "@/stores/useAuthStore";
1415

1516
export default function SettingLayout() {
1617
const [abled, setAbled] = useState(false);
@@ -22,9 +23,9 @@ export default function SettingLayout() {
2223
const navigate = useNavigate();
2324
const { setTempRole, setCurrentStep } = useProfileSetupStore();
2425
const { mutate: logout } = useLogout();
26+
const { user } = useAuthStore();
2527

2628
useEffect(() => {
27-
// 페이지 진입 시 현재 단계 저장
2829
setCurrentStep("role-selection");
2930
}, [setCurrentStep]);
3031

@@ -82,14 +83,19 @@ export default function SettingLayout() {
8283
/>
8384
</div>
8485
<div className={style.btnContainer}>
85-
<div className={style.logoutBtnWrapper}>
86-
<Button
87-
color="white"
88-
backgroundColor="#f5f5f5"
89-
content="로그아웃"
90-
onClick={handleLogout}
91-
size="md"
92-
/>
86+
<div className={style.userInfo}>
87+
<div className={style.logoutBtnWrapper}>
88+
<Button
89+
color="white"
90+
backgroundColor="#f5f5f5"
91+
content="로그아웃"
92+
onClick={handleLogout}
93+
size="md"
94+
/>
95+
</div>
96+
{user?.email && (
97+
<span className={style.userEmail}>{user.email}</span>
98+
)}
9399
</div>
94100
<NextButton btnAbled={abled} onClick={handleNext} text="다음" />
95101
</div>

frontend/src/components/layout/expertVerifyLayout.module.css

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@
77
max-width: 800px;
88
}
99

10-
.logoutBtn {
10+
.userInfo {
1111
position: absolute;
12-
top: 50px;
13-
left: 50px;
12+
bottom: 50px;
13+
left: 150px;
14+
display: flex;
15+
align-items: center;
16+
gap: 12px;
17+
}
18+
19+
.userEmail {
20+
font-size: 14px;
21+
font-weight: 500;
22+
color: #666;
23+
padding: 8px 16px;
24+
background-color: #f9f9f9;
25+
border-radius: 8px;
26+
}
27+
28+
.logoutBtn {
1429
padding: 12px 24px;
1530
background-color: #f5f5f5;
1631
border: 1px solid #ddd;

frontend/src/components/layout/secondSettingLayout.module.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@
2222
align-items: center;
2323
}
2424

25-
.leftSection {
25+
.userInfo {
2626
display: flex;
2727
align-items: center;
2828
gap: 20px;
2929
}
3030

31+
.userEmail {
32+
font-size: 14px;
33+
font-weight: 500;
34+
color: #666;
35+
padding: 8px 16px;
36+
border-radius: 8px;
37+
}
38+
3139
.logoutBtnWrapper button {
3240
background-color: #f5f5f5 !important;
3341
color: #666 !important;

frontend/src/components/layout/settingLayout.module.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@
4040
justify-content: space-between;
4141
}
4242

43+
.userInfo {
44+
display: flex;
45+
align-items: center;
46+
gap: 12px;
47+
}
48+
49+
.userEmail {
50+
font-size: 14px;
51+
font-weight: 500;
52+
color: #666;
53+
padding: 8px 16px;
54+
border-radius: 8px;
55+
}
56+
4357
.logoutBtnWrapper button {
4458
background-color: #f5f5f5 !important;
4559
color: #666 !important;

0 commit comments

Comments
 (0)