Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

2.0 KB
Raw Blame
import React from "react";
import { type TFunction } from "i18next";
import {
  type ConfigNavSection,
  type ConfigNavItem,
} from "@editor-core/components/shared/config/configNavSections";
import Plan from "@editor/components/shared/config/configSections/Plan";
import TeamSection from "@editor/components/shared/config/configSections/TeamSection";

/**
 * Shared cloud config nav-section builders, composed by both the saas (web) and
 * desktop (Tauri) nav wrappers. The Plan (wallet-driven PAYG dashboard + spend
 * cap) and Team sections are identical across platforms; each leaf owns its own
 * modal chrome and appends its leaf-only sections around these.
 */

type Translate = TFunction<"translation", undefined>;

/** The Plan (billing) nav item — wallet-driven PAYG dashboard + spend cap. */
export function createCloudPlanNavItem(t: Translate): ConfigNavItem {
  return {
    key: "plan",
    label: t("config.plan", "Plan"),
    description: t(
      "config.planDescription",
      "Your plan, credits and spend limit, and the invoices behind them.",
    ),
    icon: "credit-card",
    component: <Plan />,
  };
}

/**
 * The workspace roster — shared SaaS team management (invite/rename/members).
 *
 * Same key, name and route as the processor's roster, which supersedes this one
 * for anyone with processor access: gaining that access must not rename the
 * section or move it to a different URL under the reader.
 */
export function createCloudTeamNavItem(t: Translate): ConfigNavItem {
  return {
    key: "users",
    label: t("portal.nav.users", "Users"),
    description: t(
      "config.teamDescription",
      "Who shares this workspace, and invitations still waiting on an answer.",
    ),
    icon: "users",
    component: <TeamSection />,
  };
}

/** Billing nav section wrapping the Plan item, for leaves that group it (saas). */
export function createCloudBillingSection(t: Translate): ConfigNavSection {
  return {
    title: t("settings.billing.title", "Billing"),
    items: [createCloudPlanNavItem(t)],
  };
}