File tree Expand file tree Collapse file tree 2 files changed +29
-12
lines changed
Expand file tree Collapse file tree 2 files changed +29
-12
lines changed Original file line number Diff line number Diff line change 88import { fetchToken } from "./actions" ;
99
1010export default function Home ( ) {
11- const userId = "demo-32aaf9cd-5df0-4ffe-86b5-db43a61a842c" ; //gmail-new-email-received
11+ // const userId = "demo-32aaf9cd-5df0-4ffe-86b5-db43a61a842c"; //gmail-new-email-received
12+ const userId = "demo-937d4e64-100a-4e32-9dbb-a73c279e91b3" ; // goole_sheets add new row
1213 const client = createFrontendClient ( {
1314 environment : "development" ,
1415 externalUserId : userId ,
@@ -41,7 +42,7 @@ export default function Home() {
4142 < FrontendClientProvider client = { client } >
4243 < ComponentFormContainer
4344 userId = { userId }
44- componentKey = "gmail-new-email-received "
45+ componentKey = "google_sheets-add-single-row "
4546 configuredProps = { configuredProps }
4647 onUpdateDynamicProps = { handleDynamicProps }
4748 onUpdateConfiguredProps = { setConfiguredProps }
@@ -51,11 +52,11 @@ export default function Home() {
5152 try {
5253 const result = await client . runAction ( {
5354 userId,
54- actionId : "gmail-new-email-received " ,
55+ actionId : "google_sheets-add-single-row " ,
5556 configuredProps,
5657 dynamicPropsId,
5758 } ) ;
58- setSdkErrors ( result ?. os )
59+ setSdkErrors ( result )
5960 } catch ( error ) {
6061 setSdkErrors ( error as unknown )
6162 console . error ( "Action run failed:" , error ) ;
Original file line number Diff line number Diff line change @@ -439,7 +439,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
439439 } ;
440440
441441 const handleSdkErrors = ( o : unknown [ ] | unknown | undefined ) => {
442- const newErrors = [
442+ let newErrors = [
443443 ...sdkErrors ,
444444 ]
445445 if ( ! o ) return
@@ -496,17 +496,33 @@ export const FormContextProvider = <T extends ConfigurableProps>({
496496 // Handle HTTP errors thrown by the SDK
497497 try {
498498 const json = JSON . parse ( o . message )
499- const obs = json . data ?. observations || [ ]
500- if ( obs && obs . length > 0 ) {
501- newErrors . push (
502- ...obs ?. filter ( ( it ) => it . k === "error" )
503- . map ( handleObservationErrors )
504- . filter ( ( e ) => e !== undefined ) ,
505- )
499+ const data = json . data
500+ if ( data && "observations" in data ) {
501+ const obs = data . observations || [ ]
502+ if ( obs && obs . length > 0 ) {
503+ newErrors . push (
504+ ...obs ?. filter ( ( it ) => it . k === "error" )
505+ . map ( handleObservationErrors )
506+ . filter ( ( e ) => e !== undefined ) ,
507+ )
508+ }
509+ } else if ( data && "error" in data && "details" in data ) {
510+ newErrors . push ( {
511+ name : data . error ,
512+ message : JSON . stringify ( data . details ) ,
513+ // message: ` // TODO: It would be nice to render the JSON in markdown
514+ // \`\`\`json
515+ // ${JSON.stringify(data.details)}
516+ // \`\`\`
517+ // `,
518+ // })
519+ } )
506520 }
507521 } catch ( e ) {
508522 // pass
509523 }
524+ } else {
525+ newErrors = [ ]
510526 }
511527 setSdkErrors ( newErrors )
512528 }
You can’t perform that action at this time.
0 commit comments