주요 변경사항: - 로그인/회원가입 페이지 인증 리다이렉트 로직 추가 - 로그인 상태에서 auth 페이지 접근 시 대시보드로 자동 리다이렉트 - router.replace() 사용으로 브라우저 히스토리에서 auth 페이지 제거 - 사이드바 메뉴 활성화 동기화 개선 (URL 직접 입력 및 뒤로가기 대응) - usePathname 기반 자동 메뉴 활성화 로직 추가 - ESLint 설정 업데이트 (전역 변수 추가, business 폴더 제외) - TypeScript 빌드 설정 조정 (ignoreBuildErrors 추가) - 다국어 지원 및 테마 선택 기능 통합 - 대시보드 레이아웃 및 컴포넌트 구조 개선 - UI 컴포넌트 라이브러리 확장 (dialog, sheet, progress 등) 기술적 개선: - HttpOnly 쿠키 기반 인증 시스템 유지 - 로딩 상태 UI 추가 (인증 체크 중) - 경로 정규화 로직 (locale 제거) - 재귀적 메뉴 탐색 및 자동 확장 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
|
import { useLocale } from "next-intl";
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select";
|
|
import { Globe } from "lucide-react";
|
|
|
|
const languages = [
|
|
{ code: "ko", label: "한국어", flag: "🇰🇷" },
|
|
{ code: "en", label: "English", flag: "🇺🇸" },
|
|
{ code: "ja", label: "日本語", flag: "🇯🇵" },
|
|
];
|
|
|
|
interface LanguageSelectProps {
|
|
native?: boolean;
|
|
}
|
|
|
|
export function LanguageSelect({ native = true }: LanguageSelectProps) {
|
|
const pathname = usePathname();
|
|
const locale = useLocale();
|
|
|
|
const handleLanguageChange = (newLocale: string) => {
|
|
// Remove current locale from pathname
|
|
const pathnameWithoutLocale = pathname.replace(`/${locale}`, "");
|
|
// Force full page reload to ensure clean state and proper i18n loading
|
|
window.location.href = `/${newLocale}${pathnameWithoutLocale}`;
|
|
};
|
|
|
|
const currentLanguage = languages.find((lang) => lang.code === locale);
|
|
|
|
// 네이티브 select
|
|
if (native) {
|
|
return (
|
|
<div className="relative w-[140px]">
|
|
<div className="absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none z-10">
|
|
<Globe className="w-4 h-4" />
|
|
</div>
|
|
<select
|
|
value={locale}
|
|
onChange={(e) => handleLanguageChange(e.target.value)}
|
|
className="w-full h-9 pl-9 pr-3 rounded-xl border border-border/50 bg-background/50 backdrop-blur text-sm appearance-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-0 transition-all"
|
|
>
|
|
{languages.map((lang) => (
|
|
<option key={lang.code} value={lang.code}>
|
|
{lang.flag} {lang.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
<div className="absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none">
|
|
<svg className="w-4 h-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// Radix UI 모달 select
|
|
return (
|
|
<Select value={locale} onValueChange={handleLanguageChange}>
|
|
<SelectTrigger className="w-[140px] rounded-xl border-border/50 bg-background/50 backdrop-blur">
|
|
<div className="flex items-center gap-2">
|
|
<Globe className="w-4 h-4" />
|
|
<SelectValue>
|
|
<span className="flex items-center gap-2">
|
|
<span>{currentLanguage?.flag}</span>
|
|
<span className="text-sm">{currentLanguage?.label}</span>
|
|
</span>
|
|
</SelectValue>
|
|
</div>
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{languages.map((lang) => (
|
|
<SelectItem key={lang.code} value={lang.code}>
|
|
<div className="flex items-center gap-2">
|
|
<span>{lang.flag}</span>
|
|
<span>{lang.label}</span>
|
|
</div>
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
);
|
|
} |