import type { Office } from "@/db/schema";

export const officeLabel: Record<Office, string> = { DUBLIN: "Dublin", BOSTON: "Boston", VANCOUVER: "Vancouver", REMOTE: "Remote" };
export const fullName = (p: { firstName: string; lastName: string }) => `${p.firstName} ${p.lastName}`.trim();
export const initials = (p: { firstName: string; lastName: string }) => `${p.firstName[0] ?? ""}${p.lastName[0] ?? ""}`.toUpperCase();
export const fmtDate = (d: Date | null | undefined, opts: Intl.DateTimeFormatOptions = { month: "short", year: "numeric" }) =>
  d ? new Intl.DateTimeFormat("en-IE", opts).format(d) : "";
export const yearsAt = (d: Date | null | undefined) => (d ? Math.max(0, Math.floor((Date.now() - d.getTime()) / (365.25 * 24 * 3600 * 1000))) : null);
