feat(onboarding): branch question on the journey done screen (#1468)

* feat(onboarding): branch question on the journey done screen

Second slice of the approved activation concept: the moment the company
exists, the done screen asks "Var fanns bokföringen innan?" with
provider chips (real logos), SIE file, and new-business options, plus a
quiet look-around escape. Choices persist initial_setup_path
(fire-and-forget) and deep-link into the existing flows: providers jump
straight to the migration wizard's connect step (sieViaApi providers
only; Visma/Bokio land on the provider list where the SIE-first gate
lives), the SIE chip opens the upload step, new business lands on Hem
with step one checked off.

mode='add' keeps the plain "Öppna Accounted" button: the concept's own
guard, and it avoids writing the path onto the previous company if
setActiveCompany silently failed. Routing lives in a pure helper with
tests; anonymous onboarding_branch_chosen funnel event follows the
guarded capture pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(onboarding): review triage: single-choice latch, preselect reset

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: restore package-lock.json to main (worktree npm install mutated it)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-08-08 15:27:17 +02:00
committed by GitHub
co-authored by Claude Fable 5 Jakob Wennberg
parent 44cff5e5e4
commit c7dd78b0a3
9 changed files with 252 additions and 9 deletions
@@ -1,6 +1,6 @@
'use client'
import { useState, useCallback, useEffect } from 'react'
import { useState, useCallback, useEffect, useRef } from 'react'
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Progress } from '@/components/ui/progress'
@@ -1799,7 +1799,13 @@ function EntityResultRow({
// ── Main wizard ─────────────────────────────────────────────────
export default function ArcimMigrationWorkspace(_props: WorkspaceComponentProps) {
export default function ArcimMigrationWorkspace({
initialProvider,
}: WorkspaceComponentProps & {
/** Deep-linked old system (onboarding branch question): jump straight to
* its connect step instead of showing the provider list. */
initialProvider?: string
}) {
const { toast } = useToast()
const [step, setStep] = useState<WizardStep>('provider')
@@ -2129,6 +2135,22 @@ export default function ArcimMigrationWorkspace(_props: WorkspaceComponentProps)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// Deep-linked provider preselect (onboarding branch question). Only when
// this mount is not an OAuth return (that flow owns the wizard state), and
// only for providers whose SIE comes via API: visma/bokio must first see
// the provider list with its "SIE krävs först" gate, which depends on
// async connection status.
const preselectedRef = useRef(false)
useEffect(() => {
if (preselectedRef.current || !initialProvider) return
if (new URL(window.location.href).searchParams.get('migration')) return
const provider = ARCIM_PROVIDERS.find((p) => p.id === initialProvider)
if (!provider || COMING_SOON_PROVIDERS.has(provider.id) || !provider.sieViaApi) return
preselectedRef.current = true
void handleSelectProvider(provider.id)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialProvider])
// Listen for postMessage from OAuth popup
useEffect(() => {
function handleMessage(event: MessageEvent) {