@@ -5,79 +5,79 @@ type GARuntimeEnvironment = RuntimeEnvironment<{}, GASiteInstallationConfigurati
5
5
type GARuntimeContext = RuntimeContext < GARuntimeEnvironment > ;
6
6
7
7
type GASiteInstallationConfiguration = {
8
- tracking_id ?: string ;
8
+ tracking_id ?: string ;
9
9
} ;
10
10
11
11
type GAState = GASiteInstallationConfiguration ;
12
12
13
13
type GAProps = {
14
- siteInstallation : {
15
- configuration ?: GASiteInstallationConfiguration ;
16
- } ;
14
+ siteInstallation : {
15
+ configuration ?: GASiteInstallationConfiguration ;
16
+ } ;
17
17
} ;
18
18
19
19
export type GAAction = { action : 'save.config' } ;
20
20
21
21
export const configBlock = createComponent < GAProps , GAState , GAAction , GARuntimeContext > ( {
22
- componentId : 'config' ,
23
- initialState : ( props ) => {
24
- const siteInstallation = props . siteInstallation ;
25
- return {
26
- tracking_id : siteInstallation . configuration ?. tracking_id ?? '' ,
27
- } ;
28
- } ,
29
- action : async ( element , action , context ) => {
30
- switch ( action . action ) {
31
- case 'save.config' :
32
- const { api, environment } = context ;
33
- const siteInstallation = environment . siteInstallation ;
34
- if ( ! siteInstallation ) {
35
- throw Error ( 'No site installation found' ) ;
36
- }
22
+ componentId : 'config' ,
23
+ initialState : ( props ) => {
24
+ const siteInstallation = props . siteInstallation ;
25
+ return {
26
+ tracking_id : siteInstallation . configuration ?. tracking_id ?? '' ,
27
+ } ;
28
+ } ,
29
+ action : async ( element , action , context ) => {
30
+ switch ( action . action ) {
31
+ case 'save.config' :
32
+ const { api, environment } = context ;
33
+ const siteInstallation = environment . siteInstallation ;
34
+ if ( ! siteInstallation ) {
35
+ throw Error ( 'No site installation found' ) ;
36
+ }
37
37
38
- const configurationBody = {
39
- ...siteInstallation . configuration ,
40
- tracking_id : element . state . tracking_id ,
41
- } ;
42
- await api . integrations . updateIntegrationSiteInstallation (
43
- siteInstallation . integration ,
44
- siteInstallation . installation ,
45
- siteInstallation . site ,
46
- {
47
- configuration : {
48
- ...configurationBody ,
49
- } ,
50
- } ,
51
- ) ;
52
- return element ;
53
- }
54
- } ,
55
- render : async ( ) => {
56
- return (
57
- < configuration >
58
- < input
59
- label = "Client ID"
60
- hint = { < text > The unique identifier of your GA app client.</ text > }
61
- element = { < textinput state = "tracking_id" placeholder = "Tracking ID" /> }
62
- />
38
+ const configurationBody = {
39
+ ...siteInstallation . configuration ,
40
+ tracking_id : element . state . tracking_id ,
41
+ } ;
42
+ await api . integrations . updateIntegrationSiteInstallation (
43
+ siteInstallation . integration ,
44
+ siteInstallation . installation ,
45
+ siteInstallation . site ,
46
+ {
47
+ configuration : {
48
+ ...configurationBody ,
49
+ } ,
50
+ } ,
51
+ ) ;
52
+ return element ;
53
+ }
54
+ } ,
55
+ render : async ( ) => {
56
+ return (
57
+ < configuration >
58
+ < input
59
+ label = "Client ID"
60
+ hint = { < text > The unique identifier of your GA app client.</ text > }
61
+ element = { < textinput state = "tracking_id" placeholder = "Tracking ID" /> }
62
+ />
63
63
64
- < divider />
65
- < input
66
- label = ""
67
- hint = ""
68
- element = {
69
- < button
70
- style = "primary"
71
- disabled = { false }
72
- label = "Save"
73
- tooltip = "Save configuration"
74
- onPress = { {
75
- action : 'save.config' ,
76
- } }
77
- />
78
- }
79
- />
80
- </ configuration >
81
- ) ;
82
- } ,
64
+ < divider />
65
+ < input
66
+ label = ""
67
+ hint = ""
68
+ element = {
69
+ < button
70
+ style = "primary"
71
+ disabled = { false }
72
+ label = "Save"
73
+ tooltip = "Save configuration"
74
+ onPress = { {
75
+ action : 'save.config' ,
76
+ } }
77
+ />
78
+ }
79
+ />
80
+ </ configuration >
81
+ ) ;
82
+ } ,
83
83
} ) ;
0 commit comments