wr: 시도,시군구 전체"0" 2건 조회현상 수정

This commit is contained in:
2026-09-21 17:51:09 +09:00
parent aafb326662
commit d7f101ee30
10 changed files with 255 additions and 93 deletions
@@ -0,0 +1,28 @@
type SelectDataInput = {
text?: string | null;
val?: string | number | null;
};
export type NormalizedSelectData = {
text: string;
val: string;
};
/** 선택 목록을 값 기준으로 중복 제거하고 프런트 표준 전체 항목을 한 번만 추가한다. */
export const normalizeSelectData = (
items: readonly SelectDataInput[],
): NormalizedSelectData[] => {
const uniqueItems = new Map<string, NormalizedSelectData>();
items.forEach((item) => {
const val = String(item.val ?? "").trim();
if (!val || val === "0" || uniqueItems.has(val)) return;
uniqueItems.set(val, {
text: String(item.text ?? ""),
val,
});
});
return [{ text: "전체", val: "0" }, ...uniqueItems.values()];
};