Files
sorsfonalak/services/frontend/src/lib/synastry.ts
T

21 lines
896 B
TypeScript
Raw Normal View History

import type { ChartListItem, Synastry, SynastrySide } from "./types";
/** Short name of one side of a comparison: "Én" for the own chart. */
export function sideName(side: { label: string; is_primary?: boolean }): string {
return side.is_primary ? "Én" : side.label;
}
/** Whether a side's birth time is known (another user's chart has fewer fields). */
export function sideTimeKnown(side: SynastrySide): boolean {
const chart = side.chart as SynastrySide["chart"] & { time_known?: boolean };
return side.highlights?.time_known ?? chart.time?.time_known ?? chart.time_known ?? false;
}
/** Name of a chart in the comparison list, from the user's chart list. */
export function listName(ref: { id: string; label: string }, charts: ChartListItem[]): string {
const chart = charts.find((c) => c.id === ref.id);
return chart ? sideName(chart) : ref.label;
}
export type { Synastry };