File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 3
3
State ,
4
4
Action ,
5
5
Component ,
6
- ChildElement
6
+ ChildElement ,
7
+ HTMLType
7
8
} from '../interfaces/Interfaces' ;
8
9
import initialState from '../context/initialState' ;
9
10
import generateCode from '../helperFunctions/generateCode' ;
@@ -569,12 +570,24 @@ const reducer = (state: State, action: Action) => {
569
570
}
570
571
571
572
case 'DELETE ELEMENT' : {
572
- const HTMLTypes = [ ... state . HTMLTypes ] ;
573
- for ( let i = 0 ; i < HTMLTypes . length ; i += 1 ) {
574
- if ( HTMLTypes [ i ] . id === action . payload ) {
575
- HTMLTypes . splice ( i , 1 ) ;
573
+ let name : string = '' ;
574
+ const HTMLTypes : HTMLType [ ] = [ ... state . HTMLTypes ] . filter ( el => {
575
+ if ( el . id === action . payload ) {
576
+ name = el . tag ;
576
577
}
577
- }
578
+ return el . id !== action . payload ;
579
+ } ) ;
580
+ const components : Component [ ] = deleteById ( action . payload , name ) ;
581
+ const rootComponents : number [ ] = updateRoots ( components ) ;
582
+ components . forEach ( ( el , i ) => {
583
+ el . code = generateCode (
584
+ components ,
585
+ components [ i ] . id ,
586
+ rootComponents ,
587
+ state . projectType ,
588
+ state . HTMLTypes
589
+ ) ;
590
+ } )
578
591
return {
579
592
...state ,
580
593
HTMLTypes
You can’t perform that action at this time.
0 commit comments