import { useTranslation } from "react-i18next"; import { FeatherArrowRight, FeatherBriefcase, FeatherBuilding2, FeatherCheckCircle, FeatherContact, FeatherCreditCard, FeatherUser, FeatherUsers, } from "@subframe/core"; import type { FirstStepsChecklistItemVM, WelcomeSetupVM } from "@hivegrid/view-models"; import Logo from "~/components/brand/Logo"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { EmptyState } from "~/ui/components/EmptyState"; import { IconWithBackground } from "~/ui/components/IconWithBackground"; import { Progress } from "~/ui/components/Progress"; import { StepperHorizontal } from "~/ui/components/StepperHorizontal"; export type WelcomeSetupPageProps = { readonly vm: WelcomeSetupVM; readonly homeHref: string; readonly actions: { readonly onOpen: (href: string) => void; readonly onDashboard: (href: string) => void; readonly onRetry?: () => void; }; }; const taskContent: Record = { profile: { descriptionKey: "onboarding.welcome.tasks.profile.description", actionKey: "onboarding.welcome.tasks.profile.action", icon: , }, team: { descriptionKey: "onboarding.welcome.tasks.team.description", actionKey: "onboarding.welcome.tasks.team.action", icon: , }, contacts: { descriptionKey: "onboarding.welcome.tasks.contacts.description", actionKey: "onboarding.welcome.tasks.contacts.action", icon: , }, projects: { descriptionKey: "onboarding.welcome.tasks.projects.description", actionKey: "onboarding.welcome.tasks.projects.action", icon: , }, billing: { descriptionKey: "onboarding.welcome.tasks.billing.description", actionKey: "onboarding.welcome.tasks.billing.action", icon: , }, }; function contentFor(item: FirstStepsChecklistItemVM) { return taskContent[item.block] ?? { descriptionKey: "onboarding.welcome.tasks.default.description", actionKey: "onboarding.welcome.tasks.default.action", icon: , }; } export function WelcomeSetupPage({ vm, homeHref, actions }: WelcomeSetupPageProps) { const { t } = useTranslation(); if (vm.status === "loading" || vm.status === "idle") { return (
); } if (vm.status === "error") { return (
{t("onboarding.welcome.error.title")} } body={t(vm.error.messageKey)} action={ actions.onRetry ? ( ) : undefined } />
); } if (vm.status === "empty" || !vm.data) { return (
{t("onboarding.welcome.empty.title")} } body={t("onboarding.welcome.empty.body")} action={} />
); } const { checklist } = vm.data; const greeting = vm.data.firstName ? t("onboarding.welcome.titleNamed", { firstName: vm.data.firstName }) : t("onboarding.welcome.title"); return (
{t("onboarding.welcome.activeBadge")}

{greeting}

{t("onboarding.welcome.description", { workspaceName: vm.data.workspaceName })}

} />

{t("onboarding.welcome.setupTitle")}

{t("onboarding.welcome.setupDescription")}

{t("onboarding.firstSteps.progressBadge", { completed: checklist.completedCount, total: checklist.totalCount })}
{checklist.items.map((item) => { const content = contentFor(item); const isNext = vm.data?.nextItem?.id === item.id; return (
: content.icon} />
{t(item.titleKey)} {t(content.descriptionKey)}
{item.completed ? ( {t("onboarding.firstSteps.completed")} ) : ( )}
); })}
} />

{t("onboarding.welcome.workspaceActive.title")}

{t("onboarding.welcome.workspaceActive.body", { workspaceName: vm.data.workspaceName })}

); }