팀 생성 임시 완료
This commit is contained in:
+26
-6
@@ -171,9 +171,9 @@ const fetchClubs = async () => {
|
||||
}));
|
||||
|
||||
// 첫 번째 클럽의 memberType을 localStorage에 저장
|
||||
if (clubs.value.length > 0) {
|
||||
localStorage.setItem('userClubRole', clubs.value[0].memberType || '');
|
||||
localStorage.setItem('clubId', clubs.value[0].id);
|
||||
if (clubs.value.length > 0 && !selectedClubId.value) {
|
||||
selectedClubId.value = clubs.value[0].id;
|
||||
await setSelectedClub(clubs.value[0]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('클럽 목록 로드 실패:', error);
|
||||
@@ -199,15 +199,30 @@ const fetchClubInfo = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 클럽 선택
|
||||
const setSelectedClub = async (club) => {
|
||||
// 1. localStorage에 저장
|
||||
localStorage.setItem('clubId', club.id);
|
||||
localStorage.setItem('userClubRole', club.memberType || '');
|
||||
|
||||
// 2. 세션에도 저장 (백엔드에 clubId 전달)
|
||||
try {
|
||||
await apiClient.post('/api/club/select-club', { clubId: club.id });
|
||||
} catch (error) {
|
||||
console.error('클럽 ID 세션 저장 실패:', error);
|
||||
}
|
||||
|
||||
// 3. 프론트엔드 상태도 변경
|
||||
selectedClubId.value = club.id;
|
||||
};
|
||||
|
||||
// 클럽 변경 시
|
||||
const router = useRouter();
|
||||
const onClubChange = async () => {
|
||||
try {
|
||||
// 선택된 클럽의 memberType 찾기
|
||||
const selectedClub = clubs.value.find(club => club.id === selectedClubId.value);
|
||||
if (selectedClub) {
|
||||
localStorage.setItem('userClubRole', selectedClub.memberType || '');
|
||||
localStorage.setItem('clubId', selectedClub.id);
|
||||
await setSelectedClub(selectedClub);
|
||||
}
|
||||
|
||||
await fetchClubInfo();
|
||||
@@ -310,6 +325,11 @@ const handleUserLoggedIn = async () => {
|
||||
// 컴포넌트 마운트 시 데이터 로드
|
||||
onMounted(async () => {
|
||||
await loadUserData();
|
||||
const clubId = localStorage.getItem('clubId');
|
||||
if (clubId) {
|
||||
// 서버 세션에 clubId를 동기화
|
||||
apiClient.post('/api/club/select-club', { clubId });
|
||||
}
|
||||
if (isLoggedIn.value) {
|
||||
await fetchClubs();
|
||||
await fetchClubInfo();
|
||||
|
||||
Reference in New Issue
Block a user