@@ -219,9 +219,11 @@ export function VercelOnboardingModal({
219219 const [ expandedEnvVars , setExpandedEnvVars ] = useState ( false ) ;
220220 const [ expandedSecretEnvVars , setExpandedSecretEnvVars ] = useState ( false ) ;
221221 const [ projectSelectionError , setProjectSelectionError ] = useState < string | null > ( null ) ;
222+ const [ isRedirecting , setIsRedirecting ] = useState ( false ) ;
222223
223224 const gitHubAppInstallations = onboardingData ?. gitHubAppInstallations ?? [ ] ;
224225 const isGitHubConnectedForOnboarding = onboardingData ?. isGitHubConnected ?? false ;
226+ const isOnboardingComplete = onboardingData ?. isOnboardingComplete ?? false ;
225227
226228 const hasTriggeredMarketplaceRedirectRef = useRef ( false ) ;
227229
@@ -235,19 +237,20 @@ export function VercelOnboardingModal({
235237 isOpen &&
236238 fromMarketplaceContext &&
237239 nextUrl &&
238- hasProjectSelected &&
240+ isOnboardingComplete &&
239241 isGitHubConnectedForOnboarding
240242 ) {
241243 hasTriggeredMarketplaceRedirectRef . current = true ;
242244 setTimeout ( ( ) => {
243245 window . location . href = nextUrl ;
244246 } , 100 ) ;
245247 }
246- } , [ isOpen , fromMarketplaceContext , nextUrl , hasProjectSelected , isGitHubConnectedForOnboarding ] ) ;
248+ } , [ isOpen , fromMarketplaceContext , nextUrl , isOnboardingComplete , isGitHubConnectedForOnboarding ] ) ;
247249
248250 useEffect ( ( ) => {
249251 if ( ! isOpen ) {
250252 hasTriggeredMarketplaceRedirectRef . current = false ;
253+ setIsRedirecting ( false ) ;
251254 }
252255 } , [ isOpen ] ) ;
253256
@@ -454,6 +457,10 @@ export function VercelOnboardingModal({
454457 } , [ vercelStagingEnvironment , envMappingFetcher , actionUrl ] ) ;
455458
456459 const handleBuildSettingsNext = useCallback ( ( ) => {
460+ if ( nextUrl && fromMarketplaceContext && isGitHubConnectedForOnboarding ) {
461+ setIsRedirecting ( true ) ;
462+ }
463+
457464 const formData = new FormData ( ) ;
458465 formData . append ( "action" , "complete-onboarding" ) ;
459466 formData . append ( "vercelStagingEnvironment" , vercelStagingEnvironment ? JSON . stringify ( vercelStagingEnvironment ) : "" ) ;
@@ -873,8 +880,8 @@ export function VercelOnboardingModal({
873880 setState ( "build-settings" ) ;
874881 }
875882 } }
876- disabled = { fromMarketplaceContext && completeOnboardingFetcher . state !== "idle" }
877- LeadingIcon = { fromMarketplaceContext && completeOnboardingFetcher . state !== "idle" ? SpinnerWhite : undefined }
883+ disabled = { fromMarketplaceContext && ( completeOnboardingFetcher . state !== "idle" || isRedirecting ) }
884+ LeadingIcon = { fromMarketplaceContext && ( completeOnboardingFetcher . state !== "idle" || isRedirecting ) ? SpinnerWhite : undefined }
878885 >
879886 { fromMarketplaceContext ? ( isGitHubConnectedForOnboarding ? "Finish" : "Next" ) : "Next" }
880887 </ Button >
@@ -923,8 +930,8 @@ export function VercelOnboardingModal({
923930 < Button
924931 variant = "primary/medium"
925932 onClick = { handleBuildSettingsNext }
926- disabled = { completeOnboardingFetcher . state !== "idle" }
927- LeadingIcon = { completeOnboardingFetcher . state !== "idle" ? SpinnerWhite : undefined }
933+ disabled = { completeOnboardingFetcher . state !== "idle" || isRedirecting }
934+ LeadingIcon = { completeOnboardingFetcher . state !== "idle" || isRedirecting ? SpinnerWhite : undefined }
928935 >
929936 { isGitHubConnectedForOnboarding ? "Finish" : "Next" }
930937 </ Button >
0 commit comments