11import * as React from "react" ;
2- import { useState , useEffect , useRef , useCallback } from "react" ;
2+ import { useState } from "react" ;
33import {
44 type TechTree ,
55 type TechNode ,
@@ -10,68 +10,6 @@ import { Modal } from "./Modal.js";
1010import { Markdown } from "./Markdown.js" ;
1111import { NodePickerModal } from "./NodePicker.js" ;
1212
13- interface AddNodeModalProps {
14- onClose : ( ) => void ;
15- onAdd : ( title : string , description : string ) => void ;
16- }
17-
18- function AddNodeModal ( { onClose, onAdd } : AddNodeModalProps ) {
19- const [ title , setTitle ] = useState ( "" ) ;
20-
21- const handleSubmit = ( e : React . FormEvent ) => {
22- e . preventDefault ( ) ;
23- if ( title . trim ( ) ) {
24- onAdd ( title . trim ( ) , "" ) ;
25- onClose ( ) ;
26- }
27- } ;
28-
29- return (
30- < Modal onClose = { onClose } className = "w-[80vh]" >
31- < form onSubmit = { handleSubmit } className = "p-6" >
32- < h2 className = "text-xl font-semibold mb-4" > Add Node</ h2 >
33-
34- < div className = "mb-4" >
35- < label
36- htmlFor = "node-title"
37- className = "block text-sm font-medium text-gray-700 mb-2"
38- >
39- Title
40- </ label >
41- < input
42- id = "node-title"
43- type = "text"
44- value = { title }
45- autoFocus = { true }
46- autoComplete = "off"
47- onChange = { ( e ) => setTitle ( e . target . value ) }
48- className = "w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
49- placeholder = "Enter title..."
50- required
51- />
52- </ div >
53-
54- < div className = "flex justify-end gap-3" >
55- < button
56- type = "button"
57- onClick = { onClose }
58- className = "px-4 py-2 text-gray-700 bg-gray-100 rounded hover:bg-gray-200 transition-colors"
59- >
60- Cancel
61- </ button >
62- < button
63- type = "submit"
64- disabled = { ! title . trim ( ) }
65- className = "px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors"
66- >
67- Add
68- </ button >
69- </ div >
70- </ form >
71- </ Modal >
72- ) ;
73- }
74-
7513interface NodeViewerProps {
7614 nodeId : TechNodeId ;
7715 editing : boolean ;
@@ -106,7 +44,7 @@ export function NodeViewer({
10644 const handleSetTitle = ( title : string ) => {
10745 const updatedNode = {
10846 ...node ,
109- id : generateId ( title ) ,
47+ id : generateId ( fullTree , title ) ,
11048 title : title ,
11149 } ;
11250 onUpdateNode ( node . id , updatedNode , "set-title" , true ) ;
@@ -269,11 +207,12 @@ export function NodeViewer({
269207 < h4 className = "font-semibold text-gray-900 mb-2" > Bugzilla:</ h4 >
270208 { editing ? (
271209 < input
272- type = "text"
273- value = { node . bugzillaNumber || '' }
210+ value = { node . bugzillaNumber || "" }
274211 onChange = { ( e ) => {
275212 const value = e . target . value ;
276- handleSetBugzillaNumber ( value ? parseInt ( value , 10 ) : undefined ) ;
213+ handleSetBugzillaNumber (
214+ value ? parseInt ( value , 10 ) : undefined ,
215+ ) ;
277216 } }
278217 className = "w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
279218 placeholder = "Bugzilla bug number..."
0 commit comments