[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,111 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, BookOpen } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { useCards } from '@/features/cards/hooks/useCards';
|
||||
import { useCardFilters } from '@/features/cards/hooks/useCardFilters';
|
||||
import { CardTable } from '@/features/cards/components/CardTable';
|
||||
import { CardFormModal } from '@/features/cards/components/CardFormModal';
|
||||
import type { CardTab, NegotiationCard } from '@/features/cards/types';
|
||||
|
||||
export default function CardsPage() {
|
||||
const { cards, createCard, updateCard, deleteCard } = useCards();
|
||||
const { search, setSearch, activeTab, setActiveTab, filtered, counts } = useCardFilters(cards);
|
||||
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [formMode, setFormMode] = useState<'create' | 'edit'>('create');
|
||||
const [editing, setEditing] = useState<NegotiationCard | null>(null);
|
||||
|
||||
const openCreate = () => {
|
||||
setFormMode('create');
|
||||
setEditing(null);
|
||||
setIsFormOpen(true);
|
||||
};
|
||||
const openEdit = (card: NegotiationCard) => {
|
||||
setFormMode('edit');
|
||||
setEditing(card);
|
||||
setIsFormOpen(true);
|
||||
};
|
||||
|
||||
const handleDeleteCard = (id: string, cardName: string) => {
|
||||
if (confirm(`[${cardName}]을 삭제하시겠습니까?`)) {
|
||||
deleteCard(id);
|
||||
showToast('삭제되었습니다.', 'info');
|
||||
}
|
||||
};
|
||||
|
||||
const tabs: { id: CardTab; label: string; count: number }[] = [
|
||||
{ id: 'ALL', label: '전체', count: counts.all },
|
||||
{ id: 'CARD', label: '협상카드', count: counts.card },
|
||||
{ id: 'WILD', label: '와일드카드', count: counts.wild },
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
{/* Upper Information Banner */}
|
||||
<div className="p-4 rounded-lg border border-border bg-card flex flex-col sm:flex-row items-center justify-between gap-4 font-mono text-xs">
|
||||
<div className="flex items-center gap-3">
|
||||
<BookOpen className="text-muted-foreground" size={20} />
|
||||
<div>
|
||||
<Typography variant="h3" className="text-xs">협상카드 및 와일드카드 관리</Typography>
|
||||
<Typography variant="muted" className="text-[10px] mt-0.5">
|
||||
협상 대화 상대로 전달할 협상카드와 와일드카드를 설정하고 관리합니다. (등록 시 구분 지정 가능)
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
id="card-register-btn"
|
||||
onClick={openCreate}
|
||||
className="flex items-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground text-xs font-bold rounded hover:opacity-95 cursor-pointer transition-colors whitespace-nowrap"
|
||||
>
|
||||
<Plus size={15} />
|
||||
<span>신규 카드 등록</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Primary Navigation Tab */}
|
||||
<div className="flex border-b border-border">
|
||||
{tabs.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
id={`card-tab-${tab.id.toLowerCase()}`}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={`py-2 px-6 font-bold text-xs tracking-tight border-b-2 transition-all cursor-pointer ${
|
||||
activeTab === tab.id
|
||||
? 'border-primary text-primary'
|
||||
: 'border-transparent text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{tab.label} ({tab.count})
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Filtering Search Bar */}
|
||||
<SearchInput
|
||||
id="card-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="전체 카드이름, 카드번호, 코드 및 핵심멘트 검색..."
|
||||
/>
|
||||
|
||||
<CardTable data={filtered} onEdit={openEdit} onDelete={handleDeleteCard} />
|
||||
|
||||
{isFormOpen && (
|
||||
<CardFormModal
|
||||
key={`${formMode}-${editing?.id ?? 'new'}`}
|
||||
open
|
||||
mode={formMode}
|
||||
card={editing}
|
||||
activeTab={activeTab}
|
||||
onCreate={createCard}
|
||||
onUpdate={updateCard}
|
||||
onClose={() => setIsFormOpen(false)}
|
||||
/>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
} from '@/components/ui/card';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableHead,
|
||||
TableCell,
|
||||
} from '@/components/ui/table';
|
||||
import { TablePagination } from '@/components/ui/table-pagination';
|
||||
import {
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogClose,
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Drawer,
|
||||
DrawerTrigger,
|
||||
DrawerContent,
|
||||
DrawerHeader,
|
||||
DrawerTitle,
|
||||
DrawerDescription,
|
||||
DrawerFooter,
|
||||
DrawerClose,
|
||||
} from '@/components/ui/drawer';
|
||||
import { Plus, Upload, TrendingDown, Trash2 } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
|
||||
/**
|
||||
* 디자인시스템 쇼케이스 (dev 전용).
|
||||
* 라우터에서 import.meta.env.DEV일 때만 등록되므로 프로덕션 빌드에는 포함되지 않는다.
|
||||
* 토큰/프리미티브의 단일 출처를 눈으로 확인하고 맞추는 곳.
|
||||
*/
|
||||
export default function DevDesignPage() {
|
||||
const [switchOn, setSwitchOn] = useState(true);
|
||||
const [switchOff, setSwitchOff] = useState(false);
|
||||
const [demoPage, setDemoPage] = useState(2);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<div className="mx-auto max-w-4xl px-6 py-12 space-y-12">
|
||||
<header className="space-y-1">
|
||||
<Typography variant="mono">네고시움 디자인시스템 · 개발 전용</Typography>
|
||||
<Typography variant="h1">디자인시스템</Typography>
|
||||
<Typography variant="muted">
|
||||
텍스트·색·컴포넌트의 단일 출처. 페이지에서 직접 클래스 박지 말고 여기 토큰을 쓴다.
|
||||
</Typography>
|
||||
</header>
|
||||
|
||||
<Section title="타이포그래피">
|
||||
<div className="space-y-2">
|
||||
<Typography variant="h1">H1 · 페이지 타이틀</Typography>
|
||||
<Typography variant="h2">H2 · 섹션 타이틀</Typography>
|
||||
<Typography variant="h3">H3 · 카드/모달 타이틀</Typography>
|
||||
<Typography variant="h4">H4 · 서브 타이틀</Typography>
|
||||
<Typography variant="body">Body · 기본 본문 텍스트입니다.</Typography>
|
||||
<Typography variant="small">Small · 작은 본문 텍스트입니다.</Typography>
|
||||
<Typography variant="muted">Muted · 보조 설명 텍스트입니다.</Typography>
|
||||
<Typography variant="label">Label · 폼 라벨</Typography>
|
||||
<br />
|
||||
<Typography variant="mono">Mono · 콘솔/메타 캡션</Typography>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="색상 토큰">
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<Swatch name="background" className="bg-background border border-border" />
|
||||
<Swatch name="card" className="bg-card border border-border" />
|
||||
<Swatch name="muted" className="bg-muted" />
|
||||
<Swatch name="primary" className="bg-primary" />
|
||||
<Swatch name="secondary" className="bg-secondary" />
|
||||
<Swatch name="destructive" className="bg-destructive" />
|
||||
<Swatch name="border" className="bg-border" />
|
||||
<Swatch name="foreground" className="bg-foreground" />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="버튼">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{(['default', 'outline', 'secondary', 'ghost', 'destructive', 'link'] as const).map((v) => (
|
||||
<Button key={v} variant={v}>{v}</Button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2 pt-3">
|
||||
{(['xs', 'sm', 'default', 'lg'] as const).map((s) => (
|
||||
<Button key={s} size={s}>{s}</Button>
|
||||
))}
|
||||
<Button disabled>disabled</Button>
|
||||
</div>
|
||||
{/* 실제 사용 케이스: 아이콘+라벨, 카운트 배지, 위험 액션 */}
|
||||
<div className="flex flex-wrap items-center gap-2 pt-3">
|
||||
<Button><Plus />신규 등록</Button>
|
||||
<Button variant="outline"><Upload />엑셀 업로드</Button>
|
||||
<Button variant="outline">
|
||||
<TrendingDown />최저가 업데이트
|
||||
<Badge variant="destructive">3</Badge>
|
||||
</Button>
|
||||
<Button variant="destructive"><Trash2 />삭제</Button>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="배지">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{(['default', 'secondary', 'destructive', 'outline', 'ghost', 'link'] as const).map((v) => (
|
||||
<Badge key={v} variant={v}>{v}</Badge>
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="입력창">
|
||||
<div className="max-w-sm space-y-3">
|
||||
<Input placeholder="기본 입력" />
|
||||
<Input placeholder="비활성" disabled />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="스위치">
|
||||
<div className="flex items-center gap-6">
|
||||
<label className="flex items-center gap-2">
|
||||
<Switch checked={switchOn} onCheckedChange={setSwitchOn} />
|
||||
<Typography variant="small">{switchOn ? '켜짐' : '꺼짐'}</Typography>
|
||||
</label>
|
||||
<label className="flex items-center gap-2">
|
||||
<Switch checked={switchOff} onCheckedChange={setSwitchOff} />
|
||||
<Typography variant="small">토글</Typography>
|
||||
</label>
|
||||
<label className="flex items-center gap-2 opacity-60">
|
||||
<Switch checked disabled />
|
||||
<Typography variant="small">disabled</Typography>
|
||||
</label>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="카드">
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>카드 타이틀</CardTitle>
|
||||
<CardDescription>shadcn Card 프리미티브. 패딩·보더·그림자 단일 출처.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Typography variant="small">카드 본문 영역입니다.</Typography>
|
||||
</CardContent>
|
||||
<CardFooter className="justify-end gap-2">
|
||||
<Button variant="outline" size="sm">취소</Button>
|
||||
<Button size="sm">확인</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Section>
|
||||
|
||||
<Section title="탭">
|
||||
<Tabs defaultValue="overview" className="max-w-md">
|
||||
<TabsList>
|
||||
<TabsTrigger value="overview">개요</TabsTrigger>
|
||||
<TabsTrigger value="detail">상세</TabsTrigger>
|
||||
<TabsTrigger value="log">로그</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="overview" className="pt-3">
|
||||
<Typography variant="small">개요 탭 내용.</Typography>
|
||||
</TabsContent>
|
||||
<TabsContent value="detail" className="pt-3">
|
||||
<Typography variant="small">상세 탭 내용.</Typography>
|
||||
</TabsContent>
|
||||
<TabsContent value="log" className="pt-3">
|
||||
<Typography variant="small">로그 탭 내용.</Typography>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</Section>
|
||||
|
||||
<Section title="표">
|
||||
<div className="rounded-lg border border-border overflow-hidden">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>상품명</TableHead>
|
||||
<TableHead>코드</TableHead>
|
||||
<TableHead className="text-right">단가</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{[
|
||||
{ name: '배터리 팩', code: 'PROD-BAT-900', price: 1000000 },
|
||||
{ name: '인버터 블록', code: 'PROD-INV-11', price: 3200000 },
|
||||
].map((r) => (
|
||||
<TableRow key={r.code}>
|
||||
<TableCell className="font-medium">{r.name}</TableCell>
|
||||
<TableCell className="font-mono text-muted-foreground">{r.code}</TableCell>
|
||||
<TableCell className="text-right font-mono">₩{r.price.toLocaleString()}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="페이지네이션 푸터">
|
||||
<div className="rounded-lg border border-border overflow-hidden">
|
||||
<div className="p-4 text-center">
|
||||
<Typography variant="small" className="text-muted-foreground">표 하단에 들어가는 목록 페이지네이션</Typography>
|
||||
</div>
|
||||
<TablePagination
|
||||
page={demoPage}
|
||||
totalPages={12}
|
||||
totalCount={58}
|
||||
pageSize={5}
|
||||
onPageChange={setDemoPage}
|
||||
label="검색 결과"
|
||||
unit="건"
|
||||
/>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="모달">
|
||||
<Dialog>
|
||||
<DialogTrigger render={<Button variant="outline">모달 열기</Button>} />
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>모달 타이틀</DialogTitle>
|
||||
<DialogDescription>
|
||||
base-ui Dialog 프리미티브. 페이지마다 fixed inset-0 직접 짜지 말 것.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<DialogClose render={<Button variant="outline">취소</Button>} />
|
||||
<DialogClose render={<Button>확인</Button>} />
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Section>
|
||||
|
||||
<Section title="드로어(사이드 패널)">
|
||||
<Drawer direction="right">
|
||||
<DrawerTrigger asChild><Button variant="outline">드로어 열기</Button></DrawerTrigger>
|
||||
<DrawerContent>
|
||||
<DrawerHeader>
|
||||
<DrawerTitle>드로어 타이틀</DrawerTitle>
|
||||
<DrawerDescription>
|
||||
vaul 기반 사이드 드로어. products의 등록/수정 패널이 이걸로 통일돼야 함.
|
||||
</DrawerDescription>
|
||||
</DrawerHeader>
|
||||
<div className="px-4">
|
||||
<Typography variant="small">패널 본문 영역.</Typography>
|
||||
</div>
|
||||
<DrawerFooter>
|
||||
<Button>저장</Button>
|
||||
<DrawerClose asChild><Button variant="outline">닫기</Button></DrawerClose>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
</Section>
|
||||
|
||||
<Section title="토스트">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button variant="outline" onClick={() => showToast('성공적으로 처리되었습니다.', 'success')}>
|
||||
success
|
||||
</Button>
|
||||
<Button variant="outline" onClick={() => showToast('참고할 정보입니다.', 'info')}>
|
||||
info
|
||||
</Button>
|
||||
<Button variant="outline" onClick={() => showToast('오류가 발생했습니다.', 'error')}>
|
||||
error
|
||||
</Button>
|
||||
</div>
|
||||
<Typography variant="muted" className="pt-2">
|
||||
전역 단일 출처: <code className="font-mono">showToast(message, type)</code> (sonner)
|
||||
</Typography>
|
||||
</Section>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Section({ title, children }: { title: string; children: ReactNode }) {
|
||||
return (
|
||||
<section className="space-y-4 border-t border-border pt-8">
|
||||
<Typography variant="h2">{title}</Typography>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Swatch({ name, className }: { name: string; className: string }) {
|
||||
return (
|
||||
<div className="space-y-1.5">
|
||||
<div className={`h-14 w-full rounded-md ${className}`} />
|
||||
<Typography variant="mono" className="lowercase tracking-normal">{name}</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import {Link} from 'react-router';
|
||||
import {ShieldX} from 'lucide-react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
|
||||
export default function ForbiddenPage() {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background px-4">
|
||||
<div className="w-full max-w-sm bg-card border border-border rounded-lg shadow-sm p-8 flex flex-col items-center text-center gap-3">
|
||||
<div className="h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center">
|
||||
<ShieldX className="h-6 w-6 text-destructive" />
|
||||
</div>
|
||||
<Typography variant="h3" as="h1">403 · 접근 권한 없음</Typography>
|
||||
<Typography variant="muted">
|
||||
이 페이지에 접근할 수 있는 권한 등급이 아닙니다.
|
||||
<br />
|
||||
관리자에게 권한을 요청하세요.
|
||||
</Typography>
|
||||
<Link
|
||||
to="/products"
|
||||
className="mt-2 py-2 px-4 bg-primary text-primary-foreground font-semibold rounded text-sm hover:bg-primary/95 transition-colors"
|
||||
>
|
||||
상품관리로 돌아가기
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router';
|
||||
import { User, Lock } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { useAuth } from '../features/auth/useAuth';
|
||||
import { showToast } from '@/lib/notify';
|
||||
|
||||
export default function LoginPage() {
|
||||
const { login } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const redirectTo = searchParams.get('redirect');
|
||||
|
||||
const [loginId, setLoginId] = useState('admin');
|
||||
const [password, setPassword] = useState('admin1234');
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
|
||||
if (!loginId.trim()) {
|
||||
setError('아이디를 입력하세요.');
|
||||
return;
|
||||
}
|
||||
if (!password.trim()) {
|
||||
setError('비밀번호를 입력하세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const me = await login(loginId.trim(), password);
|
||||
showToast(
|
||||
`${me.company?.name ? me.company.name + ' ' : ''}${me.name ?? ''}님, 네고시움 시스템에 로그인했습니다.`,
|
||||
'success',
|
||||
);
|
||||
navigate(redirectTo || '/products');
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : '로그인에 실패했습니다.');
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background px-4">
|
||||
<Card className="w-full max-w-sm gap-0 p-8 transition-all hover:border-foreground/10">
|
||||
|
||||
<div className="flex flex-col items-center mb-6">
|
||||
<Typography variant="h2" as="h1">NegoData</Typography>
|
||||
<Typography variant="mono" className="mt-1">
|
||||
Negosium Admin Console
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<Typography as="label" variant="label" htmlFor="login-id">
|
||||
아이디
|
||||
</Typography>
|
||||
<div className="relative">
|
||||
<User className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
id="login-id"
|
||||
type="text"
|
||||
autoComplete="username"
|
||||
value={loginId}
|
||||
onChange={(e) => setLoginId(e.target.value)}
|
||||
className="pl-9"
|
||||
placeholder="아이디 입력"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Typography as="label" variant="label" htmlFor="login-password">
|
||||
비밀번호
|
||||
</Typography>
|
||||
<div className="relative">
|
||||
<Lock className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
id="login-password"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="pl-9"
|
||||
placeholder="비밀번호 입력"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Error messages */}
|
||||
{error && (
|
||||
<div className="p-3 rounded bg-destructive/10 border border-destructive/20 text-xs text-destructive">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
size="lg"
|
||||
className="w-full"
|
||||
>
|
||||
{loading ? (
|
||||
<span className="inline-block animate-spin h-4 w-4 border-2 border-primary-foreground border-t-transparent rounded-full" />
|
||||
) : (
|
||||
'로그인'
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Upload } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { PageToolbar, SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { usePartners } from '@/features/partners/hooks/usePartners';
|
||||
import { usePartnerFilters } from '@/features/partners/hooks/usePartnerFilters';
|
||||
import { PartnerTable } from '@/features/partners/components/PartnerTable';
|
||||
import { PartnerFormSheet } from '@/features/partners/components/PartnerFormSheet';
|
||||
import { ExcelUploadModal } from '@/features/partners/components/ExcelUploadModal';
|
||||
import { prioritiesList, type Partner } from '@/features/partners/types';
|
||||
|
||||
export default function PartnersPage() {
|
||||
const { partners, createPartner, updatePartner, deletePartner, bulkCreate } = usePartners();
|
||||
const {
|
||||
search,
|
||||
setSearch,
|
||||
priorityFilter,
|
||||
setPriorityFilter,
|
||||
page,
|
||||
setPage,
|
||||
paginated,
|
||||
totalPages,
|
||||
totalCount,
|
||||
itemsPerPage,
|
||||
} = usePartnerFilters(partners);
|
||||
|
||||
// 모달 제어 + 폼 컨텍스트
|
||||
const [openModal, setOpenModal] = useState<null | 'form' | 'excel'>(null);
|
||||
const [formMode, setFormMode] = useState<'create' | 'edit'>('create');
|
||||
const [editing, setEditing] = useState<Partner | null>(null);
|
||||
|
||||
const openCreate = () => {
|
||||
setFormMode('create');
|
||||
setEditing(null);
|
||||
setOpenModal('form');
|
||||
};
|
||||
const openEdit = (part: Partner) => {
|
||||
setFormMode('edit');
|
||||
setEditing(part);
|
||||
setOpenModal('form');
|
||||
};
|
||||
|
||||
const handleDeletePartner = async (id: string, partnerName: string) => {
|
||||
if (confirm(`[${partnerName}] 파트너사를 협력사 목록에서 삭제하시겠습니까?`)) {
|
||||
try {
|
||||
await deletePartner(id);
|
||||
showToast('협력사 정보가 명부에서 제거되었습니다.', 'info');
|
||||
} catch (err) {
|
||||
showToast(err instanceof Error ? err.message : '협력사 삭제 실패', 'error');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<PageToolbar
|
||||
actions={
|
||||
<>
|
||||
<Button variant="outline" onClick={() => setOpenModal('excel')}>
|
||||
<Upload />
|
||||
엑셀 일괄 업로드
|
||||
</Button>
|
||||
|
||||
<Button onClick={openCreate}>
|
||||
<Plus />
|
||||
신규 협력사 등록
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SearchInput
|
||||
id="partner-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="협력사명, 코드 또는 담당자명으로 추적 검색..."
|
||||
/>
|
||||
|
||||
<Select value={priorityFilter} onValueChange={(v) => setPriorityFilter(v as string)}>
|
||||
<SelectTrigger id="partner-priority-filter" className="w-full sm:w-48">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'ALL' ? '우선순위 가중치 (전체)' : `우선도: ${value}`)}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{prioritiesList.map((prio) => (
|
||||
<SelectItem key={prio} value={prio}>
|
||||
{prio === 'ALL' ? '우선순위 가중치 (전체)' : `우선도: ${prio}`}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</PageToolbar>
|
||||
|
||||
<PartnerTable
|
||||
data={paginated}
|
||||
onRowClick={openEdit}
|
||||
page={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
pageSize={itemsPerPage}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
{openModal === 'form' && (
|
||||
<PartnerFormSheet
|
||||
key={`${formMode}-${editing?.supplier_id ?? 'new'}`}
|
||||
open
|
||||
mode={formMode}
|
||||
partner={editing}
|
||||
onCreate={createPartner}
|
||||
onUpdate={updatePartner}
|
||||
onDelete={handleDeletePartner}
|
||||
onClose={() => setOpenModal(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{openModal === 'excel' && (
|
||||
<ExcelUploadModal
|
||||
open
|
||||
partners={partners}
|
||||
onConfirm={bulkCreate}
|
||||
onClose={() => setOpenModal(null)}
|
||||
/>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Upload, TrendingDown } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { PageToolbar, SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { useProducts } from '@/features/products/hooks/useProducts';
|
||||
import { useProductFilters } from '@/features/products/hooks/useProductFilters';
|
||||
import { ProductTable } from '@/features/products/components/ProductTable';
|
||||
import { ProductFormSheet } from '@/features/products/components/ProductFormSheet';
|
||||
import { PriceUpdateModal } from '@/features/products/components/PriceUpdateModal';
|
||||
import { ExcelUploadModal } from '@/features/products/components/ExcelUploadModal';
|
||||
import { categoriesList, type Product } from '@/features/products/types';
|
||||
|
||||
export default function ProductsPage() {
|
||||
const { products, createProduct, updateProduct, deleteProduct, bulkCreate } = useProducts();
|
||||
const {
|
||||
search,
|
||||
setSearch,
|
||||
categoryFilter,
|
||||
setCategoryFilter,
|
||||
page,
|
||||
setPage,
|
||||
paginated,
|
||||
totalPages,
|
||||
totalCount,
|
||||
itemsPerPage,
|
||||
} = useProductFilters(products);
|
||||
|
||||
// 행 선택(테이블 체크박스 + 최저가 모달 대상)
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
|
||||
// 모달 제어 + 폼 컨텍스트
|
||||
const [openModal, setOpenModal] = useState<null | 'form' | 'price' | 'excel'>(null);
|
||||
const [formMode, setFormMode] = useState<'create' | 'edit'>('create');
|
||||
const [editing, setEditing] = useState<Product | null>(null);
|
||||
|
||||
const openCreate = () => {
|
||||
setFormMode('create');
|
||||
setEditing(null);
|
||||
setOpenModal('form');
|
||||
};
|
||||
const openEdit = (prod: Product) => {
|
||||
setFormMode('edit');
|
||||
setEditing(prod);
|
||||
setOpenModal('form');
|
||||
};
|
||||
|
||||
const handleDeleteProduct = async (id: string, prodName: string) => {
|
||||
if (confirm(`[${prodName}] 상품 정보를 완전 삭제하시겠습니까?`)) {
|
||||
try {
|
||||
await deleteProduct(id);
|
||||
showToast('상품 정보가 대시보드에서 제거되었습니다.', 'info');
|
||||
} catch (err) {
|
||||
showToast(err instanceof Error ? err.message : '상품 삭제 실패', 'error');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<PageToolbar
|
||||
actions={
|
||||
<>
|
||||
<Button
|
||||
variant="outline"
|
||||
disabled={selectedIds.length === 0}
|
||||
onClick={() => setOpenModal('price')}
|
||||
>
|
||||
<TrendingDown />
|
||||
최저가 업데이트하기
|
||||
{selectedIds.length > 0 && <Badge variant="destructive">{selectedIds.length}</Badge>}
|
||||
</Button>
|
||||
|
||||
<Button variant="outline" onClick={() => setOpenModal('excel')}>
|
||||
<Upload />
|
||||
엑셀 일괄 업로드
|
||||
</Button>
|
||||
|
||||
<Button onClick={openCreate}>
|
||||
<Plus />
|
||||
신규 상품 등록
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SearchInput
|
||||
id="product-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="상품명 또는 상품 코드로 통합 검색..."
|
||||
/>
|
||||
|
||||
<Select value={categoryFilter} onValueChange={(v) => setCategoryFilter(v as string)}>
|
||||
<SelectTrigger id="product-category-filter" className="w-full sm:w-48">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'ALL' ? '품목 카테고리 (전체)' : value)}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{categoriesList.map((cat) => (
|
||||
<SelectItem key={cat} value={cat}>
|
||||
{cat === 'ALL' ? '품목 카테고리 (전체)' : cat}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</PageToolbar>
|
||||
|
||||
<ProductTable
|
||||
data={paginated}
|
||||
selectedIds={selectedIds}
|
||||
onSelectionChange={setSelectedIds}
|
||||
onRowClick={openEdit}
|
||||
page={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
pageSize={itemsPerPage}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
{openModal === 'form' && (
|
||||
<ProductFormSheet
|
||||
key={`${formMode}-${editing?.item_id ?? 'new'}`}
|
||||
open
|
||||
mode={formMode}
|
||||
product={editing}
|
||||
onCreate={createProduct}
|
||||
onUpdate={updateProduct}
|
||||
onDelete={handleDeleteProduct}
|
||||
onClose={() => setOpenModal(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{openModal === 'price' && (
|
||||
<PriceUpdateModal
|
||||
open
|
||||
products={products}
|
||||
selectedIds={selectedIds}
|
||||
onDone={() => setSelectedIds([])}
|
||||
onClose={() => setOpenModal(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{openModal === 'excel' && (
|
||||
<ExcelUploadModal
|
||||
open
|
||||
products={products}
|
||||
onConfirm={bulkCreate}
|
||||
onClose={() => setOpenModal(null)}
|
||||
/>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import { useState } from 'react';
|
||||
import { Settings, Plus } from 'lucide-react';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { PageToolbar, SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useQuotations } from '@/features/quotations/hooks/useQuotations';
|
||||
import { useQuotationFilters } from '@/features/quotations/hooks/useQuotationFilters';
|
||||
import { QuotationTable } from '@/features/quotations/components/QuotationTable';
|
||||
import { QuotationDetailDrawer } from '@/features/quotations/components/QuotationDetailDrawer';
|
||||
import { CreateQuotationWizard } from '@/features/quotations/components/CreateQuotationWizard';
|
||||
import { QuotationSettingsModal } from '@/features/quotations/components/QuotationSettingsModal';
|
||||
import { QUOTATION_STATUS_FILTERS } from '@/features/quotations/types';
|
||||
|
||||
export default function QuotationPage() {
|
||||
const {
|
||||
products,
|
||||
partners,
|
||||
cards,
|
||||
quotations,
|
||||
quotationSettings,
|
||||
chatSessions,
|
||||
stopNegotiation,
|
||||
addSetting,
|
||||
deleteSetting,
|
||||
createQuotation,
|
||||
} = useQuotations();
|
||||
|
||||
const { search, setSearch, statusFilter, setStatusFilter, typeFilter, setTypeFilter, filtered } =
|
||||
useQuotationFilters(quotations);
|
||||
|
||||
const [detailId, setDetailId] = useState<string | null>(null);
|
||||
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||
|
||||
const activeQuotation = quotations.find((e) => e.id === detailId) ?? null;
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<PageToolbar
|
||||
actions={
|
||||
<>
|
||||
<button
|
||||
id="quotation-settings-btn"
|
||||
onClick={() => setIsSettingsOpen(true)}
|
||||
className="flex items-center gap-2 px-3 py-2.5 bg-muted text-foreground border border-border text-xs font-semibold rounded hover:bg-muted-foreground/10 cursor-pointer transition-colors"
|
||||
>
|
||||
<Settings size={14} />
|
||||
<span>견적 세팅</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="quotation-create-btn"
|
||||
onClick={() => setIsCreateOpen(true)}
|
||||
className="flex items-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground text-xs font-bold rounded hover:opacity-95 cursor-pointer transition-colors animate-pulse"
|
||||
>
|
||||
<Plus size={15} />
|
||||
<span>신규 협상견적 발의</span>
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SearchInput
|
||||
id="quotation-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="견적명 또는 견적 번호로 실시간 서치..."
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<Select value={statusFilter} onValueChange={(v) => setStatusFilter(v as string)}>
|
||||
<SelectTrigger id="quotation-status-filter" className="font-bold">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">전체 견적상태</SelectItem>
|
||||
{QUOTATION_STATUS_FILTERS.map((s) => (
|
||||
<SelectItem key={s} value={s}>{s}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Select value={typeFilter} onValueChange={(v) => setTypeFilter(v as string)}>
|
||||
<SelectTrigger id="quotation-type-filter">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'ALL' ? '전체 유형' : value === 'RE_NEGOTIATION' ? '재협상' : '재견적')}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">전체 유형</SelectItem>
|
||||
<SelectItem value="RE_NEGOTIATION">재협상</SelectItem>
|
||||
<SelectItem value="RE_ESTIMATE">재견적</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</PageToolbar>
|
||||
|
||||
<QuotationTable
|
||||
data={filtered}
|
||||
products={products}
|
||||
onOpenDetail={setDetailId}
|
||||
onStop={stopNegotiation}
|
||||
/>
|
||||
|
||||
{activeQuotation && (
|
||||
<QuotationDetailDrawer
|
||||
key={activeQuotation.id}
|
||||
estimate={activeQuotation}
|
||||
products={products}
|
||||
partners={partners}
|
||||
cards={cards}
|
||||
quotationSettings={quotationSettings}
|
||||
sessions={chatSessions[activeQuotation.id ?? ''] ?? []}
|
||||
onStop={stopNegotiation}
|
||||
onClose={() => setDetailId(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isCreateOpen && (
|
||||
<CreateQuotationWizard
|
||||
open
|
||||
products={products}
|
||||
partners={partners}
|
||||
cards={cards}
|
||||
quotationSettings={quotationSettings}
|
||||
onCreate={createQuotation}
|
||||
onClose={() => setIsCreateOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isSettingsOpen && (
|
||||
<QuotationSettingsModal
|
||||
open
|
||||
settings={quotationSettings}
|
||||
onAdd={addSetting}
|
||||
onDelete={deleteSetting}
|
||||
onClose={() => setIsSettingsOpen(false)}
|
||||
/>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user