diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-21 09:05:52 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-21 09:05:52 +0000 |
| commit | cf77558c0ccc5c0c1bc3cdd6edd9a0475e1970c8 (patch) | |
| tree | 32eded30db38fe321c288d55c7f3ee136a0b4723 /lib/tags | |
| parent | 261c45877f58af5779ef796c0c9186ed021e028e (diff) | |
(대표님) 설계측 오류 및 스타일 등 수정
Diffstat (limited to 'lib/tags')
| -rw-r--r-- | lib/tags/table/tags-table-toolbar-actions.tsx | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/lib/tags/table/tags-table-toolbar-actions.tsx b/lib/tags/table/tags-table-toolbar-actions.tsx index f77ebafa..cc2d82b4 100644 --- a/lib/tags/table/tags-table-toolbar-actions.tsx +++ b/lib/tags/table/tags-table-toolbar-actions.tsx @@ -56,7 +56,7 @@ interface TagsTableToolbarActionsProps { /** 현재 태그 목록(상태) */ tableData: Tag[] /** 태그 목록을 갱신하는 setState */ - selectedMode:string + selectedMode: string } /** @@ -134,7 +134,7 @@ export function TagsTableToolbarActions({ }, [tagNumberingRules]) const [projectId, setProjectId] = React.useState<number | null>(null); - + // Add useEffect to fetch projectId when selectedPackageId changes React.useEffect(() => { const fetchProjectId = async () => { @@ -158,22 +158,22 @@ export function TagsTableToolbarActions({ if (tagOptionsCache[attributesId]) { return tagOptionsCache[attributesId]; } - + try { // Only pass projectId if it's not null let options: TagOption[]; if (projectId !== null) { options = await fetchTagSubfieldOptions(attributesId, projectId); } else { - options = [] + options = [] } - + // Update cache setTagOptionsCache(prev => ({ ...prev, [attributesId]: options })); - + return options; } catch (error) { console.error(`Error fetching options for ${attributesId}:`, error); @@ -267,12 +267,24 @@ export function TagsTableToolbarActions({ // 정규식 검증 if (field.expression) { - const regex = new RegExp(`^${field.expression}$`) - if (!regex.test(part)) { - return `Part '${part}' for field '${field.label}' does not match the pattern '${field.expression}'.` + try { + // 중복된 ^, $ 제거 후 다시 추가 + let cleanPattern = field.expression; + + // 시작과 끝의 ^, $ 제거 + cleanPattern = cleanPattern.replace(/^\^/, '').replace(/\$$/, ''); + + // 정규식 생성 (항상 전체 매칭) + const regex = new RegExp(`^${cleanPattern}$`); + + if (!regex.test(part)) { + return `Part '${part}' for field '${field.label}' does not match the pattern '${field.expression}'.`; + } + } catch (error) { + console.error(`Invalid regex pattern: ${field.expression}`, error); + return `Invalid pattern for field '${field.label}': ${field.expression}`; } } - // 선택 옵션 검증 if (field.type === "select" && field.options && field.options.length > 0) { const validValues = field.options.map(opt => opt.value) @@ -563,7 +575,7 @@ export function TagsTableToolbarActions({ setIsExporting(true) // 유효성 검사가 포함된 새로운 엑셀 내보내기 함수 호출 - await exportTagsToExcel(table,selectedPackageId, { + await exportTagsToExcel(table, selectedPackageId, { filename: `Tags_${selectedPackageId}`, excludeColumns: ["select", "actions", "createdAt", "updatedAt"], }) @@ -580,11 +592,11 @@ export function TagsTableToolbarActions({ const startGetTags = async () => { try { setIsLoading(true) - + // API 엔드포인트 호출 - 작업 시작만 요청 const response = await fetch('/api/cron/tags/start', { method: 'POST', - body: JSON.stringify({ + body: JSON.stringify({ packageId: selectedPackageId, mode: selectedMode // 모드 정보 추가 }) @@ -593,14 +605,14 @@ export function TagsTableToolbarActions({ const errorData = await response.json() throw new Error(errorData.error || 'Failed to start tag import') } - + const data = await response.json() - + // 작업 ID 저장 if (data.syncId) { setSyncId(data.syncId) toast.info('Tag import started. This may take a while...') - + // 상태 확인을 위한 폴링 시작 startPolling(data.syncId) } else { @@ -616,24 +628,24 @@ export function TagsTableToolbarActions({ setIsLoading(false) } } - + const startPolling = (id: string) => { // 이전 폴링이 있다면 제거 if (pollingRef.current) { clearInterval(pollingRef.current) } - + // 5초마다 상태 확인 pollingRef.current = setInterval(async () => { try { const response = await fetch(`/api/cron/tags/status?id=${id}`) - + if (!response.ok) { throw new Error('Failed to get tag import status') } - + const data = await response.json() - + if (data.status === 'completed') { // 폴링 중지 if (pollingRef.current) { @@ -642,16 +654,16 @@ export function TagsTableToolbarActions({ } router.refresh() - + // 상태 초기화 setIsLoading(false) setSyncId(null) - + // 성공 메시지 표시 toast.success( `Tags imported successfully! ${data.result?.processedCount || 0} items processed.` ) - + // 테이블 데이터 업데이트 table.resetRowSelection() } else if (data.status === 'failed') { @@ -660,7 +672,7 @@ export function TagsTableToolbarActions({ clearInterval(pollingRef.current) pollingRef.current = null } - + setIsLoading(false) setSyncId(null) toast.error(data.error || 'Import failed') @@ -687,7 +699,7 @@ export function TagsTableToolbarActions({ .getFilteredSelectedRowModel() .rows.map((row) => row.original)} onSuccess={() => table.toggleAllRowsSelected(false)} - selectedPackageId={selectedPackageId} + selectedPackageId={selectedPackageId} /> ) : null} <Button |
