MCPcopy Create free account
hub / github.com/Codehagen/Badget / getFilterDisplayValue

Function getFilterDisplayValue

src/lib/filter-utils.ts:111–137  ·  view source on GitHub ↗
(
  key: keyof TransactionFilters,
  value: unknown,
  options?: { accounts?: Account[]; categories?: Category[] }
)

Source from the content-addressed store, hash-verified

109}
110
111export function getFilterDisplayValue(
112 key: keyof TransactionFilters,
113 value: unknown,
114 options?: { accounts?: Account[]; categories?: Category[] }
115): string {
116 switch (key) {
117 case "status":
118 return value?.replace("_", " ").toLowerCase() || "";
119 case "type":
120 return value?.toLowerCase() || "";
121 case "accountId":
122 return (
123 options?.accounts?.find((a) => a.id === value)?.name || value || ""
124 );
125 case "categoryId":
126 return (
127 options?.categories?.find((c) => c.id === value)?.name || value || ""
128 );
129 case "startDate":
130 case "endDate":
131 return value instanceof Date ? value.toLocaleDateString() : "";
132 case "search":
133 return value || "";
134 default:
135 return String(value || "");
136 }
137}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected