@@ -490,6 +490,8 @@ export const createIndexFormSubmitted = (): IndexesThunkAction<
490490 return ( dispatch , getState , { track, preferences } ) => {
491491 // @experiment Early Journey Indexes Guidance & Awareness | Jira Epic: CLOUDP-239367
492492 const currentTab = getState ( ) . createIndex . currentTab ;
493+ const isQueryFlow = currentTab === 'QueryFlow' ;
494+ const indexSuggestions = getState ( ) . createIndex . indexSuggestions ;
493495 const { enableIndexesGuidanceExp, showIndexesGuidanceVariant } =
494496 preferences . getPreferences ( ) ;
495497
@@ -504,7 +506,17 @@ export const createIndexFormSubmitted = (): IndexesThunkAction<
504506 } ) ;
505507
506508 // Check for field errors.
507- if (
509+ if ( isQueryFlow ) {
510+ if ( ! indexSuggestions ) {
511+ // TODO in CLOUDP-311787: add info banner and update the current error banner to take in fetchingSuggestionsError as well
512+ dispatch (
513+ errorEncountered (
514+ 'No suggested index found. Please choose "Start with an Index" at the top to continue.'
515+ )
516+ ) ;
517+ return ;
518+ }
519+ } else if (
508520 getState ( ) . createIndex . fields . some (
509521 ( field : Field ) => field . name === '' || field . type === ''
510522 )
@@ -518,11 +530,19 @@ export const createIndexFormSubmitted = (): IndexesThunkAction<
518530 let spec : Record < string , IndexDirection > ;
519531
520532 try {
521- spec = Object . fromEntries (
522- getState ( ) . createIndex . fields . map ( ( field ) => {
523- return [ field . name , fieldTypeToIndexDirection ( field . type ) ] ;
524- } )
525- ) ;
533+ if ( isQueryFlow ) {
534+ // Gather from suggested index
535+ if ( indexSuggestions ) {
536+ spec = indexSuggestions ;
537+ }
538+ } else {
539+ // Gather from the index input fields
540+ spec = Object . fromEntries (
541+ getState ( ) . createIndex . fields . map ( ( field ) => {
542+ return [ field . name , fieldTypeToIndexDirection ( field . type ) ] ;
543+ } )
544+ ) ;
545+ }
526546 } catch ( e ) {
527547 dispatch ( errorEncountered ( ( e as any ) . message ) ) ;
528548 return ;
0 commit comments