refactor: 품목기준관리 서비스 레이어 도입 및 버그 수정

서비스 레이어 리팩토링:
- services/ 폴더 생성 (fieldService, masterFieldService, sectionService, pageService, templateService, attributeService)
- 도메인 로직 중앙화 (validation, parsing, transform)
- hooks와 dialogs에서 서비스 호출로 변경

버그 수정:
- 섹션탭 실시간 동기화 문제 수정 (sectionsAsTemplates 중복 제거 순서 변경)
- 422 Validation Error 수정 (createIndependentField → addFieldToSection)
- 페이지 삭제 시 섹션-필드 연결 유지 (refreshIndependentSections 대신 직접 이동)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
byeongcheolryu
2025-12-01 14:23:57 +09:00
parent 6ed5d4ffb3
commit 0552b02ba9
19 changed files with 2025 additions and 117 deletions

View File

@@ -9,15 +9,10 @@ import { Textarea } from '@/components/ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Switch } from '@/components/ui/switch';
import { Badge } from '@/components/ui/badge';
import { masterFieldService } from '../services';
const INPUT_TYPE_OPTIONS = [
{ value: 'textbox', label: '텍스트 입력' },
{ value: 'number', label: '숫자 입력' },
{ value: 'dropdown', label: '드롭다운' },
{ value: 'checkbox', label: '체크박스' },
{ value: 'date', label: '날짜' },
{ value: 'textarea', label: '긴 텍스트' },
];
// 2025-12-01: masterFieldService.fieldTypes 재사용으로 리팩토링
const INPUT_TYPE_OPTIONS = masterFieldService.fieldTypes;
interface MasterFieldDialogProps {
isMasterFieldDialogOpen: boolean;
@@ -82,12 +77,12 @@ export function MasterFieldDialog({
}: MasterFieldDialogProps) {
const [isSubmitted, setIsSubmitted] = useState(false);
// 유효성 검사
const isNameEmpty = !newMasterFieldName.trim();
// 2025-12-01: masterFieldService 사용으로 유효성 검사 중앙화
const nameValidation = masterFieldService.validateFieldName(newMasterFieldName);
const keyValidation = masterFieldService.validateFieldKey(newMasterFieldKey);
const isNameEmpty = !nameValidation.valid;
const isKeyEmpty = !newMasterFieldKey.trim();
// 2025-11-28: field_key validation - 영문 시작, 영문+숫자+언더스코어만 허용
const fieldKeyPattern = /^[a-zA-Z][a-zA-Z0-9_]*$/;
const isKeyInvalid = newMasterFieldKey.trim() !== '' && !fieldKeyPattern.test(newMasterFieldKey);
const isKeyInvalid = newMasterFieldKey.trim() !== '' && !keyValidation.valid;
const handleClose = () => {
setIsMasterFieldDialogOpen(false);