refactor(ui): use const type for requirement labels

This commit is contained in:
alejandrobailo
2026-07-22 15:19:30 +02:00
parent 33116f6a6d
commit 48ef053303
2 changed files with 15 additions and 4 deletions
@@ -13,7 +13,10 @@ import {
import { accountDisplayLabel } from "../_lib/cross-account-adapter";
import type { AccountStatusMap, CrossAccountAccountRef } from "../_types";
import { RequirementStatusSummary } from "./requirement-status-summary";
import {
REQUIREMENT_ENTITY_LABEL,
RequirementStatusSummary,
} from "./requirement-status-summary";
interface RequirementAccountChipsProps {
accounts: AccountStatusMap;
@@ -40,7 +43,7 @@ export const RequirementAccountChips = ({
if (entries.length > MAX_INLINE_ACCOUNT_CHIPS) {
return (
<RequirementStatusSummary
entityLabel="accounts"
entityLabel={REQUIREMENT_ENTITY_LABEL.ACCOUNTS}
entries={entries.map((account) => ({
key: account.id,
label: accountDisplayLabel(account),
@@ -30,6 +30,14 @@ const STATUS_ORDER: readonly CrossProviderStatus[] = ["FAIL", "MANUAL", "PASS"];
const SCROLLABLE_BREAKDOWN_MIN_ROWS = 13;
export const REQUIREMENT_ENTITY_LABEL = {
ACCOUNTS: "accounts",
PROVIDERS: "providers",
} as const;
type RequirementEntityLabel =
(typeof REQUIREMENT_ENTITY_LABEL)[keyof typeof REQUIREMENT_ENTITY_LABEL];
/**
* Aggregated per-status counts for a requirement row whose column axis has
* too many members to chip inline (many accounts of one provider type, or
@@ -39,10 +47,10 @@ const SCROLLABLE_BREAKDOWN_MIN_ROWS = 13;
*/
export const RequirementStatusSummary = ({
entries,
entityLabel = "providers",
entityLabel = REQUIREMENT_ENTITY_LABEL.PROVIDERS,
}: {
entries: RequirementStatusEntry[];
entityLabel?: "accounts" | "providers";
entityLabel?: RequirementEntityLabel;
}) => {
const counts = STATUS_ORDER.map((status) => ({
status,