[feat] negodata: 재협상 소유권 게이팅·처리담당자·상세 링크·재생성 타이틀·알림 토스트(읽음API)·재협상요청 표기·커스텀필드 select

This commit is contained in:
minaChoi committed 2026-07-24 14:18:52 +09:00
1 parent d7c4e86f30
commit 51d07bb779
54 files changed
+2002 -58

No files matched your search

@@ -1,6 +1,6 @@
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
import { useSearchParams } from 'react-router';
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw, Download, Upload } from 'lucide-react';
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw, Download, Upload, X } from 'lucide-react';
import { showToast } from '@/lib/notify';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -180,30 +180,6 @@ export function SettingsView() {
placeholder="NegoData (기본값)"
/>
</Field>
<Field label="브랜드 색상" hint="브랜드 마크 색 (hex)">
<div className="flex items-center gap-2">
<input
type="color"
aria-label="브랜드 색상 선택"
className="size-8 rounded border border-border bg-transparent p-0.5 cursor-pointer"
value={draft.branding?.primary_color || '#5E6AD2'}
onChange={(e) => setBranding('primary_color', e.target.value)}
/>
<Input
className="w-32"
value={draft.branding?.primary_color ?? ''}
onChange={(e) => setBranding('primary_color', e.target.value)}
placeholder="#5E6AD2"
/>
</div>
</Field>
<Field label="이메일 헤더 문구" hint="협상 초청 메일 상단 브랜드 문구">
<Input
value={draft.branding?.email_header ?? ''}
onChange={(e) => setBranding('email_header', e.target.value)}
placeholder="NEGODATA (기본값)"
/>
</Field>
</div>
{/* 로고 이미지 — 업로드(드롭/선택) 또는 URL 직접 입력. 비우면 색상 마크+서비스명 텍스트. */}
@@ -430,13 +406,14 @@ function CustomFieldsEditor({
<TableHead className="p-2 w-52">표시명</TableHead>
<TableHead className="p-2 w-52">키 (영문)</TableHead>
<TableHead className="p-2 w-36">유형</TableHead>
<TableHead className="p-2">보기 목록 (선택형, 쉼표로 구분)</TableHead>
<TableHead className="p-2 text-center w-12">삭제</TableHead>
</TableRow>
</TableHeader>
<TableBody className="divide-y divide-border bg-background">
{fields.length === 0 && (
<TableRow>
<TableCell colSpan={4} className="p-6 text-center text-muted-foreground">
<TableCell colSpan={5} className="p-6 text-center text-muted-foreground">
추가된 커스텀 필드가 없습니다.
</TableCell>
</TableRow>
@@ -476,6 +453,13 @@ function CustomFieldsEditor({
</SelectContent>
</Select>
</TableCell>
<TableCell className="p-2">
<OptionsEditor
options={f.options ?? []}
disabled={f.type !== 'select'}
onChange={(opts) => update(i, { options: opts })}
/>
</TableCell>
<TableCell className="p-2 text-center">
<button
type="button"
@@ -504,6 +488,60 @@ function CustomFieldsEditor({
);
}
// 선택형 필드의 보기 목록 — 칩(태그) 방식. 입력 후 Enter/쉼표로 하나씩 추가, X로 제거, 빈 칸에서 Backspace 로 마지막 제거.
function OptionsEditor({
options,
disabled,
onChange,
}: {
options: string[];
disabled?: boolean;
onChange: (opts: string[]) => void;
}) {
const [draft, setDraft] = useState('');
if (disabled) return <span className="text-[11px] text-muted-foreground">유형이 &lsquo;선택&rsquo;일 때 사용</span>;
const add = (raw: string) => {
const v = raw.trim();
setDraft('');
if (v && !options.includes(v)) onChange([...options, v]);
};
return (
<div className="flex min-h-7 flex-wrap items-center gap-1 rounded-md border border-input bg-background px-1.5 py-1">
{options.map((o, idx) => (
<span key={idx} className="inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px] font-sans">
{o}
<button
type="button"
onClick={() => onChange(options.filter((_, i) => i !== idx))}
className="text-muted-foreground hover:text-red-500"
title="옵션 삭제"
>
<X size={11} />
</button>
</span>
))}
<input
className="h-5 min-w-[70px] flex-1 bg-transparent text-[11px] font-sans outline-none"
value={draft}
onChange={(e) => (e.target.value.includes(',') ? add(e.target.value.replace(/,/g, '')) : setDraft(e.target.value))}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
e.preventDefault();
add(draft);
} else if (e.key === 'Backspace' && !draft && options.length) {
onChange(options.slice(0, -1));
}
}}
onBlur={() => add(draft)}
placeholder={options.length ? '추가…' : '예: 협력사배송 (엔터로 추가)'}
/>
</div>
);
}
// key 입력 정리 — 영문/숫자/언더스코어만 허용(소문자화).
function sanitizeKey(raw: string): string {
return raw.toLowerCase().replace(/[^a-z0-9_]/g, '');