Skip to content

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

826 B
Raw Blame
// Programmatic entry into the settings page from outside the router (cloud
// modals, onboarding checklists, service callbacks).

import type { NavKey } from "@editor/components/shared/config/types";
import { navigateToSettings } from "@editor/utils/settingsNavigation";

export function openAppSettings(targetKey: NavKey, notice?: string) {
  try {
    navigateToSettings(targetKey);
    // The Plan section shows why the caller sent the user here (e.g. "Not
    // enough credits"), and only it listens.
    if (notice) {
      window.dispatchEvent(
        new CustomEvent("appConfig:notice", {
          detail: { key: targetKey, notice },
        }),
      );
    }
  } catch (_e) {
    // no-op on SSR or test environments
  }
}

export function openPlanSettings(notice?: string) {
  openAppSettings("plan", notice);
}