({
open,
onOpenChange,
onSubmit,
project,
defaultWorkspaceId,
}: ProjectDialogProps)
| 73 | ]; |
| 74 | |
| 75 | export function ProjectDialog({ |
| 76 | open, |
| 77 | onOpenChange, |
| 78 | onSubmit, |
| 79 | project, |
| 80 | defaultWorkspaceId, |
| 81 | }: ProjectDialogProps) { |
| 82 | const { addProject, updateProject, workspaces } = useApp(); |
| 83 | |
| 84 | const [formData, setFormData] = useState<ProjectFormData>({ |
| 85 | name: '', |
| 86 | description: '', |
| 87 | type: 'web', |
| 88 | status: 'planning', |
| 89 | criticality: 'medium', |
| 90 | technologies: [], |
| 91 | team: '', |
| 92 | workspaceIds: [], |
| 93 | repository: '', |
| 94 | url: '', |
| 95 | }); |
| 96 | |
| 97 | const [newTech, setNewTech] = useState(''); |
| 98 | const [errors, setErrors] = useState<Record<string, string>>({}); |
| 99 | const [openWorkspaces, setOpenWorkspaces] = useState(false); |
| 100 | |
| 101 | useEffect(() => { |
| 102 | if (project) { |
| 103 | setFormData({ |
| 104 | name: project.name, |
| 105 | description: project.description, |
| 106 | type: project.type as ProjectFormData['type'], |
| 107 | status: project.status as ProjectFormData['status'], |
| 108 | criticality: project.criticality as ProjectFormData['criticality'], |
| 109 | technologies: project.technologies, |
| 110 | team: project.team, |
| 111 | workspaceIds: project.workspaceIds, |
| 112 | repository: project.repository || '', |
| 113 | url: project.url || '', |
| 114 | }); |
| 115 | } else { |
| 116 | setFormData({ |
| 117 | name: '', |
| 118 | description: '', |
| 119 | type: 'web', |
| 120 | status: 'planning', |
| 121 | criticality: 'medium', |
| 122 | technologies: [], |
| 123 | team: '', |
| 124 | workspaceIds: defaultWorkspaceId ? [defaultWorkspaceId] : [], |
| 125 | repository: '', |
| 126 | url: '', |
| 127 | }); |
| 128 | } |
| 129 | setErrors({}); |
| 130 | }, [project, open, defaultWorkspaceId]); |
| 131 | |
| 132 | const handleChange = (field: keyof ProjectFormData, value: any) => { |
nothing calls this directly
no test coverage detected