Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1004 B
Raw Blame
import type { WorkspaceUsage } from "@/constants/onboarding";

export type OnboardingStepId =
  | "workspace"
  | "usage"
  | "project"
  | "invite"
  | "plan"
  | "ready";

type StepOptions = {
  usage: WorkspaceUsage;
  canInvite: boolean;
  offersPlan: boolean;
};

export function getOnboardingSteps({
  usage,
  canInvite,
  offersPlan,
}: StepOptions): OnboardingStepId[] {
  const steps: OnboardingStepId[] = ["workspace", "usage", "project"];
  if (usage === "team" && canInvite) steps.push("invite");
  steps.push(offersPlan ? "plan" : "ready");
  return steps;
}

export function getStepProgress(
  steps: OnboardingStepId[],
  current: OnboardingStepId,
) {
  const counted: OnboardingStepId[] = steps.filter((step) => step !== "ready");
  return {
    current: counted.indexOf(current) + 1,
    total: counted.length,
  };
}

export function getNextStep(
  steps: OnboardingStepId[],
  current: OnboardingStepId,
): OnboardingStepId {
  return steps[steps.indexOf(current) + 1] ?? "ready";
}