@@ -33,7 +33,7 @@ const API_KEY_JSON_PLACEHOLDER = `{
33
33
"type": "service_account",
34
34
"project_id": "fleet-in-your-calendar",
35
35
"private_key_id": "<private key id>",
36
- "private_key": "-----BEGIN PRIVATE KEY-----\ n<private key>\n-----END PRIVATE KEY-----\n",
36
+ "private_key": "-----BEGIN PRIVATE KEY----\\ n<private key>\\ n-----END PRIVATE KEY-----\ \n",
37
37
"client_email": "fleet-calendar-events@fleet-in-your-calendar.iam.gserviceaccount.com",
38
38
"client_id": "<client id>",
39
39
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
@@ -103,7 +103,14 @@ const Calendars = (): JSX.Element => {
103
103
errors . apiKeyJson = "API key JSON must be present" ;
104
104
}
105
105
if ( ! curFormData . domain && ! ! curFormData . apiKeyJson ) {
106
- errors . apiKeyJson = "Domain must be present" ;
106
+ errors . domain = "Domain must be present" ;
107
+ }
108
+ if ( curFormData . apiKeyJson ) {
109
+ try {
110
+ JSON . parse ( curFormData . apiKeyJson ) ;
111
+ } catch ( e ) {
112
+ errors . apiKeyJson = e . message . toString ( ) ;
113
+ }
107
114
}
108
115
return errors ;
109
116
} ;
@@ -277,6 +284,7 @@ const Calendars = (): JSX.Element => {
277
284
placeholder = { API_KEY_JSON_PLACEHOLDER }
278
285
ignore1password
279
286
inputClassName = { `${ baseClass } __api-key-json` }
287
+ error = { formErrors . apiKeyJson }
280
288
/>
281
289
< InputField
282
290
label = "Primary domain"
@@ -301,6 +309,7 @@ const Calendars = (): JSX.Element => {
301
309
/>
302
310
</ >
303
311
}
312
+ error = { formErrors . domain }
304
313
/>
305
314
< Button
306
315
type = "submit"
0 commit comments