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.

1016 B
Raw Blame
import { createFileRoute, redirect } from "@tanstack/react-router";
import { useTranslation } from "react-i18next";
import { OnboardingFlow } from "@/components/onboarding/onboarding-flow";
import PageTitle from "@/components/page-title";
import getWorkspaces from "@/fetchers/workspace/get-workspaces";
import { handleUnauthorized, isUnauthorizedError } from "@/lib/http-error";

export const Route = createFileRoute("/_layout/_authenticated/onboarding")({
  beforeLoad: async () => {
    let hasWorkspace = false;
    try {
      hasWorkspace = (await getWorkspaces()).length > 0;
    } catch (error) {
      if (isUnauthorizedError(error)) {
        handleUnauthorized();
        return;
      }
      throw error;
    }
    if (hasWorkspace) {
      throw redirect({ to: "/dashboard" });
    }
  },
  component: RouteComponent,
});

function RouteComponent() {
  const { t } = useTranslation();
  return (
    <>
      <PageTitle title={t("auth:onboarding.pageTitle")} />
      <OnboardingFlow />
    </>
  );
}