import { DEFAULT_MESSAGES } from "@/app/lib/i18n/defaultMessages"; import type { AdminMemberRank, AdminMemberStatus } from "@/app/lib/types"; // Label maps for the rank/status codes the backend actually returns // (MemberEnum.MemberRank / MemberEnum.MemberStatus). Raw codes are NEVER shown // to the user, and no tier is invented that the backend did not return. // Each code resolves to an i18n message code (floor entries in // defaultMessages.ts); components use t(code) for locale-aware rendering, and // the resolve* helpers below give the built-in English label for non-hook // contexts (xlsx export, tests). export const MEMBER_STATUS_LABEL_CODES: Record = { P: "MemberStatusPending", F: "MemberStatusFailed", Y: "MemberStatusActive", E: "MemberStatusExpired", N: "MemberStatusInactive", R: "MemberStatusResigned", S: "MemberStatusSuspended", T: "MemberStatusTerminated", }; /** Badge tone per status: Active positive, Pending warning, in-good-standing-lost states negative. */ export const MEMBER_STATUS_TONE: Record = { Y: "positive", P: "warning", N: "neutral", F: "negative", E: "negative", R: "negative", S: "negative", T: "negative", }; /** * Per-rank badge tint for the members table (babyboo-42). Theme chart tokens, so dark mode has its * own values. Ranks without an entry keep the neutral outline badge. */ export const MEMBER_RANK_BADGE_CLASS: Partial> = { OTTER: "border-transparent bg-chart-2/10 text-chart-2", SQUIRREL: "border-transparent bg-chart-3/10 text-chart-3", GIRAFFE: "border-transparent bg-chart-1/10 text-chart-1", }; export const MEMBER_RANK_LABEL_CODES: Record = { NA: "MemberRankNotApplicable", M: "MemberRankMember", OTTER: "MemberRankOtter", SQUIRREL: "MemberRankSquirrel", GIRAFFE: "MemberRankGiraffe", }; /** i18n message code for a status, or undefined when the code is not a known value. */ export function memberStatusLabelCode(status: AdminMemberStatus | undefined): string | undefined { return status ? MEMBER_STATUS_LABEL_CODES[status] : undefined; } /** i18n message code for a rank, or undefined when the code is not a known value. */ export function memberRankLabelCode(rank: AdminMemberRank | undefined): string | undefined { return rank ? MEMBER_RANK_LABEL_CODES[rank] : undefined; } /** Built-in English label for a status (used where a hook is not available). */ export function resolveMemberStatusLabel(status: AdminMemberStatus | undefined): string { const code = memberStatusLabelCode(status); return code ? DEFAULT_MESSAGES[code] : "—"; } /** Built-in English label for a rank (used where a hook is not available). */ export function resolveMemberRankLabel(rank: AdminMemberRank | undefined): string { const code = memberRankLabelCode(rank); return code ? DEFAULT_MESSAGES[code] : "—"; } /** Ranks members actually hold (live DB 2026-10-05); label is the i18n code, the page translates. */ export const MEMBER_RANK_FILTER_OPTIONS = (["OTTER", "SQUIRREL", "GIRAFFE"] as const).map(value => ({ value, label: MEMBER_RANK_LABEL_CODES[value], })); /** BABYBOO-50: the Members Status filter offers only Active and Inactive (PM, 2026-10-20). */ export const MEMBER_STATUS_FILTER_OPTIONS = (["Y", "N"] as const).map(value => ({ value, label: MEMBER_STATUS_LABEL_CODES[value], }));