keys.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. export const queryKeys = {
  2. users: {
  3. all: ['users'] as const,
  4. user: (userId: number) => ['user', userId] as const,
  5. lists: () => [...queryKeys.users.all, 'list'] as const,
  6. list: (params: unknown) => [...queryKeys.users.lists(), params] as const,
  7. details: () => [...queryKeys.users.all, 'detail'] as const,
  8. detail: (id: number | string) =>
  9. [...queryKeys.users.details(), id] as const,
  10. },
  11. posts: {
  12. all: ['posts'] as const,
  13. lists: () => [...queryKeys.posts.all, 'list'] as const,
  14. list: (params: unknown) => [...queryKeys.posts.lists(), params] as const,
  15. details: () => [...queryKeys.posts.all, 'detail'] as const,
  16. detail: (id: number | string) =>
  17. [...queryKeys.posts.details(), id] as const,
  18. },
  19. location: {
  20. all: ['location'] as const,
  21. provinces: ['location', 'provinces'] as const,
  22. cities: (provinceId: number | string) =>
  23. ['location', 'cities', provinceId] as const,
  24. },
  25. evaluations: {
  26. all: ['evaluations'] as const,
  27. lists: () => [...queryKeys.evaluations.all, 'list'] as const,
  28. list: (params: unknown) =>
  29. [...queryKeys.evaluations.lists(), params] as const,
  30. details: () => [...queryKeys.evaluations.all, 'detail'] as const,
  31. detail: (id: number | string) =>
  32. [...queryKeys.evaluations.details(), id] as const,
  33. items: () => [...queryKeys.evaluations.all, 'item'] as const,
  34. item: () => [...queryKeys.evaluations.items()] as const,
  35. },
  36. referralCodes: {
  37. all: ['referralCodes'] as const,
  38. lists: () => [...queryKeys.referralCodes.all, 'list'] as const,
  39. list: (params: unknown) =>
  40. [...queryKeys.referralCodes.lists(), params] as const,
  41. },
  42. activityFields: {
  43. all: ['activityFields'] as const,
  44. },
  45. permissions: {
  46. all: ['permissions'] as const,
  47. },
  48. admins: {
  49. all: ['admins'] as const,
  50. lists: () => [...queryKeys.admins.all, 'list'] as const,
  51. list: (params: unknown) => [...queryKeys.admins.lists(), params] as const,
  52. details: () => [...queryKeys.admins.all, 'detail'] as const,
  53. detail: (id: number | string) =>
  54. [...queryKeys.admins.details(), id] as const,
  55. },
  56. roles: {
  57. all: ['roles'] as const,
  58. lists: () => [...queryKeys.roles.all, 'list'] as const,
  59. list: (params: unknown) => [...queryKeys.roles.lists(), params] as const,
  60. details: () => [...queryKeys.roles.all, 'detail'] as const,
  61. detail: (id: number | string) =>
  62. [...queryKeys.roles.details(), id] as const,
  63. },
  64. }