2025-09-02 18:25:44 +09:00
|
|
|
/**
|
|
|
|
|
* React Query Key Factory
|
|
|
|
|
* 일관된 쿼리 키 관리를 위한 팩토리 함수들
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
export const queryKeys = {
|
|
|
|
|
// 카테고리 관련 쿼리 키
|
|
|
|
|
categories: {
|
|
|
|
|
all: ["categories"] as const,
|
|
|
|
|
lists: () => [...queryKeys.categories.all, "list"] as const,
|
|
|
|
|
list: (filters?: { active?: boolean; search?: string }) => [...queryKeys.categories.lists(), filters] as const,
|
2025-09-03 17:57:37 +09:00
|
|
|
infinite: (filters?: { active?: boolean; search?: string }) =>
|
|
|
|
|
[...queryKeys.categories.all, "infinite", filters] as const,
|
2025-09-03 18:23:23 +09:00
|
|
|
infiniteList: (filters?: { active?: boolean; search?: string }) =>
|
|
|
|
|
[...queryKeys.categories.all, "infiniteList", filters] as const,
|
2025-09-02 18:25:44 +09:00
|
|
|
details: () => [...queryKeys.categories.all, "detail"] as const,
|
|
|
|
|
detail: (categoryCode: string) => [...queryKeys.categories.details(), categoryCode] as const,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 코드 관련 쿼리 키
|
|
|
|
|
codes: {
|
|
|
|
|
all: ["codes"] as const,
|
|
|
|
|
lists: () => [...queryKeys.codes.all, "list"] as const,
|
|
|
|
|
list: (categoryCode: string, filters?: { active?: boolean; search?: string }) =>
|
|
|
|
|
[...queryKeys.codes.lists(), categoryCode, filters] as const,
|
2025-09-03 17:57:37 +09:00
|
|
|
infinite: (categoryCode: string, filters?: { active?: boolean; search?: string }) =>
|
|
|
|
|
[...queryKeys.codes.all, "infinite", categoryCode, filters] as const,
|
2025-09-03 18:23:23 +09:00
|
|
|
infiniteList: (categoryCode: string, filters?: { active?: boolean; search?: string }) =>
|
|
|
|
|
[...queryKeys.codes.all, "infiniteList", categoryCode, filters] as const,
|
2025-09-02 18:25:44 +09:00
|
|
|
details: () => [...queryKeys.codes.all, "detail"] as const,
|
|
|
|
|
detail: (categoryCode: string, codeValue: string) =>
|
|
|
|
|
[...queryKeys.codes.details(), categoryCode, codeValue] as const,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 옵션 관련 쿼리 키 (향후 화면관리 연계용)
|
|
|
|
|
options: {
|
|
|
|
|
all: ["options"] as const,
|
|
|
|
|
byCategory: (categoryCode: string) => [...queryKeys.options.all, categoryCode] as const,
|
|
|
|
|
},
|
|
|
|
|
|
2025-09-03 11:20:43 +09:00
|
|
|
// 검증 관련 쿼리 키
|
|
|
|
|
validation: {
|
|
|
|
|
all: ["validation"] as const,
|
|
|
|
|
categoryDuplicate: (field: string, value: string, excludeCode?: string) =>
|
|
|
|
|
[...queryKeys.validation.all, "category", field, value, excludeCode] as const,
|
|
|
|
|
codeDuplicate: (categoryCode: string, field: string, value: string, excludeCode?: string) =>
|
|
|
|
|
[...queryKeys.validation.all, "code", categoryCode, field, value, excludeCode] as const,
|
|
|
|
|
},
|
|
|
|
|
} as const;
|