1
- import { ComponentInt , ComponentsInt , PropInt , ChildInt } from '../utils/Interfaces.ts' ;
1
+ import {
2
+ ComponentInt , ComponentsInt , PropInt , ChildInt , Action , ApplicationStateInt
3
+ } from '../utils/Interfaces.ts' ;
2
4
3
5
import {
4
6
LOAD_INIT_DATA ,
@@ -26,29 +28,29 @@ import {
26
28
UPDATE_CHILDREN_SORT ,
27
29
CHANGE_IMAGE_SOURCE ,
28
30
DELETE_IMAGE
29
- } from '../actionTypes/index.js ' ;
31
+ } from '../actionTypes/index.ts ' ;
30
32
31
33
import { loadState } from '../localStorage' ;
32
34
import createFiles from '../utils/createFiles.util.ts' ;
33
35
import createApplicationUtil from '../utils/createApplication.util.ts' ;
34
36
35
37
export const changeImagePath = ( imageSource : string ) => ( {
36
38
type : CHANGE_IMAGE_SOURCE ,
37
- payload : imageSource
38
- } ) ;
39
+ payload : { imageSource } ,
40
+ } )
39
41
40
- export const loadInitData = ( ) => ( dispatch : any ) => {
41
- loadState ( ) . then ( ( data : any ) =>
42
+ export const loadInitData = ( ) => ( dispatch : ( arg : Action ) => void ) => {
43
+ loadState ( ) . then ( ( data : ApplicationStateInt ) => {
42
44
dispatch ( {
43
- type : LOAD_INIT_DATA ,
44
- payload : {
45
- data : data ? data . workspace : { }
46
- }
47
- } )
48
- ) ;
45
+ type : LOAD_INIT_DATA ,
46
+ payload : {
47
+ data : data ? data . workspace : { } ,
48
+ } ,
49
+ } ) ;
50
+ } ) ;
49
51
} ;
50
52
51
- export const addComponent = ( { title } : { title : string } ) => ( dispatch : any ) => {
53
+ export const addComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
52
54
dispatch ( { type : ADD_COMPONENT , payload : { title } } ) ;
53
55
} ;
54
56
@@ -57,14 +59,14 @@ export const addChild = ({
57
59
childType,
58
60
HTMLInfo
59
61
} : {
60
- title : string ;
61
- childType : string ;
62
- HTMLInfo : object ;
63
- } ) => ( dispatch : any ) => {
62
+ title : string ;
63
+ childType : string ;
64
+ HTMLInfo : object ;
65
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
64
66
dispatch ( { type : ADD_CHILD , payload : { title, childType, HTMLInfo } } ) ;
65
67
} ;
66
68
67
- export const deleteChild = ( { } ) => ( dispatch : any ) => {
69
+ export const deleteChild = ( { } ) => ( dispatch : ( arg : Action ) => void ) => {
68
70
// with no payload, it will delete focusd child
69
71
dispatch ( { type : DELETE_CHILD , payload : { } } ) ;
70
72
} ;
@@ -73,9 +75,9 @@ export const deleteComponent = ({
73
75
componentId,
74
76
stateComponents
75
77
} : {
76
- componentId : number ;
77
- stateComponents : ComponentsInt ;
78
- } ) => ( dispatch : any ) => {
78
+ componentId : number ;
79
+ stateComponents : ComponentsInt ;
80
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
79
81
// find all places where the "to be deleted" is a child and do what u gotta do
80
82
stateComponents . forEach ( ( parent : ComponentInt ) => {
81
83
parent . childrenArray
@@ -98,44 +100,43 @@ export const deleteComponent = ({
98
100
dispatch ( { type : DELETE_COMPONENT , payload : { componentId } } ) ;
99
101
} ;
100
102
101
- export const changeFocusComponent = ( { title } : { title : string } ) => ( dispatch : any ) => {
103
+ export const changeFocusComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
102
104
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
103
105
} ;
104
106
105
107
// make sure childId is being sent in
106
- export const changeFocusChild = ( { childId } : { childId : number } ) => ( dispatch : any ) => {
108
+ export const changeFocusChild = ( { childId } : { childId : number } ) => ( dispatch : ( arg : Action ) => void ) => {
107
109
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { childId } } ) ;
108
110
} ;
109
111
110
112
export const changeComponentFocusChild = ( {
111
113
componentId,
112
114
childId
113
115
} : {
114
- componentId : number ;
115
- childId : number ;
116
- } ) => ( dispatch : any ) => {
116
+ componentId : number ;
117
+ childId : number ;
118
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
117
119
dispatch ( {
118
120
type : CHANGE_COMPONENT_FOCUS_CHILD ,
119
121
payload : { componentId, childId }
120
122
} ) ;
121
123
} ;
122
124
123
125
export const deleteImage = ( ) => ( {
124
- type : DELETE_IMAGE ,
125
- payload : ''
126
- } ) ;
126
+ type : DELETE_IMAGE
127
+ } )
127
128
128
129
export const exportFiles = ( {
129
130
components,
130
131
path,
131
132
appName,
132
133
exportAppBool
133
134
} : {
134
- components : ComponentsInt ;
135
- path : string ;
136
- appName : string ;
137
- exportAppBool : boolean ;
138
- } ) => ( dispatch : any ) => {
135
+ components : ComponentsInt ;
136
+ path : string ;
137
+ appName : string ;
138
+ exportAppBool : boolean ;
139
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
139
140
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
140
141
dispatch ( {
141
142
type : EXPORT_FILES
@@ -184,12 +185,12 @@ export const createApplication = ({
184
185
appName = 'reactype_app' ,
185
186
exportAppBool
186
187
} : {
187
- path : string ;
188
- components : ComponentsInt ;
189
- genOption : number ;
190
- appName : string ;
191
- exportAppBool : boolean ;
192
- } ) => ( dispatch : any ) => {
188
+ path : string ;
189
+ components : ComponentsInt ;
190
+ genOption : number ;
191
+ appName : string ;
192
+ exportAppBool : boolean ;
193
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
193
194
if ( genOption === 0 ) {
194
195
exportAppBool = false ;
195
196
dispatch (
@@ -208,8 +209,7 @@ export const createApplication = ({
208
209
createApplicationUtil ( {
209
210
path,
210
211
appName,
211
- genOption
212
- // exportAppBool
212
+ genOption,
213
213
} )
214
214
. then ( ( ) => {
215
215
dispatch ( {
@@ -242,7 +242,7 @@ export const deleteAllData = () => ({
242
242
type : DELETE_ALL_DATA
243
243
} ) ;
244
244
245
- export const deleteProp = ( propId : number ) => ( dispatch : any ) => {
245
+ export const deleteProp = ( propId : number ) => ( dispatch : ( arg : Action ) => void ) => {
246
246
dispatch ( { type : DELETE_PROP , payload : propId } ) ;
247
247
} ;
248
248
@@ -256,19 +256,20 @@ export const addProp = (prop: PropInt) => ({
256
256
} ) ;
257
257
258
258
export const updateHtmlAttr = ( { attr, value } : { attr : string ; value : string } ) => (
259
- dispatch : any
259
+ dispatch : ( arg : Action ) => void ,
260
260
) => {
261
261
dispatch ( {
262
262
type : UPDATE_HTML_ATTR ,
263
263
payload : { attr, value }
264
264
} ) ;
265
265
} ;
266
266
267
- export const updateChildrenSort = ( { newSortValues } : { newSortValues : any } ) => (
268
- dispatch : any
269
- ) => {
270
- dispatch ( {
271
- type : UPDATE_CHILDREN_SORT ,
272
- payload : { newSortValues }
273
- } ) ;
274
- } ;
267
+ //Action reserved for SortChildren component not written yet
268
+ // export const updateChildrenSort = ({ newSortValues }: { newSortValues: any }) => (
269
+ // dispatch: (arg: Action) => void,
270
+ // ) => {
271
+ // dispatch({
272
+ // type: UPDATE_CHILDREN_SORT,
273
+ // payload: { newSortValues },
274
+ // });
275
+ // };
0 commit comments