@@ -94,6 +94,9 @@ export default function StepsPreview() {
9494
9595 const [ error , setError ] = useState < boolean > ( false )
9696
97+ const [ createFlowWithSteps , { loading : isCreatingFlow } ] = useMutation (
98+ CREATE_FLOW_WITH_STEPS ,
99+ )
97100 const [ generateAiStepsMutation , { loading : isGeneratingSteps } ] =
98101 useMutation ( GENERATE_AI_STEPS )
99102
@@ -148,9 +151,10 @@ export default function StepsPreview() {
148151 navigate ,
149152 ] )
150153
151- const [ createFlowWithSteps , { loading : isCreatingFlow } ] = useMutation (
152- CREATE_FLOW_WITH_STEPS ,
153- )
154+ const retryGenerateAiSteps = useCallback ( async ( ) => {
155+ setError ( false )
156+ await generateAiSteps ( )
157+ } , [ generateAiSteps ] )
154158
155159 /** FOR EACH STEPS COMPUTATION */
156160 const forEachSteps = groupedSteps [ 0 ]
@@ -218,31 +222,35 @@ export default function StepsPreview() {
218222 } )
219223 }
220224
221- if ( isGeneratingSteps || ! output ) {
225+ if ( error ) {
222226 return (
223227 < Center h = "100%" >
224- { error ? (
225- < Flex
226- flexDir = "column"
227- alignItems = "center"
228- justifyContent = "center"
229- gap = { 4 }
230- w = "100%"
231- maxW = "400px"
232- >
233- < Text > Something went wrong</ Text >
234- < Button onClick = { ( ) => setError ( false ) } > Try again</ Button >
235- </ Flex >
236- ) : output && ! isGeneratingSteps ? (
237- < PrimarySpinner fontSize = "4xl" />
238- ) : (
239- < MultiStepLoader
240- loadingStates = { LOADING_STATES }
241- loading = { isGeneratingSteps }
242- duration = { 1500 }
243- loop = { false }
244- />
245- ) }
228+ < Flex
229+ flexDir = "column"
230+ alignItems = "center"
231+ justifyContent = "center"
232+ gap = { 4 }
233+ w = "100%"
234+ maxW = "400px"
235+ >
236+ < Text textStyle = "h4" fontWeight = "normal" >
237+ Something went wrong
238+ </ Text >
239+ < Button onClick = { retryGenerateAiSteps } > Try again</ Button >
240+ </ Flex >
241+ </ Center >
242+ )
243+ }
244+
245+ if ( isGeneratingSteps ) {
246+ return (
247+ < Center h = "100%" >
248+ < MultiStepLoader
249+ loadingStates = { LOADING_STATES }
250+ loading = { isGeneratingSteps }
251+ duration = { 1500 }
252+ loop = { false }
253+ />
246254 </ Center >
247255 )
248256 }
0 commit comments