Chart, ephemeris, reports, daily language, consult, and synastry read birth data only through resolveSubjectBirth. The current person is a request parameter outside Home(). /people replaces the settings chart pane, and deleting someone removes that person's chats and reports.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { BillingPaneTab, MembershipPlanAlias } from "@/lib/membership";
|
|
|
|
export const SETTINGS_QUERY_KEY = "settings";
|
|
|
|
export type SettingsQuery = {
|
|
readonly pane: "billing" | "chart";
|
|
readonly source: string | null;
|
|
readonly plan: MembershipPlanAlias | null;
|
|
readonly tab: BillingPaneTab | null;
|
|
};
|
|
|
|
export const CHART_SETTINGS_HREF = "/people";
|
|
|
|
const PLAN_ALIASES: ReadonlySet<string> = new Set(["trial", "monthly", "yearly"]);
|
|
const BILLING_TABS: ReadonlySet<string> = new Set(["membership", "credits", "redeem", "orders"]);
|
|
|
|
function searchParams(search: string) {
|
|
return new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
|
|
}
|
|
|
|
export function parseSettingsQuery(search: string): SettingsQuery | null {
|
|
const params = searchParams(search);
|
|
const pane = params.get(SETTINGS_QUERY_KEY);
|
|
if (pane === "chart") return { pane: "chart", source: null, plan: null, tab: null };
|
|
if (pane !== "billing") return null;
|
|
const planRaw = params.get("plan");
|
|
const tabRaw = params.get("tab");
|
|
return {
|
|
pane: "billing",
|
|
source: params.get("source"),
|
|
plan: planRaw && PLAN_ALIASES.has(planRaw) ? planRaw as MembershipPlanAlias : null,
|
|
tab: tabRaw && BILLING_TABS.has(tabRaw) ? tabRaw as BillingPaneTab : null,
|
|
};
|
|
}
|
|
|
|
export function stripSettingsQuery(search: string, pathname = "/") {
|
|
const params = searchParams(search);
|
|
params.delete(SETTINGS_QUERY_KEY);
|
|
params.delete("source");
|
|
params.delete("plan");
|
|
params.delete("tab");
|
|
const query = params.toString();
|
|
return query ? `${pathname}?${query}` : pathname || "/";
|
|
}
|