@@ -136,16 +136,8 @@ export default function OnboardingPage() {
136136 setStep ( 3 ) ;
137137 } ;
138138
139- const handleStep3 = async ( e : React . FormEvent ) => {
140- e . preventDefault ( ) ;
139+ const completeSetup = async ( skipInstance : boolean ) => {
141140 setError ( "" ) ;
142-
143- // Validate instance data
144- if ( ! instanceData . name . trim ( ) || ! instanceData . host . trim ( ) || ! instanceData . apiKey . trim ( ) ) {
145- setError ( "Instance name, host, and API key are required" ) ;
146- return ;
147- }
148-
149141 setLoading ( true ) ;
150142 setIsSubmitting ( true ) ; // Prevent going back once submission starts
151143
@@ -169,7 +161,7 @@ export default function OnboardingPage() {
169161 }
170162
171163 // Step 1: Create admin account
172- console . log ( "[Onboarding] Step 1/3 : Creating admin account..." ) ;
164+ console . log ( "[Onboarding] Step 1: Creating admin account..." ) ;
173165 const signUpResult = await signUp . email ( {
174166 email : adminData . email ,
175167 password : adminData . password ,
@@ -218,38 +210,42 @@ export default function OnboardingPage() {
218210 }
219211
220212 // Step 2: Create site
221- console . log ( "[Onboarding] Step 2/3 : Creating site..." ) ;
213+ console . log ( "[Onboarding] Step 2: Creating site..." ) ;
222214 const createdSite = await sessionService . createSite ( {
223215 name : siteData . name ,
224216 description : siteData . description || undefined ,
225217 } ) ;
226218
227219 console . log ( "[Onboarding] ✓ Site created" ) ;
228220
229- // Step 3: Create instance
230- console . log ( "[Onboarding] Step 3/3: Creating VyOS instance..." ) ;
231- const createdInstance = await sessionService . createInstance ( {
232- site_id : createdSite . id ,
233- name : instanceData . name ,
234- description : instanceData . description || undefined ,
235- host : instanceData . host ,
236- port : instanceData . port ,
237- api_key : instanceData . apiKey ,
238- vyos_version : instanceData . vyosVersion ,
239- protocol : instanceData . protocol ,
240- verify_ssl : instanceData . verifySsl ,
241- is_active : true ,
242- } ) ;
221+ // Step 3: Optionally create instance
222+ if ( ! skipInstance ) {
223+ console . log ( "[Onboarding] Step 3: Creating VyOS instance..." ) ;
224+ await sessionService . createInstance ( {
225+ site_id : createdSite . id ,
226+ name : instanceData . name ,
227+ description : instanceData . description || undefined ,
228+ host : instanceData . host ,
229+ port : instanceData . port ,
230+ api_key : instanceData . apiKey ,
231+ vyos_version : instanceData . vyosVersion ,
232+ protocol : instanceData . protocol ,
233+ verify_ssl : instanceData . verifySsl ,
234+ is_active : true ,
235+ } ) ;
236+
237+ console . log ( "[Onboarding] ✓ Instance created" ) ;
238+ } else {
239+ console . log ( "[Onboarding] Skipping instance creation" ) ;
240+ }
243241
244- console . log ( "[Onboarding] ✓ Instance created" ) ;
245242 console . log ( "[Onboarding] Setup complete! Redirecting to sites..." ) ;
246243
247244 // Note: Site ADMIN users (which the first user is) automatically have access
248245 // to all instances without needing explicit instance-level role assignments
249246
250- // Setup complete! Redirect to sites page
251- router . push ( "/sites" ) ;
252- router . refresh ( ) ;
247+ // Full page redirect so the session cookie is picked up cleanly
248+ window . location . href = "/sites" ;
253249 } catch ( err ) {
254250 console . error ( "[Onboarding] Error:" , err ) ;
255251 setError ( ( err as ApiError ) . message || "Failed to complete setup. Please try again." ) ;
@@ -259,6 +255,18 @@ export default function OnboardingPage() {
259255 }
260256 } ;
261257
258+ const handleStep3 = async ( e : React . FormEvent ) => {
259+ e . preventDefault ( ) ;
260+
261+ // Validate instance data
262+ if ( ! instanceData . name . trim ( ) || ! instanceData . host . trim ( ) || ! instanceData . apiKey . trim ( ) ) {
263+ setError ( "Instance name, host, and API key are required" ) ;
264+ return ;
265+ }
266+
267+ await completeSetup ( false ) ;
268+ } ;
269+
262270 // Show loading state while checking if onboarding is allowed
263271 if ( isCheckingAccess ) {
264272 return (
@@ -456,7 +464,7 @@ export default function OnboardingPage() {
456464 < div className = "text-center mb-6" >
457465 < h3 className = "text-xl font-semibold mb-2" > Step 3: Add Your First VyOS Instance</ h3 >
458466 < p className = "text-sm text-muted-foreground" >
459- Connect to your VyOS router
467+ Connect to your VyOS router, or skip this step and add one later from the Sites page
460468 </ p >
461469 </ div >
462470
@@ -574,6 +582,22 @@ export default function OnboardingPage() {
574582 >
575583 Back
576584 </ Button >
585+ < Button
586+ type = "button"
587+ variant = "secondary"
588+ onClick = { ( ) => completeSetup ( true ) }
589+ className = "flex-1"
590+ disabled = { loading || isSubmitting }
591+ >
592+ { loading && isSubmitting ? (
593+ < >
594+ < Loader2 className = "h-4 w-4 mr-2 animate-spin" />
595+ Completing Setup...
596+ </ >
597+ ) : (
598+ "Skip"
599+ ) }
600+ </ Button >
577601 < Button type = "submit" className = "flex-1" disabled = { loading || isSubmitting } >
578602 { loading ? (
579603 < >
0 commit comments