Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebFront
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebFront
Commits
dbd016bc
Commit
dbd016bc
authored
6 months ago
by
석찬 윤
Browse files
Options
Downloads
Patches
Plain Diff
feat: 비로그인 시 접근 차단 로직 추가 (
#11
)
parent
ce803830
Branches
master
No related tags found
1 merge request
!19
[#11] 마이페이지 개발
Pipeline
#10903
failed
6 months ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pages/Mypage.jsx
+21
-1
21 additions, 1 deletion
src/pages/Mypage.jsx
src/store/authStore.js
+2
-0
2 additions, 0 deletions
src/store/authStore.js
with
23 additions
and
1 deletion
src/pages/Mypage.jsx
+
21
−
1
View file @
dbd016bc
...
@@ -12,9 +12,10 @@ import Button from "../components/Button";
...
@@ -12,9 +12,10 @@ import Button from "../components/Button";
import
LogoIcon
from
"
../components/icons/LogoIcon
"
;
import
LogoIcon
from
"
../components/icons/LogoIcon
"
;
import
{
fetchMyMeetings
}
from
"
../api/meeting
"
;
import
{
fetchMyMeetings
}
from
"
../api/meeting
"
;
import
Card
from
"
../components/Card
"
;
import
Card
from
"
../components/Card
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
const
MyPage
=
()
=>
{
const
MyPage
=
()
=>
{
const
{
user
}
=
useAuthStore
();
// Zustand
에서 user 상태
가져오기
const
{
user
,
fetchSession
}
=
useAuthStore
();
// Zustand
상태 및 메서드
가져오기
const
[
activeTab
,
setActiveTab
]
=
useState
(
"
lightning
"
);
// 현재 활성화된 탭
const
[
activeTab
,
setActiveTab
]
=
useState
(
"
lightning
"
);
// 현재 활성화된 탭
const
[
receivedRequests
,
setReceivedRequests
]
=
useState
([]);
const
[
receivedRequests
,
setReceivedRequests
]
=
useState
([]);
const
[
sentRequests
,
setSentRequests
]
=
useState
([]);
const
[
sentRequests
,
setSentRequests
]
=
useState
([]);
...
@@ -29,9 +30,28 @@ const MyPage = () => {
...
@@ -29,9 +30,28 @@ const MyPage = () => {
const
[
meetingHasNext
,
setMeetingHasNext
]
=
useState
(
true
);
const
[
meetingHasNext
,
setMeetingHasNext
]
=
useState
(
true
);
const
[
meetingIsLoading
,
setMeetingIsLoading
]
=
useState
(
false
);
const
[
meetingIsLoading
,
setMeetingIsLoading
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
// 탭 변경 함수
// 탭 변경 함수
const
switchTab
=
(
tab
)
=>
setActiveTab
(
tab
);
const
switchTab
=
(
tab
)
=>
setActiveTab
(
tab
);
useEffect
(()
=>
{
const
fetchUserSession
=
async
()
=>
{
try
{
const
userInfo
=
localStorage
.
getItem
(
"
user
"
);
if
(
!
userInfo
)
{
alert
(
"
로그인이 필요한 페이지입니다.
"
);
navigate
(
"
/login
"
);
}
await
fetchSession
();
// 세션 정보 가져오기
}
catch
(
error
)
{
console
.
error
(
"
Failed to fetch session:
"
,
error
);
}
};
fetchUserSession
();
},
[
fetchSession
]);
// 페이지 마운트 시 실행
// 번개 모임 가져오기
// 번개 모임 가져오기
useEffect
(()
=>
{
useEffect
(()
=>
{
const
fetchMeetings
=
async
()
=>
{
const
fetchMeetings
=
async
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/store/authStore.js
+
2
−
0
View file @
dbd016bc
...
@@ -11,6 +11,7 @@ const useAuthStore = create((set) => ({
...
@@ -11,6 +11,7 @@ const useAuthStore = create((set) => ({
try
{
try
{
const
userInfo
=
await
getSessionInfo
();
const
userInfo
=
await
getSessionInfo
();
set
({
user
:
userInfo
});
set
({
user
:
userInfo
});
localStorage
.
setItem
(
"
user
"
,
{
user
:
userInfo
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"
Failed to fetch session info:
"
,
error
);
console
.
error
(
"
Failed to fetch session info:
"
,
error
);
set
({
user
:
null
});
set
({
user
:
null
});
...
@@ -24,6 +25,7 @@ const useAuthStore = create((set) => ({
...
@@ -24,6 +25,7 @@ const useAuthStore = create((set) => ({
try
{
try
{
await
logout
();
await
logout
();
set
({
user
:
null
});
set
({
user
:
null
});
localStorage
.
removeItem
(
"
user
"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"
Failed to logout:
"
,
error
);
console
.
error
(
"
Failed to logout:
"
,
error
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment