feat: 모바일 하단 내비게이션·설정 패널 도입
This commit is contained in:
1 parent
bb0ab91bcc
commit
54e5d14127
11 files changed
+613
-375
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { UserMeResponse } from '../types/api';
|
||||
import { NAV_ITEMS, SETTINGS_ID } from './navItems';
|
||||
import SettingsPanel from './SettingsPanel';
|
||||
|
||||
interface BottomNavProps {
|
||||
activeItem: string;
|
||||
onNavigate: (id: string) => void;
|
||||
userInfo?: UserMeResponse | null;
|
||||
onLogout?: () => void;
|
||||
credits?: number | null;
|
||||
isGuest: boolean;
|
||||
onLoginClick: () => void;
|
||||
}
|
||||
|
||||
const BottomNav: React.FC<BottomNavProps> = ({ activeItem, onNavigate, userInfo, onLogout, credits, isGuest, onLoginClick }) => {
|
||||
const { t } = useTranslation();
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const settingsAnchorRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
const handleItemClick = (id: string) => {
|
||||
if (id === SETTINGS_ID) {
|
||||
setSettingsOpen(v => !v);
|
||||
return;
|
||||
}
|
||||
onNavigate(id);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{settingsOpen && <div className="settings-backdrop" onClick={() => setSettingsOpen(false)} />}
|
||||
{settingsOpen && (
|
||||
<SettingsPanel
|
||||
variant="bottom"
|
||||
onClose={() => setSettingsOpen(false)}
|
||||
onNavigate={onNavigate}
|
||||
activeItem={activeItem}
|
||||
userInfo={userInfo}
|
||||
credits={credits}
|
||||
isGuest={isGuest}
|
||||
onLogout={onLogout}
|
||||
onLoginClick={onLoginClick}
|
||||
anchorRef={settingsAnchorRef}
|
||||
/>
|
||||
)}
|
||||
<nav className="bottom-nav">
|
||||
{NAV_ITEMS.map(item => {
|
||||
const isActive = item.id === SETTINGS_ID ? settingsOpen : activeItem === item.id;
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
ref={item.id === SETTINGS_ID ? settingsAnchorRef : undefined}
|
||||
className={`bottom-nav-item ${isActive ? 'active' : ''}`}
|
||||
onClick={() => handleItemClick(item.id)}
|
||||
>
|
||||
{item.icon}
|
||||
<span>{t(item.labelKey)}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default BottomNav;
|
||||
@@ -0,0 +1,141 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { UserMeResponse } from '../types/api';
|
||||
import LanguageSwitch from './LanguageSwitch';
|
||||
import { NAV } from './navItems';
|
||||
|
||||
interface SettingsPanelProps {
|
||||
variant: 'sidebar' | 'bottom';
|
||||
onClose: () => void;
|
||||
onNavigate: (id: string) => void;
|
||||
activeItem: string;
|
||||
userInfo?: UserMeResponse | null;
|
||||
credits?: number | null;
|
||||
isGuest: boolean;
|
||||
isLoggingOut?: boolean;
|
||||
onLogout?: () => void;
|
||||
onLoginClick: () => void;
|
||||
/** 팝업을 여는 설정 버튼 영역. 외부 클릭 닫기에서 제외해 재클릭 시 토글이 정상 동작하게 한다 */
|
||||
anchorRef?: React.RefObject<HTMLElement | null>;
|
||||
}
|
||||
|
||||
const SettingsPanel: React.FC<SettingsPanelProps> = ({
|
||||
variant,
|
||||
onClose,
|
||||
onNavigate,
|
||||
activeItem,
|
||||
userInfo,
|
||||
credits,
|
||||
isGuest,
|
||||
isLoggingOut,
|
||||
onLogout,
|
||||
onLoginClick,
|
||||
anchorRef,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const panelRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
const target = e.target as Node;
|
||||
if (anchorRef?.current?.contains(target)) return;
|
||||
if (panelRef.current && !panelRef.current.contains(target)) {
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
const handleEscape = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') onClose();
|
||||
};
|
||||
document.addEventListener('mousedown', handleClickOutside);
|
||||
document.addEventListener('keydown', handleEscape);
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', handleClickOutside);
|
||||
document.removeEventListener('keydown', handleEscape);
|
||||
};
|
||||
}, [onClose, anchorRef]);
|
||||
|
||||
return (
|
||||
<div ref={panelRef} className={`settings-panel settings-panel--${variant}`}>
|
||||
{/* 1) 프로필 — 패널 헤더 역할 */}
|
||||
{!isGuest && (
|
||||
<>
|
||||
<div className="profile-section settings-panel-profile">
|
||||
{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>
|
||||
)}
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="profile-name">{userInfo?.nickname || t('sidebar.defaultUser')}</p>
|
||||
{credits !== null && credits !== undefined && (
|
||||
<p className="profile-credits">{t('sidebar.credits', { count: credits })}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 2) 메뉴 그룹 — 대시보드 */}
|
||||
<button
|
||||
className={`settings-panel-item ${activeItem === NAV.DASHBOARD ? 'active' : ''}`}
|
||||
onClick={() => {
|
||||
onNavigate(NAV.DASHBOARD);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<rect x="3" y="3" width="7" height="9" /><rect x="14" y="3" width="7" height="5" />
|
||||
<rect x="14" y="12" width="7" height="9" /><rect x="3" y="16" width="7" height="5" />
|
||||
</svg>
|
||||
<span>{t('sidebar.dashboard')}</span>
|
||||
</button>
|
||||
|
||||
<div className="settings-panel-divider" />
|
||||
|
||||
{/* 3) 하단 그룹 — 언어 전환 / 로그아웃(로그인) / 고객의견 */}
|
||||
<div className="settings-panel-language">
|
||||
<LanguageSwitch isCollapsed={false} />
|
||||
</div>
|
||||
|
||||
{isGuest ? (
|
||||
<button className="settings-panel-item" onClick={onLoginClick}>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" /><polyline points="10 17 15 12 10 7" /><line x1="15" y1="12" x2="3" y2="12" />
|
||||
</svg>
|
||||
<span>{t('sidebar.login')}</span>
|
||||
</button>
|
||||
) : (
|
||||
<button className="settings-panel-item" onClick={onLogout} disabled={isLoggingOut}>
|
||||
<svg width="18" height="18" 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>
|
||||
<span>{isLoggingOut ? t('sidebar.loggingOut') : t('sidebar.logout')}</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<a
|
||||
href="https://forms.gle/4a8mGebBYtdesvby9"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="settings-panel-item"
|
||||
title={t('sidebar.inquiry')}
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
|
||||
</svg>
|
||||
<span>{t('sidebar.inquiry')}</span>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsPanel;
|
||||
+62
-181
@@ -1,32 +1,30 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { UserMeResponse } from '../types/api';
|
||||
import { logout } from '../utils/api';
|
||||
import LanguageSwitch from './LanguageSwitch';
|
||||
import { NAV_ITEMS, SETTINGS_ID } from './navItems';
|
||||
const TOP_NAV_ITEMS = NAV_ITEMS.filter(item => item.id !== SETTINGS_ID);
|
||||
const SETTINGS_NAV_ITEM = NAV_ITEMS.find(item => item.id === SETTINGS_ID)!;
|
||||
import SettingsPanel from './SettingsPanel';
|
||||
|
||||
interface SidebarItemProps {
|
||||
icon: React.ReactNode;
|
||||
label: string;
|
||||
isActive?: boolean;
|
||||
isCollapsed: boolean;
|
||||
isDisabled?: boolean;
|
||||
onClick?: () => void;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
const SidebarItem: React.FC<SidebarItemProps> = ({ icon, label, isActive, isCollapsed, isDisabled, onClick, id }) => {
|
||||
const SidebarItem: React.FC<SidebarItemProps> = ({ icon, label, isActive, onClick }) => {
|
||||
return (
|
||||
<div
|
||||
id={id}
|
||||
onClick={isDisabled ? undefined : onClick}
|
||||
className={`sidebar-item ${isActive ? 'active' : ''} ${isCollapsed ? 'collapsed' : ''} ${isDisabled ? 'disabled' : ''}`}
|
||||
title={isCollapsed ? label : ""}
|
||||
onClick={onClick}
|
||||
className={`sidebar-item ${isActive ? 'active' : ''}`}
|
||||
>
|
||||
<div className="sidebar-item-icon">
|
||||
{icon}
|
||||
</div>
|
||||
{!isCollapsed && <span className="sidebar-item-label">{label}</span>}
|
||||
<span className="sidebar-item-label">{label}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -34,22 +32,20 @@ const SidebarItem: React.FC<SidebarItemProps> = ({ icon, label, isActive, isColl
|
||||
interface SidebarProps {
|
||||
activeItem: string;
|
||||
onNavigate: (id: string) => void;
|
||||
onHome?: () => void;
|
||||
onLogoClick?: () => void;
|
||||
userInfo?: UserMeResponse | null;
|
||||
onLogout?: () => void;
|
||||
credits?: number | null;
|
||||
tutorialAvailable?: boolean;
|
||||
tutorialEnabled?: boolean;
|
||||
onToggleTutorial?: () => void;
|
||||
isGuest: boolean;
|
||||
onLoginClick: () => void;
|
||||
}
|
||||
|
||||
const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome, userInfo, onLogout, credits, tutorialAvailable, tutorialEnabled, onToggleTutorial }) => {
|
||||
const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onLogoClick, userInfo, onLogout, credits, isGuest, onLoginClick }) => {
|
||||
const { t } = useTranslation();
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
const [isMobileOpen, setIsMobileOpen] = useState(false);
|
||||
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const settingsAnchorRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// 로그아웃 처리
|
||||
const handleLogout = async () => {
|
||||
if (isLoggingOut) return;
|
||||
setIsLoggingOut(true);
|
||||
@@ -58,184 +54,69 @@ const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome, userI
|
||||
onLogout?.();
|
||||
} catch (error) {
|
||||
console.error('Logout failed:', error);
|
||||
// 에러가 나도 로컬 토큰은 이미 삭제됨, 홈으로 이동
|
||||
onLogout?.();
|
||||
} finally {
|
||||
setIsLoggingOut(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
if (window.innerWidth < 768) {
|
||||
setIsMobileOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
handleResize();
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
const handleNavigate = (id: string) => {
|
||||
onNavigate(id);
|
||||
if (window.innerWidth < 768) {
|
||||
setIsMobileOpen(false);
|
||||
const handleItemClick = (id: string) => {
|
||||
if (id === SETTINGS_ID) {
|
||||
setSettingsOpen(v => !v);
|
||||
return;
|
||||
}
|
||||
onNavigate(id);
|
||||
};
|
||||
|
||||
const menuItems = [
|
||||
{ id: '대시보드', label: t('sidebar.dashboard'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/></svg> },
|
||||
{ id: '새 프로젝트 만들기', label: t('sidebar.newProject'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> },
|
||||
{ id: 'ADO2 콘텐츠', label: t('sidebar.ado2Contents'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg> },
|
||||
{ id: '내 콘텐츠', label: t('sidebar.myContents'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg> },
|
||||
{ id: '콘텐츠 캘린더', label: t('contentCalendar.title'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg> },
|
||||
{ id: '내 정보', label: t('sidebar.myInfo'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><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> },
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Mobile Menu Button */}
|
||||
<button
|
||||
onClick={() => setIsMobileOpen(true)}
|
||||
className="mobile-menu-btn"
|
||||
>
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="18" x2="21" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{/* Mobile Overlay */}
|
||||
{isMobileOpen && (
|
||||
<div
|
||||
className="mobile-overlay"
|
||||
onClick={() => setIsMobileOpen(false)}
|
||||
<div className="sidebar expanded">
|
||||
<div className="sidebar-header">
|
||||
<img
|
||||
onClick={onLogoClick}
|
||||
src="/assets/images/ado2-sidebar-logo.svg"
|
||||
alt="ADO2"
|
||||
className="sidebar-logo"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Sidebar */}
|
||||
<div className={`sidebar ${isCollapsed ? 'collapsed' : 'expanded'} ${isMobileOpen ? 'mobile-open' : 'mobile-closed'}`}>
|
||||
<div className={`sidebar-header ${isCollapsed ? 'collapsed' : ''}`}>
|
||||
{!isCollapsed && (
|
||||
<img
|
||||
onClick={onHome}
|
||||
src="/assets/images/ado2-sidebar-logo.svg"
|
||||
alt="ADO2"
|
||||
className="sidebar-logo"
|
||||
<div className="sidebar-menu no-scrollbar">
|
||||
{TOP_NAV_ITEMS.map(item => (
|
||||
<SidebarItem
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
label={t(item.labelKey)}
|
||||
isActive={activeItem === item.id}
|
||||
onClick={() => handleItemClick(item.id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="sidebar-footer">
|
||||
<div className="sidebar-settings-anchor" ref={settingsAnchorRef}>
|
||||
<SidebarItem
|
||||
icon={SETTINGS_NAV_ITEM.icon}
|
||||
label={t(SETTINGS_NAV_ITEM.labelKey)}
|
||||
isActive={settingsOpen}
|
||||
onClick={() => handleItemClick(SETTINGS_NAV_ITEM.id)}
|
||||
/>
|
||||
{settingsOpen && (
|
||||
<SettingsPanel
|
||||
variant="sidebar"
|
||||
onClose={() => setSettingsOpen(false)}
|
||||
onNavigate={onNavigate}
|
||||
activeItem={activeItem}
|
||||
userInfo={userInfo}
|
||||
credits={credits}
|
||||
isGuest={isGuest}
|
||||
isLoggingOut={isLoggingOut}
|
||||
onLogout={handleLogout}
|
||||
onLoginClick={onLoginClick}
|
||||
anchorRef={settingsAnchorRef}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
onClick={() => {
|
||||
if (window.innerWidth < 768) {
|
||||
setIsMobileOpen(false);
|
||||
} else {
|
||||
setIsCollapsed(!isCollapsed);
|
||||
}
|
||||
}}
|
||||
className="p-1.5 text-gray-400 hover:text-white"
|
||||
>
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="18" x2="21" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="sidebar-menu no-scrollbar">
|
||||
{menuItems.map(item => (
|
||||
<SidebarItem
|
||||
key={item.id}
|
||||
id={
|
||||
item.id === '내 정보'
|
||||
? 'sidebar-my-info'
|
||||
: item.id === 'ADO2 콘텐츠'
|
||||
? 'sidebar-ado2-contents'
|
||||
: undefined
|
||||
}
|
||||
icon={item.icon}
|
||||
label={item.label}
|
||||
isCollapsed={isCollapsed}
|
||||
isActive={activeItem === item.id}
|
||||
isDisabled={item.disabled}
|
||||
onClick={() => handleNavigate(item.id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="sidebar-footer">
|
||||
{/* 모바일 전용 튜토리얼 토글 */}
|
||||
{tutorialAvailable && (
|
||||
<button
|
||||
className={`sidebar-tutorial-btn ${tutorialEnabled ? 'active' : ''}`}
|
||||
onClick={() => onToggleTutorial?.()}
|
||||
title={tutorialEnabled ? t('sidebar.tutorialOff') : t('sidebar.tutorialOn')}
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<path d="M12 8v4l3 3"/>
|
||||
</svg>
|
||||
<span className="sidebar-tutorial-label">{t('sidebar.tutorial')}</span>
|
||||
<span className={`sidebar-tutorial-badge ${tutorialEnabled ? 'on' : 'off'}`}>
|
||||
{tutorialEnabled ? 'ON' : 'OFF'}
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<div className="sidebar-language-switch">
|
||||
<LanguageSwitch isCollapsed={isCollapsed} />
|
||||
</div>
|
||||
|
||||
<div className={`profile-section ${isCollapsed ? 'collapsed' : ''}`}>
|
||||
{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">{userInfo?.nickname || t('sidebar.defaultUser')}</p>
|
||||
{credits !== null && credits !== undefined && (
|
||||
<p className="profile-credits">{t('sidebar.credits', { count: credits })}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="sidebar-footer-actions">
|
||||
<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">{isLoggingOut ? t('sidebar.loggingOut') : t('sidebar.logout')}</span>}
|
||||
</button>
|
||||
<a
|
||||
href="https://forms.gle/4a8mGebBYtdesvby9"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={`sidebar-inquiry-btn ${isCollapsed ? 'collapsed' : ''}`}
|
||||
title={t('sidebar.inquiry')}
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
|
||||
</svg>
|
||||
{!isCollapsed && <span>{t('sidebar.inquiry')}</span>}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import React from 'react';
|
||||
|
||||
export const NAV = {
|
||||
HOME: 'ADO2 콘텐츠',
|
||||
NEW: '새 프로젝트 만들기',
|
||||
MY: '내 정보',
|
||||
DASHBOARD: '대시보드',
|
||||
} as const;
|
||||
|
||||
export const SETTINGS_ID = '__settings__';
|
||||
|
||||
export const GATED_ITEMS: string[] = [NAV.NEW, NAV.MY, NAV.DASHBOARD];
|
||||
|
||||
export type MyInfoTab = 'contents' | 'calendar' | 'payment' | 'business';
|
||||
|
||||
export interface NavItemDef {
|
||||
id: string;
|
||||
labelKey: string;
|
||||
icon: React.ReactNode;
|
||||
}
|
||||
|
||||
export const NAV_ITEMS: NavItemDef[] = [
|
||||
{
|
||||
id: NAV.HOME,
|
||||
labelKey: 'sidebar.ado2Contents',
|
||||
icon: (
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
||||
<polyline points="9 22 9 12 15 12 15 22" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: NAV.NEW,
|
||||
labelKey: 'sidebar.newProject',
|
||||
icon: (
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<line x1="12" y1="5" x2="12" y2="19" />
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: NAV.MY,
|
||||
labelKey: 'sidebar.myInfo',
|
||||
icon: (
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<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>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SETTINGS_ID,
|
||||
labelKey: 'sidebar.settings',
|
||||
icon: (
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
/** 구 activeItem(6메뉴 체제) → 새 4메뉴 체계 매핑 + 비로그인 게이트 강등을 함께 처리한다. */
|
||||
export function sanitizeActiveItem(
|
||||
raw: string | null,
|
||||
isGuest: boolean
|
||||
): { item: string; myInfoTab?: MyInfoTab } {
|
||||
const gate = (result: { item: string; myInfoTab?: MyInfoTab }) =>
|
||||
isGuest && GATED_ITEMS.includes(result.item) ? { item: NAV.HOME } : result;
|
||||
|
||||
switch (raw) {
|
||||
case '대시보드':
|
||||
return gate({ item: NAV.DASHBOARD });
|
||||
case '내 콘텐츠':
|
||||
return gate({ item: NAV.MY, myInfoTab: 'contents' });
|
||||
case '콘텐츠 캘린더':
|
||||
return gate({ item: NAV.MY, myInfoTab: 'calendar' });
|
||||
case '비즈니스 설정':
|
||||
return gate({ item: NAV.MY, myInfoTab: 'business' });
|
||||
case NAV.MY:
|
||||
return gate({ item: NAV.MY });
|
||||
case NAV.NEW:
|
||||
return gate({ item: NAV.NEW });
|
||||
case NAV.DASHBOARD:
|
||||
return gate({ item: NAV.DASHBOARD });
|
||||
case NAV.HOME:
|
||||
return { item: NAV.HOME };
|
||||
default:
|
||||
return { item: NAV.HOME };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user