Merge remote-tracking branch 'origin/main' into feat/source-state
This commit is contained in:
commit
67612b477c
63 files changed
+2162
-491
No files matched your search
@@ -25,8 +25,10 @@ import type {
|
||||
|
||||
import type {
|
||||
HTTPValidationError,
|
||||
ReqPreviewInviteEmail,
|
||||
ReqUpdateCompanySettings,
|
||||
ResCompanySettings
|
||||
ResCompanySettings,
|
||||
ResPreviewInviteEmail
|
||||
} from '.././model';
|
||||
|
||||
import { customFetch } from '../../mutator/custom-fetch';
|
||||
@@ -191,4 +193,68 @@ export const useUpdateSettings = <TError = void | HTTPValidationError,
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 협상 초청 메일 미리보기
|
||||
*/
|
||||
export const previewInviteEmail = (
|
||||
reqPreviewInviteEmail: ReqPreviewInviteEmail,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResPreviewInviteEmail>(
|
||||
{url: `/v1/company/settings/email-preview`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqPreviewInviteEmail, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getPreviewInviteEmailMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof previewInviteEmail>>, TError,{data: ReqPreviewInviteEmail}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof previewInviteEmail>>, TError,{data: ReqPreviewInviteEmail}, TContext> => {
|
||||
|
||||
const mutationKey = ['previewInviteEmail'];
|
||||
const {mutation: mutationOptions, request: requestOptions} = options ?
|
||||
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
||||
options
|
||||
: {...options, mutation: {...options.mutation, mutationKey}}
|
||||
: {mutation: { mutationKey, }, request: undefined};
|
||||
|
||||
|
||||
|
||||
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof previewInviteEmail>>, {data: ReqPreviewInviteEmail}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return previewInviteEmail(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type PreviewInviteEmailMutationResult = NonNullable<Awaited<ReturnType<typeof previewInviteEmail>>>
|
||||
export type PreviewInviteEmailMutationBody = ReqPreviewInviteEmail
|
||||
export type PreviewInviteEmailMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 협상 초청 메일 미리보기
|
||||
*/
|
||||
export const usePreviewInviteEmail = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof previewInviteEmail>>, TError,{data: ReqPreviewInviteEmail}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof previewInviteEmail>>,
|
||||
TError,
|
||||
{data: ReqPreviewInviteEmail},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getPreviewInviteEmailMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@@ -203,6 +203,8 @@ export * from './reqCreateSupplierManagerEmail';
|
||||
export * from './reqCreateSupplierManagerName';
|
||||
export * from './reqCreateSupplierTotalRevenue';
|
||||
export * from './reqLogin';
|
||||
export * from './reqPreviewInviteEmail';
|
||||
export * from './reqPreviewInviteEmailBranding';
|
||||
export * from './reqRegenerateQuotation';
|
||||
export * from './reqRegenerateQuotationCardIds';
|
||||
export * from './reqRegenerateQuotationDoneCeilingRate';
|
||||
@@ -344,6 +346,8 @@ export * from './resNotificationRead';
|
||||
export * from './resNotificationReadMsg';
|
||||
export * from './resNotifySessions';
|
||||
export * from './resNotifySessionsMsg';
|
||||
export * from './resPreviewInviteEmail';
|
||||
export * from './resPreviewInviteEmailMsg';
|
||||
export * from './resQuotation';
|
||||
export * from './resQuotationCards';
|
||||
export * from './resQuotationCardsMsg';
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ReqPreviewInviteEmailBranding } from './reqPreviewInviteEmailBranding';
|
||||
|
||||
export interface ReqPreviewInviteEmail {
|
||||
branding?: ReqPreviewInviteEmailBranding;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ReqPreviewInviteEmailBranding = { [key: string]: unknown };
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ErrorInfo } from './errorInfo';
|
||||
import type { ResPreviewInviteEmailMsg } from './resPreviewInviteEmailMsg';
|
||||
|
||||
export interface ResPreviewInviteEmail {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResPreviewInviteEmailMsg;
|
||||
subject?: string;
|
||||
html?: string;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResPreviewInviteEmailMsg = string | null;
|
||||
@@ -21,18 +21,6 @@ import NotificationsPage from '../pages/notifications';
|
||||
import OnboardingPage from '../pages/onboarding';
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
// dev 전용: import.meta.env.DEV가 false인 프로덕션 빌드에선 이 배열 항목과
|
||||
// 내부 import()가 통째로 트리셰이킹되어 번들/라우트에 포함되지 않는다.
|
||||
...(import.meta.env.DEV
|
||||
? [
|
||||
{
|
||||
path: 'dev/design',
|
||||
lazy: async () => ({
|
||||
Component: (await import('../pages/dev/dev-design')).default,
|
||||
}),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
index: true,
|
||||
loader: () => redirect('/dashboard'),
|
||||
|
||||
@@ -180,11 +180,7 @@ export default function Layout({ children, currentPage, setPage, onLogout }: Lay
|
||||
{branding.logoUrl ? (
|
||||
<img src={branding.logoUrl} alt={branding.serviceName} className="h-4 max-w-24 object-contain" />
|
||||
) : (
|
||||
<span
|
||||
aria-hidden
|
||||
className="size-4 rounded-[5px] bg-primary"
|
||||
style={branding.primaryColor ? { backgroundColor: branding.primaryColor } : undefined}
|
||||
/>
|
||||
<span aria-hidden className="size-4 rounded-[5px] bg-primary" />
|
||||
)}
|
||||
{branding.serviceName}
|
||||
</Typography>
|
||||
@@ -291,7 +287,9 @@ export default function Layout({ children, currentPage, setPage, onLogout }: Lay
|
||||
{/* Main Container Wrapper */}
|
||||
<div
|
||||
className={cn(
|
||||
'flex-1 flex flex-col transition-all duration-300',
|
||||
// min-w-0: flex 아이템은 기본 min-width:auto 라 넓은 콘텐츠(다컬럼 표·차트)가
|
||||
// 래퍼를 뷰포트 밖으로 밀어낸다 — 이걸 끊어야 표 내부 overflow-x-auto 가 스크롤로 받는다.
|
||||
'flex-1 min-w-0 flex flex-col transition-all duration-300',
|
||||
// 모바일: 사이드바가 오버레이라 패딩 없음 / 데스크톱: 사이드바 폭만큼 확보
|
||||
isSidebarOpen ? 'md:pl-60' : 'md:pl-16'
|
||||
)}
|
||||
@@ -585,7 +583,8 @@ function NavItem({
|
||||
function HeaderMeta({ user, today }: { user: SidebarUser; today: string }) {
|
||||
return (
|
||||
<div className="flex items-center gap-3 md:gap-4">
|
||||
<Typography as="div" variant="caption" className="hidden lg:block">
|
||||
{/* 기준일시·관리자는 xl 부터 — lg 구간(1024~1280)은 우측 1fr 이 ~240px 라 글자가 세로로 깨진다. */}
|
||||
<Typography as="div" variant="caption" className="hidden xl:block whitespace-nowrap">
|
||||
기준일시: <span className="font-semibold text-foreground">{today}</span>
|
||||
</Typography>
|
||||
|
||||
@@ -603,8 +602,8 @@ function HeaderMeta({ user, today }: { user: SidebarUser; today: string }) {
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="h-4 w-px bg-border hidden lg:block" />
|
||||
<div className="hidden lg:flex items-center gap-2">
|
||||
<div className="h-4 w-px bg-border hidden xl:block" />
|
||||
<div className="hidden xl:flex items-center gap-2 whitespace-nowrap">
|
||||
<Typography as="span" variant="caption">관리자:</Typography>
|
||||
<Typography as="span" variant="caption" className="font-semibold text-foreground">
|
||||
{user?.name} ({user?.loginId})
|
||||
|
||||
@@ -236,7 +236,7 @@ const ZONE_STYLE: Record<NegotiationZoneTone, { marker: string; active: string;
|
||||
marker: 'bg-primary',
|
||||
active: 'bg-primary/10',
|
||||
text: 'text-primary',
|
||||
track: '#2563eb',
|
||||
track: '#5E6AD2',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
import { useRef, useState } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { ImagePlus, X, Loader2 } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { useScrollLock } from '@/lib/useScrollLock';
|
||||
import { uploadItemImage, updateItem } from '@/api/generated/item/item';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import type { Product } from '../types';
|
||||
|
||||
// 로컬 이미지 일괄 업로드 — 파일명(확장자 제외)을 상품코드로 매칭해 업로드하고 상품에 연결한다.
|
||||
// 엑셀 양식과 무관한 독립 흐름: 기존 단건 업로드(/v1/item/image)와 상품 수정(image_url)을 파일별로 반복한다.
|
||||
// (협력사·카드 엑셀과 같은 프론트 루프 패턴 — 신규 API 없음)
|
||||
|
||||
// 상품 등록 폼이 이미지 미입력 시 넣는 기본(placeholder) 이미지 — 실제 이미지로 치지 않는다.
|
||||
const PLACEHOLDER_IMAGE_MARK = 'images.unsplash.com/photo-1593941707882';
|
||||
|
||||
type RowIssue =
|
||||
| 'unmatched' // 파일명과 일치하는 상품코드 없음
|
||||
| 'dup_code' // 같은 코드의 상품이 여러 건 — 어느 상품인지 특정 불가
|
||||
| 'dup_file' // 같은 코드의 파일이 여러 개 — 앞 파일만 유효
|
||||
| 'forbidden'; // 남의 상품(수정권한 없음 — 본인∪최고관리자만)
|
||||
|
||||
type RowState = 'ready' | 'skip' | 'uploading' | 'done' | 'failed';
|
||||
|
||||
type MatchRow = {
|
||||
file: File;
|
||||
base: string; // 파일명에서 확장자를 뗀 값 = 상품코드 후보
|
||||
product?: Product;
|
||||
issue?: RowIssue;
|
||||
hasImage: boolean; // 기존 이미지 보유(placeholder 제외) — 덮어쓰기 옵션 판정용
|
||||
state: RowState;
|
||||
reason?: string; // failed 사유
|
||||
};
|
||||
|
||||
type Phase = 'select' | 'running' | 'done';
|
||||
|
||||
export function ImageBulkUploadModal({
|
||||
open,
|
||||
loadProducts,
|
||||
onClose,
|
||||
}: {
|
||||
open: boolean;
|
||||
loadProducts: () => Promise<Product[]>; // 전체 상품(페이지 밖 포함) — 매칭·권한 판정용
|
||||
onClose: () => void;
|
||||
}) {
|
||||
useScrollLock(open);
|
||||
const queryClient = useQueryClient();
|
||||
const myUserId = useAuthStore((s) => s.user?.userId);
|
||||
const isSuperAdmin = useAuthStore((s) => canManage(s.user?.role));
|
||||
|
||||
const [rows, setRows] = useState<MatchRow[]>([]);
|
||||
const [phase, setPhase] = useState<Phase>('select');
|
||||
const [overwrite, setOverwrite] = useState(true); // 대부분 placeholder 이미지라 기본 덮어쓰기
|
||||
const [matching, setMatching] = useState(false);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// 파일 선택/드롭 → 전체 상품을 받아 파일명=상품코드 매칭표를 만든다(업로드는 아직 안 한다).
|
||||
const handleFiles = async (files: FileList | File[]) => {
|
||||
const picked = [...files].filter((f) => f.type.startsWith('image/'));
|
||||
if (picked.length === 0) {
|
||||
showToast('이미지 파일이 없습니다. (jpg/png 등 이미지만 지원)', 'error');
|
||||
return;
|
||||
}
|
||||
setMatching(true);
|
||||
try {
|
||||
const products = await loadProducts();
|
||||
setRows(buildRows(picked, products, myUserId, isSuperAdmin));
|
||||
setPhase('select');
|
||||
} catch (err) {
|
||||
showToast(err instanceof Error ? err.message : '상품 목록 조회에 실패했습니다.', 'error');
|
||||
} finally {
|
||||
setMatching(false);
|
||||
}
|
||||
};
|
||||
|
||||
const uploadTargets = rows.filter((r) => isUploadable(r, overwrite));
|
||||
const skippedByImage = rows.filter((r) => !r.issue && r.product && !overwrite && r.hasImage);
|
||||
|
||||
// 업로드 실행 — 파일별 순차: 이미지 업로드 → 받은 URL 을 상품 수정으로 저장. 실패해도 멈추지 않는다.
|
||||
const handleRun = async () => {
|
||||
setPhase('running');
|
||||
let ok = 0;
|
||||
let fail = 0;
|
||||
for (const row of rows) {
|
||||
if (!isUploadable(row, overwrite)) continue;
|
||||
setRowState(setRows, row.file, { state: 'uploading' });
|
||||
try {
|
||||
const up = await uploadItemImage({ file: row.file as unknown as string });
|
||||
if (up.result?.success === false) throw new Error(up.result.desc || '이미지 업로드 실패');
|
||||
if (!up.image_url) throw new Error('업로드 응답에 URL 이 없습니다.');
|
||||
const res = await updateItem(row.product!.item_id ?? '', { image_url: up.image_url });
|
||||
if (res.result?.success === false) throw new Error(res.result.desc || '상품 수정 거부');
|
||||
setRowState(setRows, row.file, { state: 'done' });
|
||||
ok += 1;
|
||||
} catch (err) {
|
||||
setRowState(setRows, row.file, {
|
||||
state: 'failed',
|
||||
reason: err instanceof Error ? err.message : '업로드 실패',
|
||||
});
|
||||
fail += 1;
|
||||
}
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: ['/v1/item/list'] });
|
||||
setPhase('done');
|
||||
showToast(
|
||||
fail === 0 ? `${ok}개 상품 이미지가 연결되었습니다.` : `${ok}개 성공 · ${fail}개 실패`,
|
||||
fail === 0 ? 'success' : 'error',
|
||||
);
|
||||
};
|
||||
|
||||
if (!open) return null;
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-xs">
|
||||
<div className="w-full max-w-3xl bg-card border border-border rounded-lg shadow-2xl p-6 max-h-[90vh] overflow-y-auto animate-scale-up font-mono">
|
||||
{/* 헤더 */}
|
||||
<div className="flex items-center justify-between pb-3 border-b border-border">
|
||||
<Typography variant="h3">상품 이미지 일괄 업로드</Typography>
|
||||
<button
|
||||
onClick={onClose}
|
||||
disabled={phase === 'running'}
|
||||
className="p-1 rounded text-muted-foreground hover:bg-muted cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground mt-3">
|
||||
파일명(확장자 제외)을 <Typography as="span" variant="small" className="text-[11px] font-bold text-foreground">상품코드</Typography>로
|
||||
매칭합니다. 예: <Typography as="span" variant="small" className="text-[11px] font-semibold text-foreground">ABC-001.jpg → 상품코드 ABC-001</Typography>
|
||||
</Typography>
|
||||
|
||||
{/* 파일 선택 존 */}
|
||||
<div
|
||||
onClick={() => phase !== 'running' && fileRef.current?.click()}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
onDrop={(e) => {
|
||||
e.preventDefault();
|
||||
if (phase !== 'running') handleFiles(e.dataTransfer.files);
|
||||
}}
|
||||
className={`mt-4 rounded-md border-2 border-dashed border-border p-6 text-center transition-colors ${
|
||||
phase === 'running' ? 'opacity-50' : 'cursor-pointer hover:border-primary hover:bg-primary/5'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
className="hidden"
|
||||
onChange={(e) => {
|
||||
if (e.target.files) handleFiles(e.target.files);
|
||||
e.target.value = ''; // 같은 파일 재선택 허용
|
||||
}}
|
||||
/>
|
||||
{matching ? (
|
||||
<Typography as="div" variant="small" className="flex items-center justify-center gap-2 text-muted-foreground">
|
||||
<Loader2 size={14} className="animate-spin" /> 상품 목록과 매칭 중…
|
||||
</Typography>
|
||||
) : (
|
||||
<>
|
||||
<ImagePlus size={20} className="mx-auto text-muted-foreground" />
|
||||
<Typography as="p" variant="small" className="mt-2 text-xs text-muted-foreground">
|
||||
이미지를 끌어다 놓거나 클릭해서 선택 (여러 장 가능)
|
||||
</Typography>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 옵션 + 매칭표 */}
|
||||
{rows.length > 0 && (
|
||||
<>
|
||||
<label className="mt-4 flex items-center gap-2 cursor-pointer w-fit">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={overwrite}
|
||||
disabled={phase === 'running'}
|
||||
onChange={(e) => setOverwrite(e.target.checked)}
|
||||
className="h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer"
|
||||
/>
|
||||
<Typography as="span" variant="small" className="text-xs">
|
||||
기존 이미지가 있는 상품도 덮어쓰기
|
||||
</Typography>
|
||||
</label>
|
||||
|
||||
<div className="mt-3 border border-border rounded-md overflow-hidden">
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_8.5rem] gap-x-3 px-3 py-2 bg-muted/40 border-b border-border">
|
||||
<Typography as="span" variant="mono" className="text-[10px] text-muted-foreground">파일명</Typography>
|
||||
<Typography as="span" variant="mono" className="text-[10px] text-muted-foreground">매칭 상품</Typography>
|
||||
<Typography as="span" variant="mono" className="text-[10px] text-muted-foreground text-right">상태</Typography>
|
||||
</div>
|
||||
<div className="max-h-64 overflow-y-auto divide-y divide-border">
|
||||
{rows.map((r, i) => (
|
||||
<div key={`${r.file.name}-${i}`} className="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_8.5rem] gap-x-3 px-3 py-1.5 items-center">
|
||||
<Typography as="span" variant="small" className="text-[11px] truncate" title={r.file.name}>
|
||||
{r.file.name}
|
||||
</Typography>
|
||||
<Typography as="span" variant="small" className="text-[11px] truncate text-muted-foreground" title={r.product?.name ?? ''}>
|
||||
{r.product ? r.product.name : '—'}
|
||||
</Typography>
|
||||
<span className="text-right">{renderStatus(r, overwrite)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 요약 + 실행 */}
|
||||
<div className="mt-4 flex items-center justify-between gap-3">
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">
|
||||
업로드 대상 {uploadTargets.length}건
|
||||
{skippedByImage.length > 0 && ` · 기존 이미지로 건너뜀 ${skippedByImage.length}건`}
|
||||
{rows.filter((r) => r.issue).length > 0 && ` · 제외 ${rows.filter((r) => r.issue).length}건`}
|
||||
</Typography>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="outline" size="sm" onClick={onClose} disabled={phase === 'running'}>
|
||||
{phase === 'done' ? '닫기' : '취소'}
|
||||
</Button>
|
||||
{phase !== 'done' && (
|
||||
<Button size="sm" onClick={handleRun} disabled={phase === 'running' || uploadTargets.length === 0}>
|
||||
{phase === 'running' ? (
|
||||
<>
|
||||
<Loader2 size={13} className="animate-spin" /> 업로드 중…
|
||||
</>
|
||||
) : (
|
||||
`업로드 시작 (${uploadTargets.length})`
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 파일 → 상품 매칭표. 코드 비교는 공백 제거 + 대소문자 무시(엑셀·수기 등록 코드 표기가 섞여 있어서).
|
||||
function buildRows(
|
||||
files: File[],
|
||||
products: Product[],
|
||||
myUserId: string | undefined,
|
||||
isSuperAdmin: boolean,
|
||||
): MatchRow[] {
|
||||
const byCode = new Map<string, Product[]>();
|
||||
for (const p of products) {
|
||||
const code = String(p.code ?? '').trim().toLowerCase();
|
||||
if (!code) continue;
|
||||
byCode.set(code, [...(byCode.get(code) ?? []), p]);
|
||||
}
|
||||
const seenBases = new Set<string>();
|
||||
return files.map((file) => {
|
||||
const base = file.name.replace(/\.[^.]+$/, '').trim();
|
||||
const key = base.toLowerCase();
|
||||
const matches = byCode.get(key) ?? [];
|
||||
const product = matches.length === 1 ? matches[0] : undefined;
|
||||
let issue: RowIssue | undefined;
|
||||
if (matches.length === 0) issue = 'unmatched';
|
||||
else if (matches.length > 1) issue = 'dup_code';
|
||||
else if (seenBases.has(key)) issue = 'dup_file';
|
||||
else if (!isSuperAdmin && product?.user_id !== myUserId) issue = 'forbidden';
|
||||
seenBases.add(key);
|
||||
const hasImage = !!product?.image_url && !product.image_url.includes(PLACEHOLDER_IMAGE_MARK);
|
||||
return { file, base, product, issue, hasImage, state: issue ? 'skip' : 'ready' } as MatchRow;
|
||||
});
|
||||
}
|
||||
|
||||
function isUploadable(row: MatchRow, overwrite: boolean): boolean {
|
||||
if (row.issue || !row.product) return false;
|
||||
if (!overwrite && row.hasImage) return false;
|
||||
return row.state === 'ready' || row.state === 'uploading' || row.state === 'failed';
|
||||
}
|
||||
|
||||
// 특정 파일 행의 상태만 갱신(불변 업데이트).
|
||||
function setRowState(
|
||||
setRows: React.Dispatch<React.SetStateAction<MatchRow[]>>,
|
||||
file: File,
|
||||
patch: Partial<Pick<MatchRow, 'state' | 'reason'>>,
|
||||
) {
|
||||
setRows((prev) => prev.map((r) => (r.file === file ? { ...r, ...patch } : r)));
|
||||
}
|
||||
|
||||
const ISSUE_LABEL: Record<RowIssue, string> = {
|
||||
unmatched: '코드 미매칭',
|
||||
dup_code: '코드 중복',
|
||||
dup_file: '파일명 중복',
|
||||
forbidden: '권한 없음',
|
||||
};
|
||||
|
||||
function renderStatus(row: MatchRow, overwrite: boolean) {
|
||||
if (row.issue) {
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400">
|
||||
{ISSUE_LABEL[row.issue]}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
if (row.state === 'uploading') {
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] inline-flex items-center gap-1 text-muted-foreground">
|
||||
<Loader2 size={10} className="animate-spin" /> 업로드 중
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
if (row.state === 'done') {
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-700 dark:text-emerald-400">
|
||||
완료
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
if (row.state === 'failed') {
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400" title={row.reason}>
|
||||
실패
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
if (!overwrite && row.hasImage) {
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground">
|
||||
이미지 있음 · 건너뜀
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Typography as="span" variant="small" className="text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary">
|
||||
{row.hasImage ? '덮어쓰기' : '업로드 대기'}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { useCompanySettings, useLabels, useHiddenFields } from '@/features/settings/useCompanySettings';
|
||||
import { useCompanySettings, useLabels, useHiddenFields, useVatMode } from '@/features/settings/useCompanySettings';
|
||||
import { CustomFieldInputs, useCustomFieldValues } from '@/features/settings/CustomFieldInputs';
|
||||
import { ItemSuppliersManager } from './ItemSuppliersManager';
|
||||
import { NewItemSuppliersPicker, type PickedSupplier } from './NewItemSuppliersPicker';
|
||||
@@ -141,6 +141,7 @@ export function ProductFormSheet({
|
||||
|
||||
const label = useLabels(); // 회사 설정 용어
|
||||
const isHidden = useHiddenFields();
|
||||
const vatUnified = useVatMode() === 'unified_excluded'; // 부가세 전체 통일(VAT 별도) 회사
|
||||
// 숨김 필드는 DOM 에서 제거하지 않고 감추기만 한다 — 수정 시 기존 값이 그대로 유지·전송되도록.
|
||||
const hideCls = (key: string, base = 'space-y-1') => (isHidden(key) ? `${base} hidden` : base);
|
||||
const hideCls2 = (hidden: boolean, base: string) => (hidden ? `${base} hidden` : base);
|
||||
@@ -178,7 +179,8 @@ export function ProductFormSheet({
|
||||
delivery_type: v.shippingType,
|
||||
moq: v.moq,
|
||||
lead_time: v.leadTime,
|
||||
vat_yn: v.vatYn,
|
||||
// 부가세를 관리하지 않는 회사(전체 통일 모드·숨김)는 값을 쓰지 않는다 — 스위치 기본값(포함)이 몰래 저장되는 것 방지.
|
||||
vat_yn: isHidden('vat_yn') ? undefined : v.vatYn,
|
||||
delivery_fee_yn: v.deliveryFeeYn,
|
||||
internet_lowest_price_yn: v.internetLowestPriceYn,
|
||||
internet_lowest_price: v.minPrice,
|
||||
@@ -293,6 +295,12 @@ export function ProductFormSheet({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 전체 통일 회사는 가격 입력 기준을 폼에서 못 박는다 — 상품별 VAT 입력이 없어 달리 알 길이 없다. */}
|
||||
{vatUnified && (
|
||||
<Typography as="p" variant="caption" className="text-muted-foreground -mb-2">
|
||||
모든 가격은 VAT 별도(제외) 기준으로 입력합니다.
|
||||
</Typography>
|
||||
)}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{/* Price */}
|
||||
<div className={hideCls('price')}>
|
||||
|
||||
@@ -111,6 +111,14 @@ export function ProductTable({
|
||||
cellClassName: 'font-mono font-bold text-foreground',
|
||||
cell: (prod) => `₩${(prod.price || 0).toLocaleString()}`,
|
||||
},
|
||||
{
|
||||
field: 'purchase_price',
|
||||
header: label('item.purchase_price'),
|
||||
align: 'right',
|
||||
cellClassName: 'font-mono font-bold text-foreground',
|
||||
cell: (prod) =>
|
||||
prod.purchase_price != null ? `₩${Number(prod.purchase_price).toLocaleString()}` : '-',
|
||||
},
|
||||
{
|
||||
field: 'internet_lowest_price',
|
||||
header: label('item.internet_lowest_price'),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useListItems, useGetItem } from '@/api/generated/item/item';
|
||||
import { useListSuppliers } from '@/api/generated/supplier/supplier';
|
||||
import { useListCards } from '@/api/generated/card/card';
|
||||
import { mapCardData } from '@/features/cards/types';
|
||||
import { useLabels } from '@/features/settings/useCompanySettings';
|
||||
import { useLabels, useVatMode } from '@/features/settings/useCompanySettings';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Typography, typographyVariants } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -117,6 +117,7 @@ export function QuotationCreateModal({
|
||||
// 선택 상품의 협력사별 공급유형(제조/유통/총판/없음) — 협력사 리스트에 배지로 덧붙인다(리스트 자체는 재조회 안 함).
|
||||
const supplyTypeQuery = useListItemSupplyTypes(productId, { query: { enabled: !!productId } });
|
||||
const label = useLabels(); // 회사 설정 용어(목표 마진 등)
|
||||
const vatUnified = useVatMode() === 'unified_excluded'; // 부가세 전체 통일 — 목표가 입력 기준 안내
|
||||
const supplyTypeBySupplier = useMemo(() => {
|
||||
const m = new Map<string, number>();
|
||||
(supplyTypeQuery.data?.suppliers ?? []).forEach((s) => m.set(s.supplier_id, s.supply_type));
|
||||
@@ -556,6 +557,7 @@ export function QuotationCreateModal({
|
||||
{autoTarget != null
|
||||
? '위에서 선택한 후보값이 목표가(1순위)로 입력됩니다. 수정 가능.'
|
||||
: '자동 산출값이 없어 직접 입력이 필요합니다.'}
|
||||
{vatUnified && ' 금액은 VAT 별도(제외) 기준입니다.'}
|
||||
</Typography>
|
||||
{!targetReady && (
|
||||
<Typography as="p" variant="small" className="text-rose-600 leading-snug">
|
||||
|
||||
@@ -8,12 +8,12 @@ import SlateRenderer from '@/components/SlateRenderer';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { StatusPill, sessionStatusTone } from './StatusPill';
|
||||
import { type Product, type Partner, sessionStatusLabel } from '../../types';
|
||||
import { maskPrices } from '@/lib/utils';
|
||||
import { useCompanySettings } from '@/features/settings/useCompanySettings';
|
||||
import { renderEmphasis } from '@/lib/emphasis';
|
||||
import { renderCardScriptPreview } from '@/features/cards/editor';
|
||||
|
||||
// 협상로그 JSON 다운로드(IMK #9). 가격·비율 숫자는 maskPrices 로 가려 내보낸다(화면 표기와 동일 규칙).
|
||||
// 협상로그 JSON 다운로드(IMK #9). 가격·인하율은 실값 그대로 내보낸다 — 이 탭을 열 수 있는 사람이
|
||||
// 이미 공개 대상(해당 견적 담당자∪최고관리자, 조회 게이팅)뿐이라 마스킹이 하던 차단 역할이 없다.
|
||||
// target_price 등 숫자 필드는 아예 제외 — 양식은 대화 흐름(순번/발화자/스텝/멘트/카드사용) 중심.
|
||||
function exportChatJson(
|
||||
session: SessionData | undefined,
|
||||
@@ -37,7 +37,7 @@ function exportChatJson(
|
||||
seq: m.index,
|
||||
sender: m.sender === ChatSender.BOT ? 'BOT' : 'PARTNER',
|
||||
step: m.step ?? null,
|
||||
script: maskPrices(String(m.script ?? '')),
|
||||
script: String(m.script ?? ''),
|
||||
card: card
|
||||
? {
|
||||
number: card.number ?? null,
|
||||
@@ -153,7 +153,7 @@ export function ChatTab({
|
||||
type="button"
|
||||
onClick={() => exportChatJson(currentSession, currentSupplierName, currentProduct?.name, chatMessages, serverCards)}
|
||||
disabled={chatMessages.length === 0}
|
||||
title="협상로그 JSON 내보내기 (금액 숫자는 가려서 저장)"
|
||||
title="협상로그 JSON 내보내기"
|
||||
className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] font-mono text-muted-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer"
|
||||
>
|
||||
<Download size={11} />
|
||||
@@ -243,7 +243,7 @@ function BotBubble({
|
||||
)}
|
||||
{m.script && !usedCard && (
|
||||
<Typography as="p" variant="small" className="text-xs whitespace-pre-line leading-relaxed text-inherit">
|
||||
{renderEmphasis(maskPrices(m.script))}
|
||||
{renderEmphasis(m.script)}
|
||||
</Typography>
|
||||
)}
|
||||
<UsedCardBox
|
||||
@@ -259,7 +259,7 @@ function BotBubble({
|
||||
);
|
||||
}
|
||||
|
||||
// 협력사(우측) 말풍선. 협력사 입력값을 보여주되, 채팅 '내용'에 제시 금액이 노출되지 않도록 maskPrices 로 가린다.
|
||||
// 협력사(우측) 말풍선. 제시 금액은 실값 그대로 — 열람 가능자가 곧 공개 대상(조회 게이팅)이다.
|
||||
function PartnerBubble({
|
||||
message,
|
||||
currentSupplierName,
|
||||
@@ -288,7 +288,7 @@ function PartnerBubble({
|
||||
)}
|
||||
{m.script && (
|
||||
<Typography as="p" variant="small" className="text-xs whitespace-pre-line leading-relaxed text-inherit">
|
||||
{maskPrices(m.script)}
|
||||
{m.script}
|
||||
</Typography>
|
||||
)}
|
||||
<UsedCardBox
|
||||
@@ -387,7 +387,7 @@ function UsedCardBox({
|
||||
</div>
|
||||
) : usedCard.script ? (
|
||||
<Typography as="p" variant="small" className="mt-1.5 text-xs leading-relaxed whitespace-pre-line text-foreground/85">
|
||||
{renderCardScriptPreview(maskPrices(usedCard.script))}
|
||||
{renderCardScriptPreview(usedCard.script)}
|
||||
</Typography>
|
||||
) : null}
|
||||
|
||||
|
||||
+13
-7
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import { MessageSquare, Copy, Mail, MailCheck, Send, Trophy, ClipboardList, X } from 'lucide-react';
|
||||
import { MessageSquare, Copy, Mail, MailCheck, Send, Trophy, ClipboardList, X, Loader2 } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -141,7 +141,7 @@ export function SessionsStatusTab({
|
||||
}
|
||||
className="flex items-center gap-2 px-3 py-2 bg-primary text-primary-foreground text-xs font-bold rounded hover:opacity-95 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Mail size={14} />
|
||||
{sendingAll ? <Loader2 size={14} className="animate-spin" /> : <Mail size={14} />}
|
||||
<span>{sendingAll ? '발송 중…' : `초청 메일 발송${unsentCount > 0 ? ` (${unsentCount})` : ''}`}</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -296,10 +296,10 @@ export function SessionsStatusTab({
|
||||
<TooltipTrigger render={
|
||||
<button
|
||||
onClick={() => handleOne(sess.session_id, sess.supplier_name, !!sess.email_sent_at)}
|
||||
disabled={!canNotify || sendingId === sess.session_id}
|
||||
disabled={!canNotify || sendingAll || sendingId === sess.session_id}
|
||||
className="p-1 rounded text-primary hover:bg-primary/10 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Send size={12} />
|
||||
{sendingId === sess.session_id ? <Loader2 size={12} className="animate-spin" /> : <Send size={12} />}
|
||||
</button>
|
||||
} />
|
||||
<TooltipContent>
|
||||
@@ -429,14 +429,20 @@ export function SessionsStatusTab({
|
||||
)}
|
||||
<button
|
||||
onClick={() => handleOne(sess.session_id, sess.supplier_name, !!sess.email_sent_at)}
|
||||
disabled={!canNotify || sendingId === sess.session_id}
|
||||
disabled={!canNotify || sendingAll || sendingId === sess.session_id}
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed',
|
||||
sess.email_sent_at ? 'text-success' : 'text-primary',
|
||||
)}
|
||||
>
|
||||
{sess.email_sent_at ? <MailCheck size={12} /> : <Mail size={12} />}
|
||||
{sess.email_sent_at ? '메일 재발송' : '메일 발송'}
|
||||
{sendingId === sess.session_id ? (
|
||||
<Loader2 size={12} className="animate-spin" />
|
||||
) : sess.email_sent_at ? (
|
||||
<MailCheck size={12} />
|
||||
) : (
|
||||
<Mail size={12} />
|
||||
)}
|
||||
{sendingId === sess.session_id ? '발송 중…' : sess.email_sent_at ? '메일 재발송' : '메일 발송'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
+4
-2
@@ -2,7 +2,7 @@ import { X, Check } from 'lucide-react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { useGetTargetBreakdown } from '@/api/generated/quotation/quotation';
|
||||
import { useScrollLock } from '@/lib/useScrollLock';
|
||||
import { useLabels } from '@/features/settings/useCompanySettings';
|
||||
import { useLabels, useVatMode } from '@/features/settings/useCompanySettings';
|
||||
|
||||
// 세션 목표가 산정내역 모달. 후보·채택·앵커링가는 백엔드 /target-breakdown 이 산정한 값을 '표시만' 한다.
|
||||
// (프론트 재계산 없음 → 저장된 목표가와 항상 일치. 산정 로직은 백엔드 _candidates 단일 출처.)
|
||||
@@ -39,6 +39,8 @@ export function TargetPriceModal({
|
||||
}: TargetPriceModalProps) {
|
||||
useScrollLock(); // 모달은 열릴 때만 마운트(부모 게이트) → 배경 스크롤 잠금
|
||||
const label = useLabels(); // 회사 설정 용어
|
||||
// 부가세 전체 통일 회사는 상품 vat_yn 잔존값과 무관하게 'VAT별도' 고정.
|
||||
const vatUnified = useVatMode() === 'unified_excluded';
|
||||
const CANDIDATE_SUB = candidateSub(`${label('target_margin')}`);
|
||||
const { data: bd, isLoading } = useGetTargetBreakdown(sessionId, { query: { enabled: !!sessionId } });
|
||||
const candidates = bd?.candidates ?? [];
|
||||
@@ -64,7 +66,7 @@ export function TargetPriceModal({
|
||||
견적번호: {qtNumber} · 상품: {itemName}
|
||||
</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] font-semibold text-rose-500 mt-1">
|
||||
배송비: {deliveryFeeYn ? '배송비포함' : '배송비별도'} · 부가세: {vatYn ? 'VAT포함' : 'VAT별도'}
|
||||
배송비: {deliveryFeeYn ? '배송비포함' : '배송비별도'} · 부가세: {!vatUnified && vatYn ? 'VAT포함' : 'VAT별도'}
|
||||
</Typography>
|
||||
|
||||
{isLoading || !bd ? (
|
||||
|
||||
@@ -180,7 +180,9 @@ export function QuotationTable({ data, products, onOpenDetail, onFilterChain, se
|
||||
},
|
||||
{
|
||||
header: '생성일',
|
||||
cellClassName: 'font-mono text-muted-foreground whitespace-nowrap',
|
||||
// 10컬럼 표라 좁은 데스크톱(xl~2xl)에선 부차 정보인 생성일을 접어 가로 스크롤을 줄인다.
|
||||
headClassName: 'hidden 2xl:table-cell',
|
||||
cellClassName: 'hidden 2xl:table-cell font-mono text-muted-foreground whitespace-nowrap',
|
||||
cell: (est) => (
|
||||
<Typography as="span" variant="small" className="text-xs text-inherit">{est.createdDate ?? '-'}</Typography>
|
||||
),
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { Fragment, useEffect, useMemo, useRef, useState, type ElementType } from 'react';
|
||||
import { useSearchParams } from 'react-router';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Palette, Tags, ListPlus, MessageSquareText, 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';
|
||||
import ImageDropzone from '@/components/ImageDropzone';
|
||||
import { uploadItemImage } from '@/api/generated/item/item';
|
||||
import { previewInviteEmail } from '@/api/generated/company-settings/company-settings';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||
@@ -19,6 +21,8 @@ import {
|
||||
DEFAULT_GUIDE_NOTICES,
|
||||
NEGO_BASELINE_OPTIONS,
|
||||
DEFAULT_NEGO_BASELINE_FIELD,
|
||||
VAT_MODE_OPTIONS,
|
||||
DEFAULT_VAT_MODE,
|
||||
type CompanySettings,
|
||||
type CustomFieldDef,
|
||||
type CustomFieldType,
|
||||
@@ -48,6 +52,12 @@ const SETTINGS_TAB_ICON: Record<SettingsTab, ElementType> = {
|
||||
fields: ListPlus,
|
||||
};
|
||||
|
||||
// branding 의 문자열 서브키(helpdesk 만 배열이라 제외). email_* 는 협상 초청 메일 커스텀.
|
||||
type BrandingTextKey =
|
||||
| 'service_name'
|
||||
| 'logo_url'
|
||||
| 'email_greeting';
|
||||
|
||||
export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly SettingsTab[] }) {
|
||||
const { settings, isLoading, save } = useCompanySettings();
|
||||
|
||||
@@ -141,7 +151,7 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
return res.image_url;
|
||||
};
|
||||
|
||||
const setBranding = (key: 'service_name' | 'logo_url' | 'primary_color' | 'email_header', value: string) =>
|
||||
const setBranding = (key: BrandingTextKey, value: string) =>
|
||||
setDraft((d) => ({ ...d, branding: { ...d.branding, [key]: value } }));
|
||||
const setHelpdesk = (lines: string[]) =>
|
||||
setDraft((d) => ({ ...d, branding: { ...d.branding, helpdesk: lines } }));
|
||||
@@ -197,7 +207,7 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
<TabsContent value="branding" className="space-y-4">
|
||||
<SectionCard
|
||||
title="서비스 브랜딩"
|
||||
desc="사이드바·타이틀에 노출되는 서비스명과 로고입니다. 비워두면 기본 브랜드(NegoData)가 사용됩니다."
|
||||
desc="회사 CI 입니다. 사이드바·타이틀은 물론 공급사 포털(로그인·버튼)과 협상 초청 메일에도 그대로 적용됩니다. 비워두면 기본 브랜드(NegoData)가 사용됩니다."
|
||||
>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field label="서비스명" hint="예: iMarketKorea 구매협상 콘솔">
|
||||
@@ -229,16 +239,32 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
{draft.branding?.logo_url ? (
|
||||
<img src={draft.branding.logo_url} alt="로고 미리보기" className="h-4 max-w-24 object-contain" />
|
||||
) : (
|
||||
<span
|
||||
aria-hidden
|
||||
className="size-4 rounded-[5px]"
|
||||
style={{ backgroundColor: draft.branding?.primary_color || 'var(--primary)' }}
|
||||
/>
|
||||
<span aria-hidden className="size-4 rounded-[5px] bg-primary" />
|
||||
)}
|
||||
{draft.branding?.service_name || 'NegoData'}
|
||||
</div>
|
||||
</div>
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard
|
||||
title="협상 초청 메일"
|
||||
desc="공급사 담당자에게 발송되는 협상 초청 메일입니다. 로고·회사명·색은 위 서비스 브랜딩(CI)을 그대로 따르고, 메일에서 바꿀 수 있는 건 인사 문구뿐입니다. 레이아웃은 고정이라 어떤 메일 앱에서도 깨지지 않습니다."
|
||||
>
|
||||
<div className="grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_540px] gap-6">
|
||||
<div className="space-y-4">
|
||||
<Field label="인사 문구" hint="'OO 담당자님,' 다음 줄에 들어갑니다.">
|
||||
<textarea
|
||||
rows={2}
|
||||
className="w-full p-2 bg-background border border-border rounded text-xs resize-none"
|
||||
value={draft.branding?.email_greeting ?? ''}
|
||||
onChange={(e) => setBranding('email_greeting', e.target.value)}
|
||||
placeholder="아래 견적 건의 협상에 참여해 주세요. (기본값)"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<InviteEmailPreview branding={draft.branding} />
|
||||
</div>
|
||||
</SectionCard>
|
||||
</TabsContent>
|
||||
|
||||
{/* ---- 공급사 포털 안내 ---- */}
|
||||
@@ -265,7 +291,7 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
<LineListEditor
|
||||
lines={draft.branding?.helpdesk ?? []}
|
||||
onChange={setHelpdesk}
|
||||
placeholder="김건우P 02-3708-5832 kw086.kim@imarketkorea.com"
|
||||
placeholder="홍길동P 02-0000-0000 helpdesk@example.com"
|
||||
addLabel="연락처 추가"
|
||||
emptyHint="등록된 연락처가 없습니다. 공급사 포털에 연락처 영역이 표시되지 않습니다."
|
||||
/>
|
||||
@@ -331,7 +357,7 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
<TabsContent value="fields" className="space-y-4">
|
||||
<SectionCard
|
||||
title="협상 기준가"
|
||||
desc="협상 중 '기존 OO 대비 N% 인하' 를 계산하는 기준 가격입니다. 우리 회사가 공급사에 실제로 지불 중인 단가를 고르십시오."
|
||||
desc="협상 중 '기존 공급가 대비 N% 인하' 를 계산하는 기준 가격입니다. 우리 회사가 공급사에 실제로 지불 중인 단가를 고르십시오. 공급사 화면 표기는 어느 필드를 고르든 '공급가'로 고정됩니다."
|
||||
>
|
||||
<NegoBaselinePicker
|
||||
value={draft.features?.nego_baseline_field ?? DEFAULT_NEGO_BASELINE_FIELD}
|
||||
@@ -343,6 +369,43 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
/>
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard
|
||||
title="부가세(VAT) 관리"
|
||||
desc="가격 정보의 부가세 기준입니다. 전체 통일을 선택하면 상품별 부가세 입력이 폼·엑셀 양식에서 사라지고, 공급사 협상 화면 가격에 'VAT 별도'가 항상 표기됩니다. DB 컬럼과 기존 값은 그대로 남습니다."
|
||||
>
|
||||
<div className="space-y-2">
|
||||
{VAT_MODE_OPTIONS.map((opt) => {
|
||||
const selected = (draft.features?.vat_mode ?? DEFAULT_VAT_MODE) === opt.value;
|
||||
return (
|
||||
<label
|
||||
key={opt.value}
|
||||
className={`flex items-start gap-2.5 p-3 rounded-md border cursor-pointer ${
|
||||
selected ? 'border-primary bg-primary/5' : 'border-border'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="vat_mode"
|
||||
className="mt-1"
|
||||
checked={selected}
|
||||
onChange={() =>
|
||||
setDraft((d) => ({ ...d, features: { ...d.features, vat_mode: opt.value } }))
|
||||
}
|
||||
/>
|
||||
<span className="min-w-0 space-y-1">
|
||||
<Typography as="span" variant="small" className="block font-semibold">
|
||||
{opt.label}
|
||||
</Typography>
|
||||
<Typography as="span" variant="caption" className="block text-muted-foreground">
|
||||
{opt.desc}
|
||||
</Typography>
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard
|
||||
title="상품 필드 숨김"
|
||||
desc="체크한 항목은 상품 목록·등록 폼·엑셀 양식에서 감춰집니다. DB 컬럼과 기존 값은 그대로 남습니다."
|
||||
@@ -350,12 +413,23 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-2">
|
||||
{HIDEABLE_ITEM_FIELDS.map((f) => {
|
||||
const checked = (draft.hidden_fields ?? []).includes(f.key);
|
||||
// 협상 기준가로 지정된 필드는 숨김 금지(강제) — 입력 화면이 사라지면 신규 상품의
|
||||
// 기준값이 NULL 로 쌓여 인하율 멘트가 통째로 빠진다. 이미 숨겨진 상태면 해제만 허용.
|
||||
const baselineLocked =
|
||||
f.key === (draft.features?.nego_baseline_field ?? DEFAULT_NEGO_BASELINE_FIELD) &&
|
||||
!checked;
|
||||
return (
|
||||
<label key={f.key} className="flex items-start gap-2 py-1 cursor-pointer">
|
||||
<label
|
||||
key={f.key}
|
||||
className={`flex items-start gap-2 py-1 ${
|
||||
baselineLocked ? 'cursor-not-allowed opacity-60' : 'cursor-pointer'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="mt-0.5"
|
||||
checked={checked}
|
||||
disabled={baselineLocked}
|
||||
onChange={(e) =>
|
||||
setDraft((d) => {
|
||||
const cur = new Set(d.hidden_fields ?? []);
|
||||
@@ -372,6 +446,11 @@ export function SettingsView({ tabs = SETTINGS_TABS }: { tabs?: readonly Setting
|
||||
<Typography as="span" variant="caption" className="block text-muted-foreground">
|
||||
{f.where}
|
||||
</Typography>
|
||||
{baselineLocked && (
|
||||
<Typography as="span" variant="caption" className="block text-amber-600">
|
||||
⚠ 협상 기준가로 지정된 필드는 숨길 수 없습니다
|
||||
</Typography>
|
||||
)}
|
||||
{f.calcNote && (
|
||||
<Typography as="span" variant="caption" className="block text-amber-600">
|
||||
⚠ {f.calcNote}
|
||||
@@ -484,9 +563,6 @@ function NegoBaselinePicker({
|
||||
<Typography as="span" variant="caption" className="block text-muted-foreground">
|
||||
{opt.desc}
|
||||
</Typography>
|
||||
<Typography as="span" variant="caption" className="block text-muted-foreground">
|
||||
협상 멘트 — 기존 {phrase} 대비 약 3.2% 인하된 금액입니다.
|
||||
</Typography>
|
||||
{selected && hiddenFields.includes(opt.value) && (
|
||||
<Typography as="span" variant="caption" className="block text-amber-600">
|
||||
⚠ 이 필드를 아래에서 숨김 처리했습니다. 값을 입력할 화면이 없어 신규 상품은 기준가가 비어
|
||||
@@ -497,6 +573,10 @@ function NegoBaselinePicker({
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
<Typography variant="caption" className="block text-muted-foreground">
|
||||
협상 멘트(공급사 화면) — 기존 공급가 대비 약 3.2% 인하된 금액입니다. 여기서 고른 필드는 계산에 쓰는
|
||||
값만 정하고, 공급사에게 보이는 호칭은 항상 ‘공급가’입니다.
|
||||
</Typography>
|
||||
<Typography variant="caption" className="block text-amber-600">
|
||||
⚠ 이미 협상을 진행한 회사가 이 값을 바꾸면 가격 수용률 기준이 달라져, 기존 학습분과 이후 데이터가
|
||||
섞입니다. 협상 시작 전에 정하십시오. (진행 중인 협상은 시작 시점 기준을 그대로 유지합니다)
|
||||
@@ -588,6 +668,60 @@ function Field({ label, hint, children }: { label: string; hint?: string; childr
|
||||
);
|
||||
}
|
||||
|
||||
// 초청 메일 미리보기 — 실제 발송과 같은 백엔드 템플릿을 샘플 견적으로 렌더해 iframe 에 띄운다.
|
||||
// 입력 중 매 타자마다 서버를 부르지 않도록 디바운스하고, 갱신 사이엔 직전 렌더를 유지해 깜빡임을 없앤다.
|
||||
function InviteEmailPreview({ branding }: { branding?: CompanySettings['branding'] }) {
|
||||
// 메일 헤더는 회사 CI(로고·서비스명)를 그대로 쓰므로 CI 편집값을 같이 보낸다(미리보기 = 실발송). 색은 솔루션 고정.
|
||||
const emailBranding = JSON.stringify({
|
||||
service_name: branding?.service_name ?? '',
|
||||
logo_url: branding?.logo_url ?? '',
|
||||
email_greeting: branding?.email_greeting ?? '',
|
||||
});
|
||||
const debounced = useDebounced(emailBranding, 400);
|
||||
const { data, isError } = useQuery({
|
||||
queryKey: ['invite-email-preview', debounced],
|
||||
queryFn: () => previewInviteEmail({ branding: JSON.parse(debounced) }),
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
return (
|
||||
<div className="min-w-0 space-y-2">
|
||||
<Typography variant="muted" className="text-[10px] block">
|
||||
미리보기 — 실제 발송 템플릿을 샘플 견적으로 렌더한 것입니다.
|
||||
</Typography>
|
||||
<div className="border border-border rounded-md overflow-hidden">
|
||||
<div className="border-b border-border bg-background px-3 py-2">
|
||||
<Typography variant="caption" className="block text-muted-foreground">제목</Typography>
|
||||
<Typography variant="small" className="block font-semibold truncate">
|
||||
{data?.subject || '미리보기를 불러오는 중...'}
|
||||
</Typography>
|
||||
</div>
|
||||
{isError ? (
|
||||
<Typography variant="muted" className="block p-6 text-center">
|
||||
미리보기를 불러오지 못했습니다. 잠시 후 다시 시도하십시오.
|
||||
</Typography>
|
||||
) : (
|
||||
<iframe
|
||||
title="협상 초청 메일 미리보기"
|
||||
srcDoc={data?.html ?? ''}
|
||||
sandbox=""
|
||||
className="w-full h-[600px] bg-[#f4f5f7]"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 값이 delayMs 동안 잠잠해진 뒤에만 반영되는 디바운스 훅(미리보기 서버호출 절약용).
|
||||
function useDebounced(value: string, delayMs: number): string {
|
||||
const [debounced, setDebounced] = useState(value);
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setDebounced(value), delayMs);
|
||||
return () => clearTimeout(t);
|
||||
}, [value, delayMs]);
|
||||
return debounced;
|
||||
}
|
||||
|
||||
// 커스텀필드 정의 편집 — 표시명을 입력하면 key 를 자동 제안하되 직접 수정도 가능.
|
||||
function CustomFieldsEditor({
|
||||
title,
|
||||
|
||||
@@ -5,6 +5,8 @@ export type CustomFieldType = 'text' | 'number' | 'boolean' | 'select';
|
||||
|
||||
export type NegoBaselineField = 'price' | 'purchase_price';
|
||||
|
||||
export type VatMode = 'per_item' | 'unified_excluded';
|
||||
|
||||
export type CustomFieldDef = {
|
||||
key: string; // custom JSONB 의 키 (영문 snake_case)
|
||||
label: string; // 화면 표시명
|
||||
@@ -16,8 +18,7 @@ export type CompanySettings = {
|
||||
branding?: {
|
||||
service_name?: string; // 사이드바/타이틀 서비스명 (기본 NegoData)
|
||||
logo_url?: string; // 로고 이미지 URL. 없으면 색상 사각형+텍스트
|
||||
primary_color?: string; // 브랜드 색 (hex)
|
||||
email_header?: string; // 초청 메일 헤더 문구 (기본 NEGODATA)
|
||||
email_greeting?: string; // 초청 메일 인사 문구 ('OO 담당자님,' 다음 줄). 메일 헤더는 CI(logo_url·service_name)를 따르고 색은 솔루션 고정
|
||||
helpdesk?: string[]; // 헬프데스크 연락처 — 한 줄 = 담당자 한 명. 공급사 포털 3곳(로그인·메뉴·안내팝업)이 그대로 출력
|
||||
};
|
||||
labels?: Record<string, string>; // 카탈로그 키 → 이 회사 용어 (없으면 기본값)
|
||||
@@ -25,6 +26,9 @@ export type CompanySettings = {
|
||||
// 협상 기준가로 쓸 상품 가격 컬럼. 인하율 멘트의 분모이자 RL 가격 수용률의 기준가다.
|
||||
// 미설정이면 공급가(price) — 단 공급가를 숨긴 회사는 매입가로 폴백(협상 엔진).
|
||||
nego_baseline_field?: NegoBaselineField;
|
||||
// 부가세 관리 방식. 미설정=상품별(per_item). 전체 통일(unified_excluded)이면 상품 VAT 입력을
|
||||
// 숨기고(폼·엑셀) 공급사 협상 화면 가격에 'VAT 별도'를 고정 표기한다(협상 백엔드 chat_service).
|
||||
vat_mode?: VatMode;
|
||||
[key: string]: unknown; // 그 밖의 회사별 동작 플래그
|
||||
};
|
||||
guide_notices?: string[]; // 공급사 포털 협상 유의사항 항목 — 한 줄 = 안내 한 항목. 비면 기본 문구
|
||||
@@ -45,7 +49,7 @@ export type HideableFieldEntry = {
|
||||
|
||||
export const HIDEABLE_ITEM_FIELDS: HideableFieldEntry[] = [
|
||||
{ key: 'made_in', label: '원산지(제조 국가)', where: '상품 등록, 엑셀 양식' },
|
||||
{ key: 'vat_yn', label: '부가세포함', where: '상품 등록, 엑셀 양식' },
|
||||
// vat_yn 은 숨김 목록에서 뺐다 — 부가세는 '부가세(VAT) 관리' 모드(features.vat_mode)로 관리한다.
|
||||
{ key: 'delivery_fee_yn', label: '배송비포함', where: '상품 등록, 엑셀 양식' },
|
||||
{ key: 'spec', label: '규격', where: '상품 등록, 엑셀 양식' },
|
||||
{ key: 'manufacturer', label: '제조사', where: '상품 등록, 엑셀 양식' },
|
||||
@@ -69,7 +73,6 @@ export const HIDEABLE_ITEM_FIELDS: HideableFieldEntry[] = [
|
||||
key: 'price',
|
||||
label: '상품 단가(공급가)',
|
||||
where: '상품 목록·등록, 엑셀 양식',
|
||||
calcNote: '협상 기준가로 고른 경우 숨기지 말 것 — 인하율 멘트의 기준값이 비게 된다',
|
||||
},
|
||||
];
|
||||
// internet_lowest_price 는 숨김 대상에서 뺀다 — 신규 견적의 유일한 목표가 후보라
|
||||
@@ -89,7 +92,8 @@ export const LABEL_CATALOG: LabelCatalogEntry[] = [
|
||||
{ key: 'item.code', base: '상품코드', where: '상품 목록·등록, 엑셀 양식', group: '상품' },
|
||||
{ key: 'item.model_name', base: '모델번호', where: '상품 등록, 엑셀 양식', group: '상품' },
|
||||
{ key: 'category', base: '카테고리', where: '상품 목록·등록·필터, 통계', group: '상품' },
|
||||
{ key: 'item.price', base: '상품 단가', where: '상품 목록·등록, 엑셀 양식', group: '상품' },
|
||||
// 관리자 화면 전용 — 공급사 화면(포털·협상 멘트)의 기준가 표기는 '공급가'로 고정이라 이 용어를 타지 않는다.
|
||||
{ key: 'item.price', base: '상품 단가', where: '상품 목록·등록, 엑셀 양식 (관리자 화면 전용)', group: '상품' },
|
||||
{ key: 'item.purchase_price', base: '매입가', where: '상품 등록, 엑셀 양식', group: '상품' },
|
||||
{ key: 'item.selling_price', base: '판매가', where: '상품 등록, 엑셀 양식', group: '상품' },
|
||||
{ key: 'item.internet_lowest_price', base: '인터넷 최저가', where: '상품 목록·등록, 엑셀 양식', group: '상품' },
|
||||
@@ -155,6 +159,23 @@ export const NEGO_BASELINE_OPTIONS: {
|
||||
|
||||
export const DEFAULT_NEGO_BASELINE_FIELD: NegoBaselineField = 'price';
|
||||
|
||||
export const DEFAULT_VAT_MODE: VatMode = 'per_item';
|
||||
|
||||
// 부가세 관리 모드 선택지. 전체 통일은 'VAT 별도(제외)' 고정만 둔다 — 포함으로 통일하려는
|
||||
// 회사가 나오면 값을 추가한다(지금 만들면 안 쓰는 분기만 는다).
|
||||
export const VAT_MODE_OPTIONS: { value: VatMode; label: string; desc: string }[] = [
|
||||
{
|
||||
value: 'per_item',
|
||||
label: '상품별 관리',
|
||||
desc: '상품마다 부가세 포함 여부를 입력합니다. 공급사 협상 화면에는 상품에 입력된 값대로 VAT 포함/별도가 표기됩니다.',
|
||||
},
|
||||
{
|
||||
value: 'unified_excluded',
|
||||
label: '전체 통일 — VAT 별도(제외)',
|
||||
desc: '모든 가격을 VAT 제외 기준으로 통일합니다. 상품 등록·엑셀 양식에서 부가세 입력이 사라지고, 공급사 협상 화면 가격에는 항상 "VAT 별도"가 표기됩니다.',
|
||||
},
|
||||
];
|
||||
|
||||
// 공급사 포털 협상 유의사항 기본 문구. 설정이 비어 있을 때 포털이 쓰는 값과 같아야 한다
|
||||
// (포털 사본: frontend/src/features/chat/components/popup/GuideContent.tsx).
|
||||
// VAT·배송비 조건은 상품마다 달라 기본 문구에서 뺐다 — 필요한 회사가 항목으로 직접 넣는다.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useGetSettings, updateSettings, getGetSettingsQueryKey } from '@/api/generated/company-settings/company-settings';
|
||||
import { LABEL_DEFAULTS, type CompanySettings } from './catalog';
|
||||
import { LABEL_DEFAULTS, DEFAULT_VAT_MODE, type CompanySettings, type VatMode } from './catalog';
|
||||
|
||||
// 회사 커스터마이징 설정 조회 + 저장.
|
||||
// 조회는 전 유저(브랜딩/라벨 렌더용), 저장은 백엔드가 OWNER 로 게이트한다.
|
||||
@@ -26,18 +26,26 @@ export function useLabels() {
|
||||
}
|
||||
|
||||
// 숨김필드 헬퍼. isHidden('made_in') → 이 회사에서 감출 필드인지.
|
||||
// 부가세 전체 통일(features.vat_mode) 회사는 상품별 VAT 입력이 무의미하므로 vat_yn 을 숨김으로 친다 —
|
||||
// 상품 폼·엑셀 양식·데이터 내보내기가 이 헬퍼 하나를 읽어 함께 사라진다.
|
||||
export function useHiddenFields() {
|
||||
const { settings } = useCompanySettings();
|
||||
const hidden = settings.hidden_fields ?? [];
|
||||
return (key: string): boolean => hidden.includes(key);
|
||||
const vatUnified = settings.features?.vat_mode === 'unified_excluded';
|
||||
return (key: string): boolean => hidden.includes(key) || (vatUnified && key === 'vat_yn');
|
||||
}
|
||||
|
||||
// 브랜딩 헬퍼. 서비스명·로고 — 미설정 시 기본 브랜드(NegoData).
|
||||
// 부가세 관리 모드 헬퍼. 미설정이면 상품별(per_item).
|
||||
export function useVatMode(): VatMode {
|
||||
const { settings } = useCompanySettings();
|
||||
return settings.features?.vat_mode ?? DEFAULT_VAT_MODE;
|
||||
}
|
||||
|
||||
// 브랜딩 헬퍼. 서비스명·로고 — 미설정 시 기본 브랜드(NegoData). 색은 회사별 커스텀 없이 솔루션 고정.
|
||||
export function useBranding() {
|
||||
const { settings } = useCompanySettings();
|
||||
return {
|
||||
serviceName: settings.branding?.service_name || 'NegoData',
|
||||
logoUrl: settings.branding?.logo_url || null,
|
||||
primaryColor: settings.branding?.primary_color || null,
|
||||
};
|
||||
}
|
||||
@@ -23,8 +23,9 @@ export function StatisticsView({ data }: { data: StatData }) {
|
||||
const markupTrend = fillMonths(data.markupTrend, (month) => ({ month, rate: 0 }));
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* 임팩트 요약 KPI */}
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6">
|
||||
{/* 임팩트 요약 KPI — 6열은 초광폭(2xl)에서만. xl 구간은 사이드바 빼면 타일이 ~170px 로 눌려
|
||||
라벨·증감칩이 여러 줄로 깨진다 → 3열 유지. */}
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 2xl:grid-cols-6">
|
||||
<StatTile
|
||||
label="총 절감액 (목표가 대비)"
|
||||
value={wonCompact(k.totalSavings)}
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Upload, TrendingDown, Download, FileDown, FileSpreadsheet, ChevronDown, Trash2 } from 'lucide-react';
|
||||
import { Plus, Upload, TrendingDown, Download, FileDown, FileSpreadsheet, ChevronDown, Trash2, ImagePlus } from 'lucide-react';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
@@ -18,6 +18,7 @@ import { ProductFormSheet } from '@/features/products/components/ProductFormShee
|
||||
import { PriceUpdateModal } from '@/features/products/components/PriceUpdateModal';
|
||||
import { LowestPriceHistorySheet } from '@/features/products/components/LowestPriceHistorySheet';
|
||||
import { ExcelUploadModal, downloadProductTemplate, downloadProductData } from '@/features/products/components/ExcelUploadModal';
|
||||
import { ImageBulkUploadModal } from '@/features/products/components/ImageBulkUploadModal';
|
||||
import { type Product } from '@/features/products/types';
|
||||
|
||||
export default function ProductsPage() {
|
||||
@@ -135,24 +136,29 @@ export default function ProductsPage() {
|
||||
{selectedIds.length > 0 && <Badge variant="destructive">{selectedIds.length}</Badge>}
|
||||
</Button>
|
||||
|
||||
{/* 엑셀 3종 + 이미지 일괄이 한 메뉴에 있어 버튼명은 '일괄 작업'으로 포괄, 항목에서 엑셀/이미지를 명시한다. */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger render={<Button variant="outline" />}>
|
||||
<FileSpreadsheet />
|
||||
엑셀업로드
|
||||
일괄 작업
|
||||
<ChevronDown />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem onClick={() => overlay.open('modal', 'excel')}>
|
||||
<Upload />
|
||||
일괄 업로드
|
||||
엑셀 일괄 업로드
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => downloadProductTemplate(label, settings.item_fields ?? [], isHidden)}>
|
||||
<Download />
|
||||
양식 다운로드
|
||||
엑셀 양식 다운로드
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleExport}>
|
||||
<FileDown />
|
||||
데이터 다운로드
|
||||
엑셀 데이터 다운로드
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => overlay.open('modal', 'images')}>
|
||||
<ImagePlus />
|
||||
이미지 일괄 업로드
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
@@ -242,6 +248,10 @@ export default function ProductsPage() {
|
||||
onClose={overlay.close}
|
||||
/>
|
||||
)}
|
||||
|
||||
{modal === 'images' && (
|
||||
<ImageBulkUploadModal open loadProducts={fetchAllForExport} onClose={overlay.close} />
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
@@ -30,11 +30,13 @@ export default function QuotationPage() {
|
||||
const mineFilter = list.filters.mine;
|
||||
const statusOptions = QUOTATION_STATUS_OPTIONS;
|
||||
const typeOptions = QUOTATION_TYPE_OPTIONS;
|
||||
// 일반(USER)은 본인 견적만 조회 — 작성자 필터를 숨기고 mine 을 고정한다(백엔드도 동일하게 강제).
|
||||
const isManager = useAuthStore((s) => canManage(s.user?.role));
|
||||
const params: ListQuotationsParams = {
|
||||
search: list.debouncedSearch || undefined,
|
||||
status: statusFilter !== 'ALL' ? statusFilter : undefined,
|
||||
type: typeFilter !== 'ALL' ? typeFilter : undefined,
|
||||
mine: mineFilter === 'MINE' ? true : undefined,
|
||||
mine: !isManager || mineFilter === 'MINE' ? true : undefined,
|
||||
page: list.page,
|
||||
size: list.pageSize,
|
||||
};
|
||||
@@ -159,18 +161,20 @@ export default function QuotationPage() {
|
||||
placeholder="견적명 또는 견적 번호로 검색..."
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<Select value={mineFilter} onValueChange={(v) => list.setFilter('mine', v as string)}>
|
||||
<SelectTrigger id="quotation-mine-filter">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'MINE' ? '내 견적' : '전체 작성자 견적')}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">전체 작성자 견적</SelectItem>
|
||||
<SelectItem value="MINE">내 견적</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className={`grid gap-2 ${isManager ? 'grid-cols-3' : 'grid-cols-2'}`}>
|
||||
{isManager && (
|
||||
<Select value={mineFilter} onValueChange={(v) => list.setFilter('mine', v as string)}>
|
||||
<SelectTrigger id="quotation-mine-filter">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'MINE' ? '내 견적' : '전체 작성자 견적')}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">전체 작성자 견적</SelectItem>
|
||||
<SelectItem value="MINE">내 견적</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
|
||||
<Select value={statusFilter} onValueChange={(v) => list.setFilter('status', v as string)}>
|
||||
<SelectTrigger id="quotation-status-filter">
|
||||
|
||||
Reference in new issue
Block a user