'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { usePathname } from 'next/navigation'; import { ArrowLeft, ChevronsUpDown, CircleAlert, Settings, User, } from 'lucide-react'; import { Sidebar as SidebarRoot, SidebarContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarGroup, SidebarGroupContent, useSidebar, } from '@/components/ui/sidebar'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { fetchApi } from '@/lib/utils/client'; import type { StudioSettingsResponse } from '@/types/response/studio/settings'; export default function Sidebar() { const pathname = usePathname(); const { isMobile } = useSidebar(); const [channel, setChannel] = useState|null>(null); const isActive = (href: string) => pathname === href || pathname.startsWith(href + '/'); useEffect(() => { fetchApi('/api/studio/settings') .then(res => { if (res.data) { setChannel(res.data); } }) .catch(() => {}); }, []); const isConnected = channel?.isYouTubeConnected === true; return ( {/* 상단 Studio 라벨 + 돌아가기 버튼 (전체 영역 클릭 가능) */} Studio {/* YouTube 채널 카드 */} {/* 아이콘 (collapse 시 이것만 표시) */}
{channel?.thumbnailUrl ? ( {channel.channelName ) : ( )} {/* 미연동 경고 뱃지 */} {channel !== null && !isConnected && ( )}
{/* 텍스트 (collapse 시 hidden) */}
{isConnected ? (channel?.channelName ?? '채널 이름') : '채널 미연동'} {isConnected ? (channel?.handle ?? '') : '채널을 연결해 주세요'}
{isConnected ? ( <> {channel?.channelName} 채널 정보 보기 ) : ( <> YouTube 채널이 연동되지 않았습니다 YouTube 연동하기 )}
{/* 채널 설정 */} 채널 설정
); }