|
|
|
|
@@ -15,7 +15,7 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { usePathname, useRouter } from 'next/navigation';
|
|
|
|
|
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
|
|
|
import {
|
|
|
|
|
FileText, // 견적
|
|
|
|
|
ClipboardList, // 수주
|
|
|
|
|
@@ -40,7 +40,7 @@ import { Button } from '@/components/ui/button';
|
|
|
|
|
import { Badge } from '@/components/ui/badge';
|
|
|
|
|
import { useDevFillContext, type DevFillPageType } from './DevFillContext';
|
|
|
|
|
|
|
|
|
|
// 페이지 경로와 타입 매핑
|
|
|
|
|
// 페이지 경로와 타입 매핑 (pathname만으로 매칭되는 패턴)
|
|
|
|
|
const PAGE_PATTERNS: { pattern: RegExp; type: DevFillPageType; label: string }[] = [
|
|
|
|
|
// 판매/생산 플로우
|
|
|
|
|
{ pattern: /\/quote-management\/new/, type: 'quote', label: '견적' },
|
|
|
|
|
@@ -52,15 +52,19 @@ const PAGE_PATTERNS: { pattern: RegExp; type: DevFillPageType; label: string }[]
|
|
|
|
|
{ pattern: /\/work-orders\/\d+$/, type: 'workOrderComplete', label: '작업완료' },
|
|
|
|
|
{ pattern: /\/shipments\/new/, type: 'shipment', label: '출하' },
|
|
|
|
|
{ pattern: /\/shipments\/\d+\/edit/, type: 'shipment', label: '출하' },
|
|
|
|
|
// 회계 플로우
|
|
|
|
|
{ pattern: /\/accounting\/deposits\/new/, type: 'deposit', label: '입금' },
|
|
|
|
|
{ pattern: /\/accounting\/withdrawals\/new/, type: 'withdrawal', label: '출금' },
|
|
|
|
|
// 회계 플로우 (mode=new 사용하는 페이지는 아래 MODE_NEW_PAGES에서 처리)
|
|
|
|
|
{ pattern: /\/approval\/draft\/new/, type: 'purchaseApproval', label: '매입' },
|
|
|
|
|
{ pattern: /\/accounting\/card-transactions\/new/, type: 'cardTransaction', label: '카드' },
|
|
|
|
|
// 기준정보
|
|
|
|
|
{ pattern: /\/client-management-sales-admin\/new/, type: 'client', label: '거래처' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// ?mode=new 쿼리 파라미터를 사용하는 페이지 매핑
|
|
|
|
|
const MODE_NEW_PAGES: { pattern: RegExp; type: DevFillPageType; label: string }[] = [
|
|
|
|
|
{ pattern: /\/accounting\/deposits$/, type: 'deposit', label: '입금' },
|
|
|
|
|
{ pattern: /\/accounting\/withdrawals$/, type: 'withdrawal', label: '출금' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 플로우 단계 정의
|
|
|
|
|
const FLOW_STEPS: { type: DevFillPageType; label: string; icon: typeof FileText; path: string }[] = [
|
|
|
|
|
{ type: 'quote', label: '견적', icon: FileText, path: '/sales/quote-management/new' },
|
|
|
|
|
@@ -72,8 +76,8 @@ const FLOW_STEPS: { type: DevFillPageType; label: string; icon: typeof FileText;
|
|
|
|
|
|
|
|
|
|
// 회계 단계 정의
|
|
|
|
|
const ACCOUNTING_STEPS: { type: DevFillPageType; label: string; icon: typeof FileText; path: string; fillEnabled: boolean }[] = [
|
|
|
|
|
{ type: 'deposit', label: '입금', icon: ArrowDownToLine, path: '/accounting/deposits/new', fillEnabled: true },
|
|
|
|
|
{ type: 'withdrawal', label: '출금', icon: ArrowUpFromLine, path: '/accounting/withdrawals/new', fillEnabled: true },
|
|
|
|
|
{ type: 'deposit', label: '입금', icon: ArrowDownToLine, path: '/accounting/deposits?mode=new', fillEnabled: true },
|
|
|
|
|
{ type: 'withdrawal', label: '출금', icon: ArrowUpFromLine, path: '/accounting/withdrawals?mode=new', fillEnabled: true },
|
|
|
|
|
{ type: 'purchaseApproval', label: '매입', icon: Receipt, path: '/approval/draft/new', fillEnabled: true },
|
|
|
|
|
{ type: 'cardTransaction', label: '카드', icon: CreditCard, path: '/accounting/card-transactions/new', fillEnabled: true },
|
|
|
|
|
];
|
|
|
|
|
@@ -86,6 +90,7 @@ const MASTER_DATA_STEPS: { type: DevFillPageType; label: string; icon: typeof Fi
|
|
|
|
|
export function DevToolbar() {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const searchParams = useSearchParams();
|
|
|
|
|
const {
|
|
|
|
|
isEnabled,
|
|
|
|
|
isVisible,
|
|
|
|
|
@@ -105,6 +110,9 @@ export function DevToolbar() {
|
|
|
|
|
const firstSegment = pathname.split('/')[1];
|
|
|
|
|
const locale = VALID_LOCALES.includes(firstSegment) ? firstSegment : '';
|
|
|
|
|
|
|
|
|
|
// mode=new 쿼리 파라미터 확인
|
|
|
|
|
const isNewMode = searchParams.get('mode') === 'new';
|
|
|
|
|
|
|
|
|
|
// 비활성화 시 렌더링하지 않음
|
|
|
|
|
if (!isEnabled) return null;
|
|
|
|
|
|
|
|
|
|
@@ -126,7 +134,14 @@ export function DevToolbar() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 현재 페이지 타입 감지
|
|
|
|
|
const detectedPage = PAGE_PATTERNS.find(p => p.pattern.test(pathname));
|
|
|
|
|
// 1. 먼저 ?mode=new를 사용하는 페이지 체크
|
|
|
|
|
const modeNewPage = isNewMode
|
|
|
|
|
? MODE_NEW_PAGES.find(p => p.pattern.test(pathname))
|
|
|
|
|
: null;
|
|
|
|
|
// 2. 일반 패턴 매칭
|
|
|
|
|
const patternMatchedPage = PAGE_PATTERNS.find(p => p.pattern.test(pathname));
|
|
|
|
|
// 3. mode=new 페이지 우선, 없으면 일반 패턴 매칭
|
|
|
|
|
const detectedPage = modeNewPage || patternMatchedPage;
|
|
|
|
|
const activePage = detectedPage?.type || null;
|
|
|
|
|
|
|
|
|
|
// 폼 채우기 실행
|
|
|
|
|
|