Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
86 lines
3.4 KiB
TypeScript
86 lines
3.4 KiB
TypeScript
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<AdminMemberStatus, string> = {
|
|
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<AdminMemberStatus, "positive" | "warning" | "negative" | "neutral"> = {
|
|
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<Record<AdminMemberRank, string>> = {
|
|
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<AdminMemberRank, string> = {
|
|
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],
|
|
}));
|