재로그인 버그 수정, test 버튼 추가, 브랜드 분석페이지 수정 .
This commit is contained in:
1 parent
61892a5d93
commit
e66eca1aca
10 files changed
+804
-173
No files matched your search
@@ -1,5 +1,7 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { UserMeResponse } from '../types/api';
|
||||
import { logout } from '../utils/api';
|
||||
|
||||
interface SidebarItemProps {
|
||||
icon: React.ReactNode;
|
||||
@@ -29,11 +31,30 @@ interface SidebarProps {
|
||||
activeItem: string;
|
||||
onNavigate: (id: string) => void;
|
||||
onHome?: () => void;
|
||||
userInfo?: UserMeResponse | null;
|
||||
onLogout?: () => void;
|
||||
}
|
||||
|
||||
const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome }) => {
|
||||
const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome, userInfo, onLogout }) => {
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
const [isMobileOpen, setIsMobileOpen] = useState(false);
|
||||
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
||||
|
||||
// 로그아웃 처리
|
||||
const handleLogout = async () => {
|
||||
if (isLoggingOut) return;
|
||||
setIsLoggingOut(true);
|
||||
try {
|
||||
await logout();
|
||||
onLogout?.();
|
||||
} catch (error) {
|
||||
console.error('Logout failed:', error);
|
||||
// 에러가 나도 로컬 토큰은 이미 삭제됨, 홈으로 이동
|
||||
onLogout?.();
|
||||
} finally {
|
||||
setIsLoggingOut(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
@@ -125,23 +146,36 @@ const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome }) =>
|
||||
|
||||
<div className="sidebar-footer">
|
||||
<div className={`profile-section ${isCollapsed ? 'collapsed' : ''}`}>
|
||||
<img
|
||||
src="https://picsum.photos/seed/user/100/100"
|
||||
alt="Profile"
|
||||
className="profile-avatar"
|
||||
/>
|
||||
{userInfo?.profile_image_url || userInfo?.thumbnail_image_url ? (
|
||||
<img
|
||||
src={userInfo.thumbnail_image_url || userInfo.profile_image_url || ''}
|
||||
alt="Profile"
|
||||
className="profile-avatar"
|
||||
/>
|
||||
) : (
|
||||
<div className="profile-avatar profile-avatar-default">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
|
||||
<circle cx="12" cy="7" r="4"/>
|
||||
</svg>
|
||||
</div>
|
||||
)}
|
||||
{!isCollapsed && (
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="profile-name">username1234</p>
|
||||
<p className="profile-name">{userInfo?.nickname || '사용자'}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button className={`logout-btn ${isCollapsed ? 'collapsed' : ''}`}>
|
||||
<button
|
||||
className={`logout-btn ${isCollapsed ? 'collapsed' : ''}`}
|
||||
onClick={handleLogout}
|
||||
disabled={isLoggingOut}
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/>
|
||||
</svg>
|
||||
{!isCollapsed && <span className="logout-btn-label">로그아웃</span>}
|
||||
{!isCollapsed && <span className="logout-btn-label">{isLoggingOut ? '로그아웃 중...' : '로그아웃'}</span>}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user