Files
accounted/lib/onboarding-journey/branch.ts
T
c7dd78b0a3 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>
2026-08-08 15:27:17 +02:00

48 lines
1.5 KiB
TypeScript

import type { InitialSetupPath } from '@/types'
/**
* The done-screen branch question ("Var fanns bokföringen innan?"): the one
* routing decision made at peak motivation, right after the company exists.
* Providers deep-link into the migration wizard; the SIE file goes straight
* to the upload step; a new business skips the import entirely and starts
* on Hem where the checklist points at the bank next.
*/
export type BranchChoice =
| 'fortnox'
| 'visma'
| 'bokio'
| 'bjornlunden'
| 'briox'
| 'sie'
| 'fresh'
| 'skip'
export const BRANCH_PROVIDERS: { id: BranchChoice; name: string; logo: string }[] = [
{ id: 'fortnox', name: 'Fortnox', logo: '/logos/fortnox.svg' },
{ id: 'visma', name: 'Visma', logo: '/logos/visma.jpeg' },
{ id: 'bokio', name: 'Bokio', logo: '/logos/bokio.png' },
{ id: 'bjornlunden', name: 'Björn Lundén', logo: '/logos/bjornlunden.png' },
{ id: 'briox', name: 'Briox', logo: '/logos/Briox_logo.png' },
]
export function branchDestination(choice: BranchChoice): {
/** initial_setup_path to persist; null = persist nothing (pure skip). */
path: InitialSetupPath | null
href: string
} {
switch (choice) {
case 'fortnox':
case 'visma':
case 'bokio':
case 'bjornlunden':
case 'briox':
return { path: 'migration', href: `/import?mode=migration&provider=${choice}` }
case 'sie':
return { path: 'migration', href: '/import?mode=sie' }
case 'fresh':
return { path: 'fresh', href: '/' }
case 'skip':
return { path: null, href: '/' }
}
}