[feat] negodata/front: 프론트 초기 구축 (Vite+React, orval API 클라이언트, 견적/상품/협력사 페이지)
- 라우팅 react-router v7, 서버상태 TanStack Query - orval 자동 생성 API 클라이언트(src/api/generated) - 견적/상품/협력사/견적설정 페이지, shadcn UI, 토큰(tokens.css) - 실행: 루트 docker compose (front :3001), README 그에 맞게 정리 - AI Studio 스캐폴드 잔재 제거(metadata.json, 중복 DESIGN_TOKENS.md), 타이틀 NegoData, vite.config 죽은코드 제거 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a6731dcb07
commit
87524bf6e8
288 files changed
+26363
-1
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import {Outlet, useNavigate, useLocation} from 'react-router';
|
||||
import Layout from './Layout';
|
||||
import {PageType} from '@/types';
|
||||
import {useAuth} from '@/features/auth/useAuth';
|
||||
import {showToast} from '@/lib/notify';
|
||||
|
||||
const PAGE_TO_PATH: Record<PageType, string> = {
|
||||
PRODUCTS: '/products',
|
||||
PARTNERS: '/partners',
|
||||
QUOTATION: '/quotation',
|
||||
CARDS: '/cards',
|
||||
};
|
||||
|
||||
export default function AuthenticatedLayout() {
|
||||
const {user, logout} = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const {pathname} = useLocation();
|
||||
|
||||
const currentPage =
|
||||
(Object.keys(PAGE_TO_PATH) as PageType[]).find((page) =>
|
||||
pathname.startsWith(PAGE_TO_PATH[page]),
|
||||
) ?? 'PRODUCTS';
|
||||
|
||||
const setPage = (page: PageType) => {
|
||||
navigate(PAGE_TO_PATH[page]);
|
||||
};
|
||||
|
||||
const handleLogout = async () => {
|
||||
// logout()이 상태를 비우므로 메시지에 쓸 유저 정보를 미리 잡아둔다.
|
||||
const who = `${user?.company ? user.company + ' ' : ''}${user?.name ?? ''}`.trim();
|
||||
// 로그아웃 완료(상태 초기화) 후 이동 — 안 그러면 /login 가드가 다시 튕겨낼 수 있다.
|
||||
await logout();
|
||||
showToast(who ? `${who}님, 로그아웃되었습니다.` : '로그아웃되었습니다.', 'info');
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
return (
|
||||
<Layout
|
||||
currentPage={currentPage}
|
||||
setPage={setPage}
|
||||
onLogout={handleLogout}
|
||||
>
|
||||
<Outlet />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
import { useState, type ReactNode, type ElementType } from 'react';
|
||||
import { PageType } from '@/types';
|
||||
import { useAuth } from '@/features/auth/useAuth';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import {
|
||||
Briefcase,
|
||||
Users,
|
||||
FileSpreadsheet,
|
||||
Layers,
|
||||
LogOut,
|
||||
Sun,
|
||||
Moon,
|
||||
Building,
|
||||
ChevronRight,
|
||||
} from 'lucide-react';
|
||||
|
||||
interface LayoutProps {
|
||||
children: ReactNode;
|
||||
currentPage: PageType;
|
||||
setPage: (page: PageType) => void;
|
||||
onLogout: () => void;
|
||||
}
|
||||
|
||||
type SidebarUser = ReturnType<typeof useAuth>['user'];
|
||||
|
||||
const menuItems = [
|
||||
{ type: 'PRODUCTS' as PageType, label: '상품관리', icon: Briefcase, id: 'sidebar-products' },
|
||||
{ type: 'PARTNERS' as PageType, label: '협력사관리', icon: Users, id: 'sidebar-partners' },
|
||||
{ type: 'QUOTATION' as PageType, label: '견적관리', icon: FileSpreadsheet, id: 'sidebar-quotation' },
|
||||
{ type: 'CARDS' as PageType, label: '협상카드관리', icon: Layers, id: 'sidebar-cards' },
|
||||
];
|
||||
|
||||
const pageLabelMap: Record<PageType, string> = {
|
||||
PRODUCTS: '상품관리',
|
||||
PARTNERS: '협력사관리',
|
||||
QUOTATION: '견적관리',
|
||||
CARDS: '협상카드관리',
|
||||
};
|
||||
|
||||
export default function Layout({ children, currentPage, setPage, onLogout }: LayoutProps) {
|
||||
const { user } = useAuth();
|
||||
// 기준일시(오늘) — 로컬 타임존 기준 YYYY-MM-DD
|
||||
const today = new Date().toLocaleDateString('sv-SE');
|
||||
|
||||
const [isDark, setIsDark] = useState(false);
|
||||
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
|
||||
|
||||
const toggleDarkMode = () => {
|
||||
setIsDark(!isDark);
|
||||
if (!isDark) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground flex">
|
||||
{/* 토스트는 sonner <Toaster/>(main.tsx)가 전역으로 처리한다 */}
|
||||
|
||||
{/* Main Sidebar */}
|
||||
<aside
|
||||
className={cn(
|
||||
'bg-card border-r border-border flex flex-col justify-between transition-all duration-300 z-30 fixed h-full',
|
||||
isSidebarOpen ? 'w-60' : 'w-16'
|
||||
)}
|
||||
>
|
||||
<div>
|
||||
{/* Sidebar Brand Header */}
|
||||
<div className="h-14 flex items-center justify-between px-4 border-b border-border">
|
||||
{isSidebarOpen ? (
|
||||
<>
|
||||
<Typography as="div" variant="body" className="text-primary font-extrabold tracking-tighter">
|
||||
NegoData
|
||||
</Typography>
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => setIsSidebarOpen(false)}
|
||||
className="p-1 h-auto rounded text-muted-foreground"
|
||||
title="메뉴 접기"
|
||||
>
|
||||
<ChevronRight size={14} className="rotate-180 size-3.5" />
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => setIsSidebarOpen(true)}
|
||||
className="mx-auto p-1.5 h-auto rounded bg-muted/65 text-muted-foreground"
|
||||
title="메뉴 열기"
|
||||
>
|
||||
<ChevronRight size={14} className="size-3.5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Nav User Profile Card */}
|
||||
{isSidebarOpen && <SidebarProfileCard user={user} />}
|
||||
|
||||
{/* Nav Items */}
|
||||
<nav className="mt-2 px-3 space-y-1">
|
||||
{menuItems.map((item) => (
|
||||
<NavItem
|
||||
key={item.type}
|
||||
item={item}
|
||||
isActive={currentPage === item.type}
|
||||
isOpen={isSidebarOpen}
|
||||
onClick={() => setPage(item.type)}
|
||||
/>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
{/* Sidebar Footer Controls */}
|
||||
<div className="p-2 border-t border-border space-y-1">
|
||||
{/* Theme switcher */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={toggleDarkMode}
|
||||
className="w-full justify-start gap-3 py-1.5 px-3 h-auto rounded text-[11px] font-semibold text-muted-foreground"
|
||||
>
|
||||
{isDark ? <Sun size={14} className="text-warning size-3.5" /> : <Moon size={14} className="size-3.5" />}
|
||||
{isSidebarOpen && <span>{isDark ? '라이트 모드' : '다크 모드'}</span>}
|
||||
</Button>
|
||||
|
||||
{/* Logout btn */}
|
||||
<Button
|
||||
id="header-logout-button"
|
||||
variant="ghost"
|
||||
onClick={onLogout}
|
||||
className="w-full justify-start gap-3 py-1.5 px-3 h-auto rounded text-[11px] font-semibold text-destructive hover:bg-destructive/10 hover:text-destructive"
|
||||
>
|
||||
<LogOut size={14} className="size-3.5" />
|
||||
{isSidebarOpen && <span>시스템 로그아웃</span>}
|
||||
</Button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Main Container Wrapper */}
|
||||
<div
|
||||
className="flex-1 flex flex-col transition-all duration-300"
|
||||
style={{ paddingLeft: isSidebarOpen ? '15rem' : '4rem' }}
|
||||
>
|
||||
{/* Global Header */}
|
||||
<header className="h-14 bg-card border-b border-border flex items-center justify-between px-8 sticky top-0 z-20 shadow-xs backdrop-blur-md bg-opacity-95">
|
||||
<div className="flex items-center gap-4">
|
||||
<Typography as="div" variant="small" className="font-bold">
|
||||
{pageLabelMap[currentPage]}
|
||||
</Typography>
|
||||
<Badge variant="outline">B2B 시스템</Badge>
|
||||
</div>
|
||||
|
||||
<HeaderMeta user={user} today={today} />
|
||||
</header>
|
||||
|
||||
{/* Content Body Area */}
|
||||
<main className="flex-1 p-8 overflow-y-auto bg-background">
|
||||
<div className="max-w-7xl mx-auto space-y-6">{children}</div>
|
||||
</main>
|
||||
|
||||
{/* Compact Admin footer info */}
|
||||
<footer className="h-10 border-t border-border/60 bg-card flex items-center justify-between px-8">
|
||||
<Typography variant="mono">Copyright © O2O Inc. All rights reserved</Typography>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 라벨:값 한 줄 (사이드바 프로필 카드용) */
|
||||
function InfoRow({
|
||||
label,
|
||||
value,
|
||||
valueClassName,
|
||||
title,
|
||||
}: {
|
||||
label: string;
|
||||
value?: string;
|
||||
valueClassName?: string;
|
||||
title?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex justify-between items-center">
|
||||
<Typography variant="caption">{label}</Typography>
|
||||
<Typography variant="caption" title={title} className={cn('font-bold text-foreground', valueClassName)}>
|
||||
{value}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 사이드바 사용자 프로필 카드 */
|
||||
function SidebarProfileCard({ user }: { user: SidebarUser }) {
|
||||
return (
|
||||
<div className="p-3.5 mx-4 my-4 rounded-lg bg-muted/80 border border-border flex flex-col gap-1.5 shadow-2xs">
|
||||
<div className="flex items-center gap-2 pb-1.5 border-b border-border/50">
|
||||
<Building size={13} className="text-primary" />
|
||||
<Typography variant="caption" className="font-bold text-foreground truncate max-w-[140px]" title="소속 고객사">
|
||||
{user?.company}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<InfoRow label="사용자명:" value={user?.name} />
|
||||
<InfoRow label="로그인 ID:" value={user?.loginId} valueClassName="font-mono" />
|
||||
<InfoRow
|
||||
label="이메일:"
|
||||
value={user?.email}
|
||||
title={user?.email}
|
||||
valueClassName="font-mono text-foreground/90 truncate max-w-[80px]"
|
||||
/>
|
||||
<InfoRow label="연락처:" value={user?.contact} valueClassName="font-mono" />
|
||||
<div className="flex justify-between items-center pt-1 border-t border-border/20">
|
||||
<Typography variant="caption">권한등급:</Typography>
|
||||
<Badge variant="secondary" className="text-[10px]">{user?.role}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 사이드바 메뉴 항목 */
|
||||
function NavItem({
|
||||
item,
|
||||
isActive,
|
||||
isOpen,
|
||||
onClick,
|
||||
}: {
|
||||
item: { type: PageType; label: string; icon: ElementType; id: string };
|
||||
isActive: boolean;
|
||||
isOpen: boolean;
|
||||
onClick: () => void;
|
||||
}) {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<Button
|
||||
id={item.id}
|
||||
variant="ghost"
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'w-full justify-start gap-3 py-2 px-3 h-auto rounded text-xs font-semibold tracking-tight',
|
||||
isActive
|
||||
? 'bg-secondary text-foreground border-l-2 border-primary pl-2 hover:bg-secondary hover:text-foreground'
|
||||
: 'text-muted-foreground hover:bg-muted/80'
|
||||
)}
|
||||
>
|
||||
<Icon size={16} className={cn('size-4', isActive ? 'text-foreground' : 'text-muted-foreground/85')} />
|
||||
{isOpen && <span className="truncate">{item.label}</span>}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
/** 글로벌 헤더 우측 메타 정보 */
|
||||
function HeaderMeta({ user, today }: { user: SidebarUser; today: string }) {
|
||||
return (
|
||||
<div className="flex items-center gap-4">
|
||||
<Typography as="div" variant="caption" className="hidden md:block">
|
||||
기준일시: <span className="font-semibold text-foreground">{today}</span>
|
||||
</Typography>
|
||||
<div className="h-4 w-px bg-border hidden md:block" />
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="inline-block h-2 w-2 rounded-full bg-success animate-pulse" />
|
||||
<Typography as="span" variant="caption">회사:</Typography>
|
||||
<Typography
|
||||
as="span"
|
||||
variant="caption"
|
||||
id="header-company-name"
|
||||
className="font-bold text-foreground underline decoration-1"
|
||||
>
|
||||
{user?.company}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="h-4 w-px bg-border" />
|
||||
<div className="flex items-center gap-2">
|
||||
<Typography as="span" variant="caption">관리자:</Typography>
|
||||
<Typography as="span" variant="caption" className="font-semibold text-foreground">
|
||||
{user?.name} ({user?.loginId})
|
||||
</Typography>
|
||||
<Badge variant="secondary" className="text-[9px]">{user?.role}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
// 라우트 페이지 최상위 래퍼. 페이지 간 세로 리듬(섹션 간격)을 단일 출처로 통일한다.
|
||||
// 페이지마다 <div className="space-y-6">를 복붙하지 말고 이걸 쓴다.
|
||||
export function PageContainer({
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return <div className={cn('space-y-6', className)}>{children}</div>;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { ComponentProps, ReactNode } from 'react';
|
||||
import { Search } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
// 페이지 상단의 "검색/액션 바". card 외피 + 좌측(검색·필터) / 우측(액션 버튼) 레이아웃.
|
||||
// products/partners/quotation에서 동일하게 반복되던 구조를 단일 출처로 통일.
|
||||
export function PageToolbar({
|
||||
children,
|
||||
actions,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode; // 좌측: 검색 + 필터
|
||||
actions?: ReactNode; // 우측: 액션 버튼들
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col md:flex-row md:items-center justify-between gap-4 p-4 rounded-lg border border-border bg-card',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-1 flex-col sm:flex-row gap-3">{children}</div>
|
||||
{actions && <div className="flex items-center gap-2">{actions}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 돋보기 아이콘 + 검색 input. 매 페이지 복붙하던 동일 마크업을 컴포넌트화.
|
||||
export function SearchInput({ className, ...props }: ComponentProps<'input'>) {
|
||||
return (
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-3 top-2.5 h-4 w-4 text-muted-foreground" />
|
||||
<input
|
||||
type="text"
|
||||
className={cn(
|
||||
'w-full pl-9 pr-3 py-2 text-xs bg-background border border-border rounded focus:outline-none focus:border-foreground/40 text-foreground transition-colors font-mono',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user