refactor: 품목기준관리 hooks 분리 및 다이얼로그 개선

- ItemMasterDataManagement 컴포넌트에서 hooks 분리
- 다이얼로그 컴포넌트들 타입 및 구조 개선
- BOMManagementSection 개선
- HierarchyTab 업데이트

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
byeongcheolryu
2025-11-26 14:06:48 +09:00
parent 593644922a
commit b73603822b
25 changed files with 3559 additions and 1703 deletions

View File

@@ -1,5 +1,6 @@
'use client';
import { useState } from 'react';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
@@ -23,12 +24,21 @@ export function PathEditDialog({
updateItemPage,
trackChange,
}: PathEditDialogProps) {
const [isSubmitted, setIsSubmitted] = useState(false);
// 유효성 검사
const isPathEmpty = !editingAbsolutePath.trim();
const isPathInvalid = editingAbsolutePath.trim() && !editingAbsolutePath.startsWith('/');
const handleClose = () => {
setEditingPathPageId(null);
setEditingAbsolutePath('');
setIsSubmitted(false);
};
return (
<Dialog open={editingPathPageId !== null} onOpenChange={(open) => {
if (!open) {
setEditingPathPageId(null);
setEditingAbsolutePath('');
}
if (!open) handleClose();
}}>
<DialogContent>
<DialogHeader>
@@ -42,25 +52,30 @@ export function PathEditDialog({
value={editingAbsolutePath}
onChange={(e) => setEditingAbsolutePath(e.target.value)}
placeholder="/제품관리/제품등록"
className={isSubmitted && (isPathEmpty || isPathInvalid) ? 'border-red-500 focus-visible:ring-red-500' : ''}
/>
<p className="text-xs text-gray-500 mt-1">(/) , </p>
{isSubmitted && isPathEmpty && (
<p className="text-xs text-red-500 mt-1"> </p>
)}
{isSubmitted && isPathInvalid && (
<p className="text-xs text-red-500 mt-1"> (/) </p>
)}
{!isSubmitted || (!isPathEmpty && !isPathInvalid) ? (
<p className="text-xs text-gray-500 mt-1">(/) , </p>
) : null}
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setEditingPathPageId(null)}></Button>
<Button variant="outline" onClick={handleClose}></Button>
<Button onClick={() => {
if (!editingAbsolutePath.trim()) {
toast.error('절대경로를 입력해주세요');
return;
}
if (!editingAbsolutePath.startsWith('/')) {
toast.error('절대경로는 슬래시(/)로 시작해야 합니다');
setIsSubmitted(true);
if (isPathEmpty || isPathInvalid) {
return;
}
if (editingPathPageId) {
updateItemPage(editingPathPageId, { absolutePath: editingAbsolutePath });
trackChange('pages', editingPathPageId, 'update', { absolutePath: editingAbsolutePath });
setEditingPathPageId(null);
trackChange('pages', String(editingPathPageId), 'update', { absolutePath: editingAbsolutePath });
handleClose();
toast.success('절대경로가 수정되었습니다 (저장 필요)');
}
}}></Button>