@@ -47,18 +47,17 @@ export interface State {
47
47
} ;
48
48
}
49
49
50
- type ToggleableUserType = UserType . Vendor | UserType . Government ;
51
-
52
50
type InnerMsg =
53
51
| ADT < "onInitResponse" , TableUser [ ] >
54
52
| ADT < "table" , Table . Msg >
55
53
| ADT < "showExportModal" >
56
54
| ADT < "hideExportModal" >
57
- | ADT < "userTypeCheckbox" , { userType : ToggleableUserType ; msg : Checkbox . Msg } >
58
- | ADT <
59
- "fieldCheckbox" ,
60
- { field : keyof State [ "fieldCheckboxes" ] ; msg : Checkbox . Msg }
61
- >
55
+ | ADT < "userTypeCheckboxGovernment" , Checkbox . Msg >
56
+ | ADT < "userTypeCheckboxVendor" , Checkbox . Msg >
57
+ | ADT < "fieldCheckboxFirstName" , Checkbox . Msg >
58
+ | ADT < "fieldCheckboxLastName" , Checkbox . Msg >
59
+ | ADT < "fieldCheckboxEmail" , Checkbox . Msg >
60
+ | ADT < "fieldCheckboxOrganizationName" , Checkbox . Msg >
62
61
| ADT < "exportContactList" >
63
62
| ADT < "exportComplete" > ;
64
63
@@ -144,29 +143,27 @@ function baseInit(): component_.base.InitReturnValue<State, Msg> {
144
143
...component_ . cmd . mapMany ( tableCmds , ( msg ) => adt ( "table" , msg ) as Msg ) ,
145
144
...component_ . cmd . mapMany (
146
145
govCheckboxCmds ,
147
- ( msg ) =>
148
- adt ( "userTypeCheckbox" , { userType : UserType . Government , msg } ) as Msg
146
+ ( msg ) => adt ( "userTypeCheckboxGovernment" , msg ) as Msg
149
147
) ,
150
148
...component_ . cmd . mapMany (
151
149
vendorCheckboxCmds ,
152
- ( msg ) =>
153
- adt ( "userTypeCheckbox" , { userType : UserType . Vendor , msg } ) as Msg
150
+ ( msg ) => adt ( "userTypeCheckboxVendor" , msg ) as Msg
154
151
) ,
155
152
...component_ . cmd . mapMany (
156
153
firstNameCheckboxCmds ,
157
- ( msg ) => adt ( "fieldCheckbox " , { field : "firstName" , msg } ) as Msg
154
+ ( msg ) => adt ( "fieldCheckboxFirstName " , msg ) as Msg
158
155
) ,
159
156
...component_ . cmd . mapMany (
160
157
lastNameCheckboxCmds ,
161
- ( msg ) => adt ( "fieldCheckbox " , { field : "lastName" , msg } ) as Msg
158
+ ( msg ) => adt ( "fieldCheckboxLastName " , msg ) as Msg
162
159
) ,
163
160
...component_ . cmd . mapMany (
164
161
emailCheckboxCmds ,
165
- ( msg ) => adt ( "fieldCheckbox " , { field : "email" , msg } ) as Msg
162
+ ( msg ) => adt ( "fieldCheckboxEmail " , msg ) as Msg
166
163
) ,
167
164
...component_ . cmd . mapMany (
168
165
organizationNameCheckboxCmds ,
169
- ( msg ) => adt ( "fieldCheckbox " , { field : "organizationName" , msg } ) as Msg
166
+ ( msg ) => adt ( "fieldCheckboxOrganizationName " , msg ) as Msg
170
167
)
171
168
]
172
169
] ;
@@ -255,27 +252,53 @@ const update: component_.page.Update<State, InnerMsg, Route> = ({
255
252
return [ state . set ( "showExportModal" , true ) , [ ] ] ;
256
253
case "hideExportModal" :
257
254
return [ state . set ( "showExportModal" , false ) , [ ] ] ;
258
- case "userTypeCheckbox " :
255
+ case "userTypeCheckboxGovernment " :
259
256
return component_ . base . updateChild ( {
260
257
state,
261
- childStatePath : [ "userTypeCheckboxes" , msg . value . userType ] ,
258
+ childStatePath : [ "userTypeCheckboxes" , UserType . Government ] ,
262
259
childUpdate : Checkbox . update ,
263
- childMsg : msg . value . msg ,
264
- mapChildMsg : ( value ) => ( {
265
- tag : "userTypeCheckbox" ,
266
- value : { userType : msg . value . userType , msg : value }
267
- } )
260
+ childMsg : msg . value ,
261
+ mapChildMsg : ( value ) => adt ( "userTypeCheckboxGovernment" , value )
268
262
} ) ;
269
- case "fieldCheckbox " :
263
+ case "userTypeCheckboxVendor " :
270
264
return component_ . base . updateChild ( {
271
265
state,
272
- childStatePath : [ "fieldCheckboxes " , msg . value . field ] ,
266
+ childStatePath : [ "userTypeCheckboxes " , UserType . Vendor ] ,
273
267
childUpdate : Checkbox . update ,
274
- childMsg : msg . value . msg ,
275
- mapChildMsg : ( value ) => ( {
276
- tag : "fieldCheckbox" ,
277
- value : { field : msg . value . field , msg : value }
278
- } )
268
+ childMsg : msg . value ,
269
+ mapChildMsg : ( value ) => adt ( "userTypeCheckboxVendor" , value )
270
+ } ) ;
271
+ case "fieldCheckboxFirstName" :
272
+ return component_ . base . updateChild ( {
273
+ state,
274
+ childStatePath : [ "fieldCheckboxes" , "firstName" ] ,
275
+ childUpdate : Checkbox . update ,
276
+ childMsg : msg . value ,
277
+ mapChildMsg : ( value ) => adt ( "fieldCheckboxFirstName" , value )
278
+ } ) ;
279
+ case "fieldCheckboxLastName" :
280
+ return component_ . base . updateChild ( {
281
+ state,
282
+ childStatePath : [ "fieldCheckboxes" , "lastName" ] ,
283
+ childUpdate : Checkbox . update ,
284
+ childMsg : msg . value ,
285
+ mapChildMsg : ( value ) => adt ( "fieldCheckboxLastName" , value )
286
+ } ) ;
287
+ case "fieldCheckboxEmail" :
288
+ return component_ . base . updateChild ( {
289
+ state,
290
+ childStatePath : [ "fieldCheckboxes" , "email" ] ,
291
+ childUpdate : Checkbox . update ,
292
+ childMsg : msg . value ,
293
+ mapChildMsg : ( value ) => adt ( "fieldCheckboxEmail" , value )
294
+ } ) ;
295
+ case "fieldCheckboxOrganizationName" :
296
+ return component_ . base . updateChild ( {
297
+ state,
298
+ childStatePath : [ "fieldCheckboxes" , "organizationName" ] ,
299
+ childUpdate : Checkbox . update ,
300
+ childMsg : msg . value ,
301
+ mapChildMsg : ( value ) => adt ( "fieldCheckboxOrganizationName" , value )
279
302
} ) ;
280
303
case "exportContactList" : {
281
304
// Build query parameters from checkbox states
@@ -428,10 +451,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
428
451
className = "mb-0"
429
452
state = { state . userTypeCheckboxes . GOV }
430
453
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
431
- adt ( "userTypeCheckbox" as const , {
432
- userType : UserType . Government as ToggleableUserType ,
433
- msg
434
- } )
454
+ adt ( "userTypeCheckboxGovernment" as const , msg )
435
455
) }
436
456
/>
437
457
< Checkbox . view
@@ -441,10 +461,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
441
461
className = "mb-0"
442
462
state = { state . userTypeCheckboxes . VENDOR }
443
463
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
444
- adt ( "userTypeCheckbox" as const , {
445
- userType : UserType . Vendor as ToggleableUserType ,
446
- msg
447
- } )
464
+ adt ( "userTypeCheckboxVendor" as const , msg )
448
465
) }
449
466
/>
450
467
</ div >
@@ -458,10 +475,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
458
475
className = "mb-0"
459
476
state = { state . fieldCheckboxes . firstName }
460
477
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
461
- adt ( "fieldCheckbox" as const , {
462
- field : "firstName" as const ,
463
- msg
464
- } )
478
+ adt ( "fieldCheckboxFirstName" as const , msg )
465
479
) }
466
480
/>
467
481
< Checkbox . view
@@ -471,7 +485,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
471
485
className = "mb-0"
472
486
state = { state . fieldCheckboxes . lastName }
473
487
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
474
- adt ( "fieldCheckbox " as const , { field : "lastName" as const , msg } )
488
+ adt ( "fieldCheckboxLastName " as const , msg )
475
489
) }
476
490
/>
477
491
< Checkbox . view
@@ -481,7 +495,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
481
495
className = "mb-0"
482
496
state = { state . fieldCheckboxes . email }
483
497
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
484
- adt ( "fieldCheckbox " as const , { field : "email" as const , msg } )
498
+ adt ( "fieldCheckboxEmail " as const , msg )
485
499
) }
486
500
/>
487
501
< Checkbox . view
@@ -491,10 +505,7 @@ const getModal: component_.page.GetModal<State, Msg> = (state) => {
491
505
className = "mb-0"
492
506
state = { state . fieldCheckboxes . organizationName }
493
507
dispatch = { component_ . base . mapDispatch ( dispatch , ( msg ) =>
494
- adt ( "fieldCheckbox" as const , {
495
- field : "organizationName" as const ,
496
- msg
497
- } )
508
+ adt ( "fieldCheckboxOrganizationName" as const , msg )
498
509
) }
499
510
/>
500
511
</ div >
0 commit comments