#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import { useEffect, useState } from "react";
import { useSettingsNav as useProprietarySettingsNav } from "@editor-proprietary/components/settings/useSettingsNav";
import type { SettingsNav } from "@editor/components/settings/settingsNavTypes";
import { connectionModeService } from "@editor/services/connectionModeService";
export type { SettingsNav };
/** Desktop billing opens on the web; existing Plan links land on its browser handoff. */
export function useSettingsNav(onLeave: () => void): SettingsNav {
const nav = useProprietarySettingsNav(onLeave);
const [connectionReady, setConnectionReady] = useState(false);
useEffect(() => {
let active = true;
void connectionModeService
.getCurrentMode()
.catch(() => undefined)
.finally(() => {
if (active) setConnectionReady(true);
});
return () => {
active = false;
};
}, []);
const hasBilling = nav.sections.some((group) =>
group.items.some((item) => item.key === "billing"),
);
return {
...nav,
pending: nav.pending || !connectionReady,
aliases: hasBilling
? { ...nav.aliases, plan: "billing", adminPlan: "billing" }
: nav.aliases,
};
}