@@ -853,13 +853,20 @@ const reducer = (state: State, action: Action) => {
853
853
child . passedInProps . forEach ( ( prop , k ) => {
854
854
if ( prop . id === action . payload . rowId ) {
855
855
child . passedInProps . splice ( k , 1 ) ;
856
- pPKillah ( child ) ;
856
+ pPKillahChildren ( child ) ;
857
857
}
858
858
} )
859
859
} )
860
860
}
861
861
}
862
862
} ) ;
863
+ currComponent . code = generateCode (
864
+ components ,
865
+ currComponent . id ,
866
+ [ ...state . rootComponents ] ,
867
+ state . projectType ,
868
+ state . HTMLTypes
869
+ )
863
870
}
864
871
865
872
const pPKillah = ( myComponent ) => {
@@ -872,6 +879,14 @@ const reducer = (state: State, action: Action) => {
872
879
}
873
880
} ) ;
874
881
}
882
+ myComponent . useStateCodes = updateUseStateCodes ( myComponent )
883
+ myComponent . code = generateCode (
884
+ components ,
885
+ myComponent . id ,
886
+ [ ...state . rootComponents ] ,
887
+ state . projectType ,
888
+ state . HTMLTypes
889
+ ) ;
875
890
return ;
876
891
} ;
877
892
myComponent . passedInProps . forEach ( ( prop , i ) => {
@@ -885,9 +900,10 @@ const reducer = (state: State, action: Action) => {
885
900
} )
886
901
}
887
902
} )
903
+ myComponent . useStateCodes = updateUseStateCodes ( myComponent )
888
904
myComponent . code = generateCode (
889
905
components ,
890
- currComponent . id ,
906
+ myComponent . id ,
891
907
[ ...state . rootComponents ] ,
892
908
state . projectType ,
893
909
state . HTMLTypes
@@ -963,9 +979,13 @@ const reducer = (state: State, action: Action) => {
963
979
components ,
964
980
state . canvasFocus . componentId
965
981
) ;
982
+ //updates the stateProps array to reflect total state initialized in component minus the selected state to be deleted
966
983
currComponent . stateProps = action . payload . stateProps ;
967
984
968
-
985
+ //CHILDREN ARRAY LOOP (needed for code preview)
986
+ //iterate through all components, starting from top, and delete ALL instances of deleted state (provided to us
987
+ // in the passedInProps array within the children array of the component
988
+ // using the action.payload.rowId (variable name) and action.payload.otherId (setVariable name))
969
989
components . forEach ( ( component ) => {
970
990
console . log ( 'component in for loop' , component ) ;
971
991
//find all instances of state within child elements and delete state
@@ -981,7 +1001,11 @@ const reducer = (state: State, action: Action) => {
981
1001
} ) ;
982
1002
}
983
1003
} )
984
-
1004
+
1005
+ // COMPONENT LOOP (needed for tables in State Management Tab)
1006
+ //iterate through all components, starting from top, and delete ALL instances of deleted state (provided to us
1007
+ // in the passedInProps array within each component
1008
+ // using the action.payload.rowId (variable name) and action.payload.otherId (setVariable name))
985
1009
for ( let i = 0 ; i < component . passedInProps ?. length ; i ++ ) {
986
1010
if ( component . passedInProps [ i ] [ 'id' ] === action . payload . rowId || component . passedInProps [ i ] [ 'id' ] === action . payload . otherId ) {
987
1011
console . log ( 'prop.id' , component . passedInProps [ i ] [ 'id' ] ) ;
@@ -1017,6 +1041,27 @@ const reducer = (state: State, action: Action) => {
1017
1041
// }
1018
1042
// }
1019
1043
// }
1044
+ let parent ;
1045
+ for ( let i = 0 ; i < components . length ; i ++ ) {
1046
+ let currComponent = components [ i ]
1047
+ for ( let j = 0 ; j < currComponent . children . length ; j ++ ) {
1048
+ let currChild = currComponent . children [ j ] ;
1049
+ if ( currChild . typeId === component . id ) {
1050
+ parent = currComponent ;
1051
+ }
1052
+ }
1053
+ }
1054
+ console . log ( 'ben parent' , { parent} )
1055
+ if ( parent ) {
1056
+ parent . code = generateCode (
1057
+ components ,
1058
+ parent . id ,
1059
+ [ ...state . rootComponents ] ,
1060
+ state . projectType ,
1061
+ state . HTMLTypes
1062
+ ) ;
1063
+ }
1064
+
1020
1065
component . useStateCodes = updateUseStateCodes ( component ) ;
1021
1066
component . code = generateCode (
1022
1067
components ,
@@ -1025,15 +1070,16 @@ const reducer = (state: State, action: Action) => {
1025
1070
state . projectType ,
1026
1071
state . HTMLTypes
1027
1072
) ;
1073
+ console . log ( { component} ) ;
1028
1074
} ) ;
1029
- currComponent . useStateCodes = updateUseStateCodes ( currComponent ) ;
1030
- currComponent . code = generateCode (
1031
- components ,
1032
- state . canvasFocus . componentId ,
1033
- [ ...state . rootComponents ] ,
1034
- state . projectType ,
1035
- state . HTMLTypes
1036
- ) ;
1075
+ // currComponent.useStateCodes = updateUseStateCodes(currComponent);
1076
+ // currComponent.code = generateCode(
1077
+ // components,
1078
+ // state.canvasFocus.componentId,
1079
+ // [...state.rootComponents],
1080
+ // state.projectType,
1081
+ // state.HTMLTypes
1082
+ // );
1037
1083
return { ...state , components} ;
1038
1084
}
1039
1085
default :
0 commit comments