@@ -13,7 +13,7 @@ interface Props {
1313 handleUnlockAfterChange : ( idx : number , id : string ) => void ;
1414 addUnlockAfter : ( ) => void ;
1515 removeUnlockAfter : ( idx : number ) => void ;
16- renderNodeSelect : ( value : string , onChange : ( id : string ) => void ) => React . ReactNode ;
16+ renderNodePicker : ( value : string , onChange : ( id : string ) => void , onRemove : ( ) => void ) => React . ReactNode ;
1717 handleCompletionNeedsChange : ( idx : number , id : string ) => void ;
1818 addCompletionNeed : ( ) => void ;
1919 removeCompletionNeed : ( idx : number ) => void ;
@@ -31,7 +31,7 @@ export function EditorDrawerTaskContent({
3131 handleUnlockAfterChange,
3232 addUnlockAfter,
3333 removeUnlockAfter,
34- renderNodeSelect ,
34+ renderNodePicker ,
3535 handleCompletionNeedsChange,
3636 addCompletionNeed,
3737 removeCompletionNeed,
@@ -235,42 +235,27 @@ export function EditorDrawerTaskContent({
235235 </ div >
236236 < div className = "form-group" >
237237 < label > { t . unlockAfter } </ label >
238- { ( localNode . data . unlock ?. after || [ ] ) . map ( ( id : string , idx : number ) => (
239- < div key = { idx } style = { { display : "flex" , gap : "8px" , marginBottom : "8px" } } >
240- { renderNodeSelect ( id , newId => handleUnlockAfterChange ( idx , newId ) ) }
241- < button onClick = { ( ) => removeUnlockAfter ( idx ) } className = "icon-button" >
242- < Trash2 size = { 16 } />
243- </ button >
244- </ div >
245- ) ) }
238+ { ( localNode . data . unlock ?. after || [ ] ) . map ( ( id : string , idx : number ) =>
239+ renderNodePicker ( id , newId => handleUnlockAfterChange ( idx , newId ) , ( ) => removeUnlockAfter ( idx ) )
240+ ) }
246241 < button onClick = { addUnlockAfter } className = "secondary-button" >
247242 < Plus size = { 16 } /> { t . unlockAfter }
248243 </ button >
249244 </ div >
250245 { localNode . type === "topic" && < div className = "form-group" >
251246 < label > { t . completionNeeds } </ label >
252- { ( localNode . data . completion ?. needs || [ ] ) . map ( ( need : string , idx : number ) => (
253- < div key = { idx } style = { { display : "flex" , gap : "8px" , marginBottom : "8px" } } >
254- { renderNodeSelect ( need , newId => handleCompletionNeedsChange ( idx , newId ) ) }
255- < button onClick = { ( ) => removeCompletionNeed ( idx ) } className = "icon-button" >
256- < Trash2 size = { 16 } />
257- </ button >
258- </ div >
259- ) ) }
247+ { ( localNode . data . completion ?. needs || [ ] ) . map ( ( need : string , idx : number ) =>
248+ renderNodePicker ( need , newId => handleCompletionNeedsChange ( idx , newId ) , ( ) => removeCompletionNeed ( idx ) )
249+ ) }
260250 < button onClick = { addCompletionNeed } className = "secondary-button" >
261251 < Plus size = { 16 } /> { t . completionNeeds }
262252 </ button >
263253 </ div > }
264254 { localNode . type === "topic" && < div className = "form-group" >
265255 < label > { t . completionOptional } </ label >
266- { ( localNode . data . completion ?. optional || [ ] ) . map ( ( opt : string , idx : number ) => (
267- < div key = { idx } style = { { display : "flex" , gap : "8px" , marginBottom : "8px" } } >
268- { renderNodeSelect ( opt , newId => handleCompletionOptionalChange ( idx , newId ) ) }
269- < button onClick = { ( ) => removeCompletionOptional ( idx ) } className = "icon-button" >
270- < Trash2 size = { 16 } />
271- </ button >
272- </ div >
273- ) ) }
256+ { ( localNode . data . completion ?. optional || [ ] ) . map ( ( opt : string , idx : number ) =>
257+ renderNodePicker ( opt , newId => handleCompletionOptionalChange ( idx , newId ) , ( ) => removeCompletionOptional ( idx ) )
258+ ) }
274259 < button onClick = { addCompletionOptional } className = "secondary-button" >
275260 < Plus size = { 16 } /> { t . completionOptional }
276261 </ button >
0 commit comments