[feat] negodata: 카드 성공률 순위·상품 엑셀 TO-BE 싱크·회사설정 JSON 입출력·목록 포털형 UI
- 협상카드 성공률(사용 세션 대비 타결) 집계 추가, 견적 생성 카드선택 순위 정렬·통계 TOP5 - 상품 엑셀: 품목코드·모델명 라벨화, 리드타임 suffix 제거, 공급사 컬럼 신설(등록 후 supplier_items 매핑) - 설정 화면 JSON 불러오기/내보내기(빈 값은 미갱신), IMK 설정 JSON 보관 - 설정·회원 페이지 새로고침 forbidden 수정(자식 loader 가 initAuth 대기) - 협력사·견적 목록도 포털형 카드(툴바+테이블 결합)로 통일
This commit is contained in:
1 parent
fa9113da55
commit
03322d6ca3
22 files changed
+448
-41
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw } from 'lucide-react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw, Download, Upload } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -59,6 +59,30 @@ export function SettingsView() {
|
||||
}
|
||||
};
|
||||
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// 현재 편집본을 JSON 파일로 내려받는다(회사 설정 전체 백업/이관용).
|
||||
const handleExport = () => {
|
||||
const blob = new Blob([JSON.stringify(draft, null, 2)], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'company-settings.json';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
// JSON 파일 → 편집본 병합. 빈 값(빈 문자열·빈 배열·null)은 "그대로 두기"로 보고 덮어쓰지 않는다.
|
||||
const handleImport = async (file: File) => {
|
||||
try {
|
||||
const parsed = JSON.parse(await file.text()) as CompanySettings;
|
||||
setDraft((d) => mergeSettings(d, parsed));
|
||||
showToast('설정 JSON 을 불러왔습니다. 확인 후 저장하십시오.', 'success');
|
||||
} catch (err) {
|
||||
showToast(err instanceof Error ? `JSON 파싱 실패 - ${err.message}` : 'JSON 파싱 실패', 'error');
|
||||
}
|
||||
};
|
||||
|
||||
// 로고 파일 업로드 — 상품 이미지와 동일한 스토리지 엔드포인트(/v1/item/image, Azure Blob)를 재사용해 URL 을 받는다.
|
||||
const handleUploadLogo = async (file: File): Promise<string> => {
|
||||
const res = await uploadItemImage({ file: file as unknown as string });
|
||||
@@ -95,6 +119,23 @@ export function SettingsView() {
|
||||
<RotateCcw size={13} /> 되돌리기
|
||||
</Button>
|
||||
)}
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept="application/json,.json"
|
||||
className="hidden"
|
||||
onChange={(e) => {
|
||||
const f = e.target.files?.[0];
|
||||
if (f) handleImport(f);
|
||||
e.target.value = ''; // 같은 파일 재선택 허용
|
||||
}}
|
||||
/>
|
||||
<Button variant="ghost" size="sm" onClick={() => fileRef.current?.click()}>
|
||||
<Upload size={13} /> JSON 불러오기
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={handleExport}>
|
||||
<Download size={13} /> JSON 내보내기
|
||||
</Button>
|
||||
<Button size="sm" onClick={handleSave} disabled={!dirty || saving}>
|
||||
{saving ? '저장 중...' : '변경사항 저장'}
|
||||
</Button>
|
||||
@@ -243,6 +284,29 @@ export function SettingsView() {
|
||||
);
|
||||
}
|
||||
|
||||
// 불러온 JSON 을 현재 설정에 병합. 값이 비어있는 키(빈 문자열·빈 배열·null·undefined)는
|
||||
// "업데이트 안 함"으로 보고 기존 값을 유지한다 — 부분 JSON 만 던져도 안전하게 갱신되도록.
|
||||
function mergeSettings(base: CompanySettings, incoming: CompanySettings): CompanySettings {
|
||||
const mergeMap = (b: Record<string, string> = {}, i: Record<string, string> = {}) => {
|
||||
const out = { ...b };
|
||||
for (const [k, v] of Object.entries(i)) if (typeof v === 'string' && v.trim()) out[k] = v;
|
||||
return out;
|
||||
};
|
||||
const pickFields = (b?: CustomFieldDef[], i?: CustomFieldDef[]) =>
|
||||
Array.isArray(i) && i.length > 0 ? i : (b ?? []);
|
||||
return {
|
||||
...base,
|
||||
labels: mergeMap(base.labels, incoming.labels),
|
||||
branding: mergeMap(
|
||||
base.branding as Record<string, string> | undefined,
|
||||
incoming.branding as Record<string, string> | undefined,
|
||||
) as CompanySettings['branding'],
|
||||
item_fields: pickFields(base.item_fields, incoming.item_fields),
|
||||
supplier_fields: pickFields(base.supplier_fields, incoming.supplier_fields),
|
||||
session_fields: pickFields(base.session_fields, incoming.session_fields),
|
||||
};
|
||||
}
|
||||
|
||||
function SectionCard({ title, desc, children }: { title: string; desc: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="bg-card border border-border rounded-lg p-5">
|
||||
|
||||
Reference in new issue
Block a user