diff --git a/frontend/src/pages/welcome/WelcomeStep2.tsx b/frontend/src/pages/welcome/WelcomeStep2.tsx index 1b803894..c5f84805 100644 --- a/frontend/src/pages/welcome/WelcomeStep2.tsx +++ b/frontend/src/pages/welcome/WelcomeStep2.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { Link, useNavigate } from 'react-router-dom' +import { useNavigate } from 'react-router-dom' import { Loader2 } from 'lucide-react' import { useAuthStore } from '@/store/authStore' import { onboardingApi, type PrimaryPsa } from '@/api/onboarding' @@ -14,21 +14,24 @@ const PSA_OPTIONS: { value: PrimaryPsa; label: string; description: string }[] = /** * `/welcome/step-2` — second step of the welcome wizard. Captures the PSA the - * shop primarily uses. Selecting a non-`none` tile reveals a quiet "Connect - * now" link that navigates out to `/account/integrations`. The wizard's - * primary action is "Continue" — credential entry is intentionally OUT of - * the wizard (per spec). + * shop primarily uses. Selecting a non-`none` tile splits the primary CTA + * into "Connect now" (routes to `/account/integrations` after saving) + * and "Connect later" (continues to step 3). Both paths persist the + * `primary_psa` choice before navigating. */ export function WelcomeStep2() { const navigate = useNavigate() const fetchUser = useAuthStore((s) => s.fetchUser) const [primaryPsa, setPrimaryPsa] = useState(null) - const [submitting, setSubmitting] = useState<'continue' | 'skip' | 'dismiss' | null>(null) + const [submitting, setSubmitting] = useState< + 'continue' | 'connect-now' | 'skip' | 'dismiss' | null + >(null) const [error, setError] = useState(null) const isBusy = submitting !== null const showConnectNow = primaryPsa !== null && primaryPsa !== 'none' + const selectedPsaLabel = PSA_OPTIONS.find((o) => o.value === primaryPsa)?.label const handleContinue = async () => { if (isBusy) return @@ -48,6 +51,24 @@ export function WelcomeStep2() { } } + const handleConnectNow = async () => { + if (isBusy || !showConnectNow) return + setError(null) + setSubmitting('connect-now') + try { + await onboardingApi.updateStep({ + step: 2, + action: 'complete', + data: { primary_psa: primaryPsa! }, + }) + await fetchUser() + navigate('/account/integrations') + } catch { + setError('Could not save. Please try again.') + setSubmitting(null) + } + } + const handleSkipStep = async () => { if (isBusy) return setError(null) @@ -131,42 +152,69 @@ export function WelcomeStep2() { })} - {showConnectNow && ( -
- - Connect now → - -
- )} - {error && (

{error}

)} -
- +
+ {showConnectNow ? ( + <> + + + + ) : ( + + )}