Move frontend runtime constants out of types/ban.ts
This commit is contained in:
@@ -384,6 +384,8 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
|
||||
|
||||
**Docs changes needed:** None.
|
||||
|
||||
**Status:** Completed.
|
||||
|
||||
**Why this is needed:** The `types/` directory is meant to contain zero runtime code — only TypeScript type declarations that are erased at compile time. A runtime `const` object in a types file is confusing, breaks the "no runtime code in types/" rule, and pollutes the bundle with a lookup table alongside pure type transpile artifacts.
|
||||
|
||||
---
|
||||
|
||||
@@ -20,7 +20,7 @@ import type { BanOriginFilter, TimeRange } from "../types/ban";
|
||||
import {
|
||||
BAN_ORIGIN_FILTER_LABELS,
|
||||
TIME_RANGE_LABELS,
|
||||
} from "../types/ban";
|
||||
} from "../utils/constants";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Types
|
||||
|
||||
@@ -20,21 +20,6 @@ export type TimeRange = "24h" | "7d" | "30d" | "365d";
|
||||
*/
|
||||
export type BanOriginFilter = "all" | "blocklist" | "selfblock";
|
||||
|
||||
/** Human-readable labels for each origin filter option. */
|
||||
export const BAN_ORIGIN_FILTER_LABELS: Record<BanOriginFilter, string> = {
|
||||
all: "All",
|
||||
blocklist: "Blocklist",
|
||||
selfblock: "Selfblock",
|
||||
} as const;
|
||||
|
||||
/** Human-readable labels for each time-range preset. */
|
||||
export const TIME_RANGE_LABELS: Record<TimeRange, string> = {
|
||||
"24h": "Last 24 h",
|
||||
"7d": "Last 7 days",
|
||||
"30d": "Last 30 days",
|
||||
"365d": "Last 365 days",
|
||||
} as const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Ban-list table item
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
17
frontend/src/utils/constants.ts
Normal file
17
frontend/src/utils/constants.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Shared runtime constants used by the frontend UI.
|
||||
*/
|
||||
import type { BanOriginFilter, TimeRange } from "../types/ban";
|
||||
|
||||
export const BAN_ORIGIN_FILTER_LABELS: Record<BanOriginFilter, string> = {
|
||||
all: "All",
|
||||
blocklist: "Blocklist",
|
||||
selfblock: "Selfblock",
|
||||
} as const;
|
||||
|
||||
export const TIME_RANGE_LABELS: Record<TimeRange, string> = {
|
||||
"24h": "Last 24 h",
|
||||
"7d": "Last 7 days",
|
||||
"30d": "Last 30 days",
|
||||
"365d": "Last 365 days",
|
||||
} as const;
|
||||
Reference in New Issue
Block a user