refactor(desktop): simplify onboarding routing structure
- Replace nested routes with single OnboardingPage component - Simplify Stepper to use numeric index instead of StepId Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
60467c4ad2
commit
f3c5068e74
2 changed files with 11 additions and 28 deletions
|
|
@ -7,11 +7,7 @@ import ToolsPage from './pages/tools'
|
|||
import SkillsPage from './pages/skills'
|
||||
import ChannelsPage from './pages/channels'
|
||||
import CronsPage from './pages/crons'
|
||||
import OnboardingLayout from './pages/onboarding/layout'
|
||||
import PermissionsStep from './pages/onboarding/permissions'
|
||||
import SetupStep from './pages/onboarding/setup'
|
||||
import TryItStep from './pages/onboarding/try-it'
|
||||
import ConnectStep from './pages/onboarding/connect'
|
||||
import OnboardingPage from './pages/onboarding'
|
||||
import { useOnboardingStore } from './stores/onboarding'
|
||||
|
||||
function OnboardingGuard({ children }: { children: React.ReactNode }) {
|
||||
|
|
@ -24,13 +20,7 @@ function OnboardingGuard({ children }: { children: React.ReactNode }) {
|
|||
const router = createHashRouter([
|
||||
{
|
||||
path: '/onboarding',
|
||||
element: <OnboardingLayout />,
|
||||
children: [
|
||||
{ index: true, element: <PermissionsStep /> },
|
||||
{ path: 'setup', element: <SetupStep /> },
|
||||
{ path: 'connect', element: <ConnectStep /> },
|
||||
{ path: 'try-it', element: <TryItStep /> },
|
||||
],
|
||||
element: <OnboardingPage />,
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
|
|
|
|||
|
|
@ -2,26 +2,19 @@ import { cn } from '@multica/ui/lib/utils'
|
|||
import { HugeiconsIcon } from '@hugeicons/react'
|
||||
import { Tick02Icon } from '@hugeicons/core-free-icons'
|
||||
|
||||
export type StepId = 'permissions' | 'setup' | 'connect' | 'try-it'
|
||||
|
||||
interface Step {
|
||||
id: StepId
|
||||
label: string
|
||||
}
|
||||
|
||||
const steps: Step[] = [
|
||||
{ id: 'permissions', label: 'Permissions' },
|
||||
{ id: 'setup', label: 'Provider' },
|
||||
{ id: 'connect', label: 'Connect' },
|
||||
{ id: 'try-it', label: 'Try it' },
|
||||
const steps = [
|
||||
{ label: 'Permissions' },
|
||||
{ label: 'Provider' },
|
||||
{ label: 'Connect' },
|
||||
{ label: 'Try it' },
|
||||
]
|
||||
|
||||
interface StepperProps {
|
||||
currentStep: StepId
|
||||
currentStep: number // 1-based index
|
||||
}
|
||||
|
||||
export function Stepper({ currentStep }: StepperProps) {
|
||||
const currentIndex = steps.findIndex((s) => s.id === currentStep)
|
||||
const currentIndex = currentStep - 1 // Convert to 0-based
|
||||
// Progress: 0% at step 0, 50% at step 1, 100% at step 2
|
||||
const progress = (currentIndex / (steps.length - 1)) * 100
|
||||
|
||||
|
|
@ -31,10 +24,10 @@ export function Stepper({ currentStep }: StepperProps) {
|
|||
<nav className="flex items-center justify-center gap-3">
|
||||
{steps.map((step, index) => {
|
||||
const isCompleted = index < currentIndex
|
||||
const isCurrent = step.id === currentStep
|
||||
const isCurrent = index === currentIndex
|
||||
|
||||
return (
|
||||
<div key={step.id} className="flex items-center gap-3">
|
||||
<div key={step.label} className="flex items-center gap-3">
|
||||
{index > 0 && (
|
||||
<span
|
||||
className={cn(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue