fix(WEB): 버튼 URL 및 DevToolbar ?mode=new 지원

- DepositManagement, WithdrawalManagement, SalesManagement, CardManagement
  버튼 URL을 /new에서 ?mode=new 방식으로 변경
- DevToolbar에 MODE_NEW_PAGES 상수 추가하여 ?mode=new 페이지 감지
- useSearchParams 활용하여 mode 파라미터 확인 후 채우기 버튼 활성화
This commit is contained in:
2026-01-23 11:13:18 +09:00
parent 1195fc1fa5
commit d7594d026a
5 changed files with 27 additions and 12 deletions

View File

@@ -327,7 +327,7 @@ export function DepositManagement({ initialData, initialPagination }: DepositMan
// 헤더 액션 (등록 버튼)
headerActions: () => (
<Button className="ml-auto" onClick={() => router.push('/ko/accounting/deposits/new')}>
<Button className="ml-auto" onClick={() => router.push('/accounting/deposits?mode=new')}>
<Plus className="w-4 h-4 mr-2" />
</Button>

View File

@@ -189,7 +189,7 @@ export function SalesManagement({ initialData, initialPagination }: SalesManagem
}, [router]);
const handleCreate = useCallback(() => {
router.push('/ko/accounting/sales/new');
router.push('/accounting/sales?mode=new');
}, [router]);
// 토글 핸들러

View File

@@ -299,7 +299,7 @@ export function WithdrawalManagement({ initialData, initialPagination }: Withdra
// 헤더 액션 (등록 버튼)
headerActions: () => (
<Button className="ml-auto" onClick={() => router.push('/ko/accounting/withdrawals/new')}>
<Button className="ml-auto" onClick={() => router.push('/accounting/withdrawals?mode=new')}>
<Plus className="w-4 h-4 mr-2" />
</Button>

View File

@@ -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;
// 폼 채우기 실행

View File

@@ -162,7 +162,7 @@ export function CardManagement({ initialData }: CardManagementProps) {
// 핸들러
const handleAddCard = useCallback(() => {
router.push('/ko/hr/card-management/new');
router.push('/hr/card-management?mode=new');
}, [router]);
const handleDeleteCard = useCallback(async () => {