@gen-epix/ui-client-common 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/README.md +5 -4
  2. package/dist/@types/mui.d.ts +13 -5
  3. package/dist/@types/ui-client-common.d.ts +1 -0
  4. package/dist/_chunks/ApplicationFooter.js +45 -46
  5. package/dist/_chunks/ApplicationFooter.js.map +1 -1
  6. package/dist/_chunks/Breadcrumbs.js +14 -15
  7. package/dist/_chunks/CrudPage.js +301 -302
  8. package/dist/_chunks/CrudPage.js.map +1 -1
  9. package/dist/_chunks/GeoFilter.js +1 -2
  10. package/dist/_chunks/GeoFilter.js.map +1 -1
  11. package/dist/_chunks/Notifications.js +52 -53
  12. package/dist/_chunks/OutageList.js +30 -31
  13. package/dist/_chunks/OutageList.js.map +1 -1
  14. package/dist/_chunks/OutageUtil.js +4 -8
  15. package/dist/_chunks/OutageUtil.js.map +1 -1
  16. package/dist/_chunks/QueryClientProvider.js +1 -2
  17. package/dist/_chunks/QueryClientProvider.js.map +1 -1
  18. package/dist/_chunks/QueryClientService.js +101 -395
  19. package/dist/_chunks/QueryClientService.js.map +1 -1
  20. package/dist/_chunks/Reflect.js +1 -2
  21. package/dist/_chunks/Table.js +523 -522
  22. package/dist/_chunks/Table.js.map +1 -1
  23. package/dist/_chunks/TableUtil.js +10 -20
  24. package/dist/_chunks/TableUtil.js.map +1 -1
  25. package/dist/_chunks/TextFilter.js +18 -20
  26. package/dist/_chunks/TextFilter.js.map +1 -1
  27. package/dist/_chunks/UserInvitationsAdminPage.js +78 -79
  28. package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
  29. package/dist/_chunks/UserManagerUtil.js +212 -213
  30. package/dist/_chunks/UserManagerUtil.js.map +1 -1
  31. package/dist/_chunks/_baseAssignValue.js +1 -2
  32. package/dist/_chunks/_baseFlatten.js +9 -10
  33. package/dist/_chunks/_baseFlatten.js.map +1 -1
  34. package/dist/_chunks/_baseGet.js +279 -0
  35. package/dist/_chunks/_baseGet.js.map +1 -0
  36. package/dist/_chunks/_baseIteratee.js +273 -0
  37. package/dist/_chunks/_baseIteratee.js.map +1 -0
  38. package/dist/_chunks/_baseUnset.js +22 -300
  39. package/dist/_chunks/_baseUnset.js.map +1 -1
  40. package/dist/_chunks/_cacheHas.js +1 -2
  41. package/dist/_chunks/_setToString.js +1 -2
  42. package/dist/_chunks/decorate.js +1 -2
  43. package/dist/_chunks/decorateParam.js +1 -2
  44. package/dist/_chunks/format.js +27 -54
  45. package/dist/_chunks/format.js.map +1 -1
  46. package/dist/_chunks/isArrayLike.js +1 -2
  47. package/dist/_chunks/isObject.js +1 -2
  48. package/dist/_chunks/isSymbol.js +1 -2
  49. package/dist/_chunks/last.js +12 -0
  50. package/dist/_chunks/last.js.map +1 -0
  51. package/dist/_chunks/middleware.js +2 -3
  52. package/dist/_chunks/middleware.js.map +1 -1
  53. package/dist/_chunks/omit.js +42 -42
  54. package/dist/_chunks/omit.js.map +1 -1
  55. package/dist/_chunks/query.js +8 -15
  56. package/dist/_chunks/query.js.map +1 -1
  57. package/dist/_chunks/react.js +2 -3
  58. package/dist/_chunks/react.js.map +1 -1
  59. package/dist/_chunks/rolldown-runtime.js +2 -3
  60. package/dist/_chunks/tableStore.js +231 -224
  61. package/dist/_chunks/tableStore.js.map +1 -1
  62. package/dist/_chunks/toDate.js +8 -14
  63. package/dist/_chunks/toDate.js.map +1 -1
  64. package/dist/_chunks/uniq.js +43 -0
  65. package/dist/_chunks/uniq.js.map +1 -0
  66. package/dist/_chunks/useColumnsMenu.js +3 -6
  67. package/dist/_chunks/useColumnsMenu.js.map +1 -1
  68. package/dist/_chunks/useMutation.js +24 -26
  69. package/dist/_chunks/useMutation.js.map +1 -1
  70. package/dist/_chunks/useQueryMemo.js +33 -22
  71. package/dist/_chunks/useQueryMemo.js.map +1 -1
  72. package/dist/_chunks/vanilla.js +1 -2
  73. package/dist/_chunks/vanilla.js.map +1 -1
  74. package/dist/_chunks/yup.js +2 -4
  75. package/dist/_chunks/yup.js.map +1 -1
  76. package/dist/classes/TableEventBus/index.js +1 -2
  77. package/dist/classes/abstracts/FilterAbstract/index.js +4 -3
  78. package/dist/classes/abstracts/FilterAbstract/index.js.map +1 -1
  79. package/dist/classes/filters/MultiSelectFilter.d.ts +1 -1
  80. package/dist/classes/services/AuthenticationService/AuthenticationService.d.ts +1 -1
  81. package/dist/classes/services/AuthenticationService/index.js +15 -16
  82. package/dist/classes/services/AuthenticationService/index.js.map +1 -1
  83. package/dist/classes/services/AuthorizationService/index.js +5 -6
  84. package/dist/classes/services/AuthorizationService/index.js.map +1 -1
  85. package/dist/classes/services/BackendVersionService/index.js +4 -4
  86. package/dist/classes/services/BackendVersionService/index.js.map +1 -1
  87. package/dist/classes/services/BreadcrumbService/index.js +16 -39
  88. package/dist/classes/services/BreadcrumbService/index.js.map +1 -1
  89. package/dist/classes/services/EmotionCacheService/index.js +10 -10
  90. package/dist/classes/services/EmotionCacheService/index.js.map +1 -1
  91. package/dist/classes/services/FeatureFlagsService/index.js +1 -2
  92. package/dist/classes/services/I18nService/index.js +12 -12
  93. package/dist/classes/services/I18nService/index.js.map +1 -1
  94. package/dist/classes/services/InactivityService/index.js +13 -14
  95. package/dist/classes/services/InactivityService/index.js.map +1 -1
  96. package/dist/classes/services/LogService/index.js +40 -35
  97. package/dist/classes/services/LogService/index.js.map +1 -1
  98. package/dist/classes/services/NavigationHistoryService/index.js +1 -2
  99. package/dist/classes/services/NotificationService/index.js +9 -10
  100. package/dist/classes/services/NotificationService/index.js.map +1 -1
  101. package/dist/classes/services/PageEventBusService/index.js +14 -11
  102. package/dist/classes/services/PageEventBusService/index.js.map +1 -1
  103. package/dist/classes/services/RouterService/index.js +4 -8
  104. package/dist/classes/services/RouterService/index.js.map +1 -1
  105. package/dist/classes/services/UserSettingsService/index.js +1 -2
  106. package/dist/components/app/App/App.d.ts +1 -1
  107. package/dist/components/app/App/index.js +35 -40
  108. package/dist/components/app/App/index.js.map +1 -1
  109. package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +29 -30
  110. package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
  111. package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js +48 -47
  112. package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
  113. package/dist/components/app/AuthenticationWrapper/index.js +36 -37
  114. package/dist/components/app/AuthenticationWrapper/index.js.map +1 -1
  115. package/dist/components/app/AuthorizationWrapper/index.js +20 -21
  116. package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
  117. package/dist/components/app/RouterRoot/index.js +53 -52
  118. package/dist/components/app/RouterRoot/index.js.map +1 -1
  119. package/dist/components/epi/EpiContactDetailsDialog/index.js +22 -23
  120. package/dist/components/filters/BooleanFilterField/index.js +6 -7
  121. package/dist/components/filters/DateFilterField/index.js +4 -5
  122. package/dist/components/filters/GeoFilterField/index.js +5 -6
  123. package/dist/components/filters/MultiSelectFilterField/index.js +5 -6
  124. package/dist/components/filters/NumberRangeFilterField/index.js +4 -5
  125. package/dist/components/filters/TextFilterField/index.js +4 -5
  126. package/dist/components/ui/ApplicationBar/index.js +189 -190
  127. package/dist/components/ui/ApplicationBar/index.js.map +1 -1
  128. package/dist/components/ui/ConsentDialog/index.js +1 -2
  129. package/dist/components/ui/GenericErrorMessage/index.js +30 -31
  130. package/dist/components/ui/LicensesDialog/index.js +39 -40
  131. package/dist/components/ui/LicensesDialog/index.js.map +1 -1
  132. package/dist/components/ui/MyPermissionsDialog/index.js +17 -18
  133. package/dist/components/ui/NavLink/index.js +7 -8
  134. package/dist/components/ui/OrganizationSwitcherDialog/index.js +22 -23
  135. package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
  136. package/dist/components/ui/OutagesDialog/index.js +1 -2
  137. package/dist/components/ui/PageContainer/index.js +25 -26
  138. package/dist/components/ui/PageContainer/index.js.map +1 -1
  139. package/dist/components/ui/ResponseHandler/index.js +1 -2
  140. package/dist/components/ui/Sidebar/index.js +31 -32
  141. package/dist/components/ui/UserFeedbackDialog/index.js +13 -14
  142. package/dist/components/ui/UserInactivityConfirmation/index.js +1 -2
  143. package/dist/constants/api.constants.js +1 -2
  144. package/dist/constants/config.constants.d.ts +0 -2
  145. package/dist/constants/config.constants.js +3 -4
  146. package/dist/constants/config.constants.js.map +1 -1
  147. package/dist/constants/query.constants.js +1 -2
  148. package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js +13 -14
  149. package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js.map +1 -1
  150. package/dist/dataHooks/useIdentifierIssuerQuery/index.js +15 -16
  151. package/dist/dataHooks/useIdentifierIssuerQuery/index.js.map +1 -1
  152. package/dist/dataHooks/useInviteUserConstraintsQuery/index.js +13 -14
  153. package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
  154. package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js +14 -15
  155. package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js.map +1 -1
  156. package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js +5 -6
  157. package/dist/dataHooks/useOrganizationsQuery/index.js +14 -15
  158. package/dist/dataHooks/useOrganizationsQuery/index.js.map +1 -1
  159. package/dist/dataHooks/useUsersQuery/index.js +11 -12
  160. package/dist/dataHooks/useUsersQuery/index.js.map +1 -1
  161. package/dist/hoc/withPermissions/index.js +1 -2
  162. package/dist/hooks/useConfig/index.js +3 -4
  163. package/dist/hooks/useConfig/index.js.map +1 -1
  164. package/dist/hooks/useCreateMutation/index.js +13 -14
  165. package/dist/hooks/useCreateMutation/index.js.map +1 -1
  166. package/dist/hooks/useDeleteMutation/index.js +17 -11
  167. package/dist/hooks/useDeleteMutation/index.js.map +1 -1
  168. package/dist/hooks/useEditMutation/index.js +49 -35
  169. package/dist/hooks/useEditMutation/index.js.map +1 -1
  170. package/dist/hooks/useInitializeTableStore/index.js +1 -2
  171. package/dist/hooks/useItemQuery/index.js +5 -6
  172. package/dist/hooks/useItemQuery/index.js.map +1 -1
  173. package/dist/hooks/useUpdateBreadcrumb/index.js +1 -2
  174. package/dist/hooks/useUpdateDocumentTitle/index.js +1 -2
  175. package/dist/locale/en.json +1 -0
  176. package/dist/locale/nl.json +1 -0
  177. package/dist/models/admin.models.js +1 -2
  178. package/dist/models/admin.models.js.map +1 -1
  179. package/dist/models/config.models.d.ts +1 -5
  180. package/dist/models/table.models.js +1 -2
  181. package/dist/models/table.models.js.map +1 -1
  182. package/dist/models/theme.models.d.ts +19 -16
  183. package/dist/pages/AcceptInvitationPage/index.js +26 -27
  184. package/dist/pages/AcceptInvitationPage/index.js.map +1 -1
  185. package/dist/pages/AdminPage/index.js +17 -18
  186. package/dist/pages/ChooseIdentityProviderPage/index.js +22 -23
  187. package/dist/pages/ErrorPage/index.js +1 -2
  188. package/dist/pages/IdentifierIssuersAdminPage/index.js +6 -7
  189. package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +6 -7
  190. package/dist/pages/OrganizationContactsAdminPage/index.js +7 -8
  191. package/dist/pages/OrganizationSitesAdminPage/index.js +10 -11
  192. package/dist/pages/OrganizationsAdminPage/index.js +14 -15
  193. package/dist/pages/OrganizationsAdminPage/index.js.map +1 -1
  194. package/dist/pages/OutagesAdminPage/index.js +21 -22
  195. package/dist/pages/PostLoginPage/index.js +8 -9
  196. package/dist/pages/PostLoginPage/index.js.map +1 -1
  197. package/dist/pages/PostLogoutPage/index.js +9 -10
  198. package/dist/pages/RouterErrorPage/index.js +1 -2
  199. package/dist/pages/UsersAdminPage/index.js +40 -41
  200. package/dist/pages/UsersAdminPage/index.js.map +1 -1
  201. package/dist/routes/index.js +1 -2
  202. package/dist/setup/setup.js +12 -6
  203. package/dist/setup/setup.js.map +1 -1
  204. package/dist/stores/oidcStore/index.js +1 -2
  205. package/dist/stores/outagesStore/index.js +1 -2
  206. package/dist/theme/demoTheme/index.js +18 -17
  207. package/dist/theme/demoTheme/index.js.map +1 -1
  208. package/dist/utils/AxiosUtil/index.js +1 -2
  209. package/dist/utils/DataHookUtil/index.js +2 -3
  210. package/dist/utils/DataHookUtil/index.js.map +1 -1
  211. package/dist/utils/DependencyContainerUtil/DependencyContainerUtil.d.ts +2 -3
  212. package/dist/utils/DependencyContainerUtil/index.js +10 -16
  213. package/dist/utils/DependencyContainerUtil/index.js.map +1 -1
  214. package/dist/utils/LoadableUtil/index.js +1 -2
  215. package/dist/utils/MenuDataUtil/index.js +2 -3
  216. package/dist/utils/MenuDataUtil/index.js.map +1 -1
  217. package/dist/utils/NotificationUtil/index.js +1 -2
  218. package/dist/utils/StandardConfigUtil/index.js +1 -6
  219. package/dist/utils/StandardConfigUtil/index.js.map +1 -1
  220. package/dist/utils/TimeUtil/index.js +2 -3
  221. package/dist/utils/TimeUtil/index.js.map +1 -1
  222. package/dist/utils/UserUtil/index.js +1 -2
  223. package/package.json +26 -29
  224. package/dist/context/ClientCommonConfigContext/ClientCommonConfigContext.d.ts +0 -9
  225. package/dist/context/ClientCommonConfigContext/ClientCommonConfigContextProvider.d.ts +0 -6
  226. package/dist/context/ClientCommonConfigContext/index.d.ts +0 -3
  227. package/dist/context/ClientCommonConfigContext/index.js +0 -34
  228. package/dist/context/ClientCommonConfigContext/index.js.map +0 -1
  229. package/dist/context/ClientCommonConfigContext/useClientCommonConfigContext.d.ts +0 -3
@@ -1,24 +1,23 @@
1
1
  import { UserUtil as e } from "../../utils/UserUtil/index.js";
2
- import { t } from "../../_chunks/QueryClientService.js";
3
- import { t as n } from "../../_chunks/useQueryMemo.js";
4
- import { DataHookUtil as r } from "../../utils/DataHookUtil/index.js";
5
- import { API_ORGANIZATION_TOKEN as i } from "../../constants/api.constants.js";
2
+ import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
3
+ import { API_ORGANIZATION_TOKEN as n } from "../../constants/api.constants.js";
4
+ import { t as r } from "../../_chunks/useQueryMemo.js";
5
+ import { t as i } from "../../_chunks/QueryClientService.js";
6
6
  import { COMMON_QUERY_KEY as a } from "../../constants/query.constants.js";
7
7
  import { container as o } from "tsyringe";
8
8
  import { useMemo as s } from "react";
9
9
  import { useTranslation as c } from "react-i18next";
10
- //#region src/dataHooks/useUsersQuery/useUsersQuery.ts
11
- var l = () => n({
12
- queryFn: async ({ signal: e }) => (await o.resolve(i).usersGetAll(null, null, { signal: e })).data,
13
- queryKey: o.resolve(t).getGenericKey(a.USERS)
10
+ // src/dataHooks/useUsersQuery/useUsersQuery.ts
11
+ var l = () => r({
12
+ queryFn: async ({ signal: e }) => (await o.resolve(n).usersGetAll(null, null, { signal: e })).data,
13
+ queryKey: o.resolve(i).getGenericKey(a.USERS)
14
14
  }), u = () => {
15
15
  let e = l();
16
- return s(() => r.createUseMapDataHook(e, (e) => e.id), [e]);
16
+ return s(() => t.createUseMapDataHook(e, (e) => e.id), [e]);
17
17
  }, d = () => {
18
- let t = l(), { t: n } = c();
19
- return s(() => r.createUseOptionsDataHook(t, (e) => e.id, (t) => e.getUserDisplayValue(t, n)), [n, t]);
18
+ let n = l(), { t: r } = c();
19
+ return s(() => t.createUseOptionsDataHook(n, (e) => e.id, (t) => e.getUserDisplayValue(t, r)), [r, n]);
20
20
  };
21
- //#endregion
22
21
  export { d as useUserOptionsQuery, u as useUsersMapQuery, l as useUsersQuery };
23
22
 
24
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useQueryMemo","useUsersQuery","container","API_ORGANIZATION_TOKEN","QueryClientService","COMMON_QUERY_KEY","useUsersMapQuery","usersQuery","useMemo","DataHookUtil","item","useUserOptionsQuery","useTranslation","UserUtil","t"],"sources":["../../../src/dataHooks/useUsersQuery/useUsersQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useTranslation } from 'react-i18next';\nimport { useMemo } from 'react';\nimport type { CommonDbUser } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { UserUtil } from '../../utils/UserUtil';\n\nexport const useUsersQuery = (): UseQueryResult<CommonDbUser[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).usersGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USERS),\n });\n};\n\nexport const useUsersMapQuery = (): UseMap<CommonDbUser> => {\n const usersQuery = useUsersQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbUser>(usersQuery, item => item.id);\n }, [usersQuery]);\n};\n\nexport const useUserOptionsQuery = (): UseOptions<string> => {\n const usersQuery = useUsersQuery();\n const { t } = useTranslation();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbUser>(usersQuery, item => item.id, item => UserUtil.getUserDisplayValue(item, t));\n }, [t, usersQuery]);\n};\n"],"mappings":";;;;;;;;;;AAiBA,IAAaC,UACJD,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBE,EAAU,QAAQC,CAAsB,CAAC,CAAC,YAAY,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CACnF;CAElB,UAAUD,EAAU,QAAQE,CAAkB,CAAC,CAAC,cAAcC,EAAiB,KAAK;AACtF,CAAC,GAGUC,UAA+C;CAC1D,IAAMC,IAAaN,EAAc;CAEjC,OAAOO,QACEC,EAAa,qBAAmCF,IAAY,MAAQG,EAAK,EAAE,GACjF,CAACH,CAAU,CAAC;AACjB,GAEaI,UAAgD;CAC3D,IAAMJ,IAAaN,EAAc,GAC3B,EAAE,SAAMW,EAAe;CAE7B,OAAOJ,QACEC,EAAa,yBAAuCF,IAAY,MAAQG,EAAK,KAAI,MAAQG,EAAS,oBAAoBH,GAAMI,CAAC,CAAC,GACpI,CAACA,GAAGP,CAAU,CAAC;AACpB"}
1
+ {"version":3,"file":"index.js","names":["useQueryMemo","QueryClientService","useUsersQuery","container","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY","useUsersMapQuery","usersQuery","useMemo","DataHookUtil","item","useUserOptionsQuery","useTranslation","UserUtil","t"],"sources":["../../../src/dataHooks/useUsersQuery/useUsersQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useTranslation } from 'react-i18next';\nimport { useMemo } from 'react';\nimport type { CommonDbUser } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { UserUtil } from '../../utils/UserUtil';\n\nexport const useUsersQuery = (): UseQueryResult<CommonDbUser[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).usersGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USERS),\n });\n};\n\nexport const useUsersMapQuery = (): UseMap<CommonDbUser> => {\n const usersQuery = useUsersQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbUser>(usersQuery, item => item.id);\n }, [usersQuery]);\n};\n\nexport const useUserOptionsQuery = (): UseOptions<string> => {\n const usersQuery = useUsersQuery();\n const { t } = useTranslation();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbUser>(usersQuery, item => item.id, item => UserUtil.getUserDisplayValue(item, t));\n }, [t, usersQuery]);\n};\n"],"mappings":";;;;;;;;;;AAiBA,IAAaE,UACJF,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBG,EAAU,QAAQC,CAAsB,CAAC,CAAC,YAAY,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CACnF;CAElB,UAAUD,EAAU,QAAQF,CAAkB,CAAC,CAAC,cAAcI,EAAiB,KAAK;AACtF,CAAC,GAGUC,UAA+C;CAC1D,IAAMC,IAAaL,EAAc;CAEjC,OAAOM,QACEC,EAAa,qBAAmCF,IAAY,MAAQG,EAAK,EAAE,GACjF,CAACH,CAAU,CAAC;AACjB,GAEaI,UAAgD;CAC3D,IAAMJ,IAAaL,EAAc,GAC3B,EAAE,SAAMU,EAAe;CAE7B,OAAOJ,QACEC,EAAa,yBAAuCF,IAAY,MAAQG,EAAK,KAAI,MAAQG,EAAS,oBAAoBH,GAAMI,CAAC,CAAC,GACpI,CAACA,GAAGP,CAAU,CAAC;AACpB"}
@@ -2,7 +2,7 @@ import { AuthorizationService as e } from "../../classes/services/AuthorizationS
2
2
  import { container as t } from "tsyringe";
3
3
  import { useMemo as n } from "react";
4
4
  import { jsx as r } from "react/jsx-runtime";
5
- //#region src/hoc/withPermissions/withPermissions.tsx
5
+ // src/hoc/withPermissions/withPermissions.tsx
6
6
  var i = (i, a) => {
7
7
  let o = (o) => {
8
8
  if (!n(() => t.resolve(e), []).doesUserHavePermission(a.requiredPermissions)) {
@@ -16,7 +16,6 @@ var i = (i, a) => {
16
16
  };
17
17
  return o.displayName = `withPermissions(${i.displayName || i.name})`, o;
18
18
  };
19
- //#endregion
20
19
  export { i as withPermissions };
21
20
 
22
21
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
- import { useClientCommonConfigContext as e } from "../../context/ClientCommonConfigContext/index.js";
2
- //#region src/hooks/useConfig/useConfig.ts
3
- var t = () => e().config;
4
- //#endregion
1
+ import { DependencyContainerUtil as e } from "../../utils/DependencyContainerUtil/index.js";
2
+ // src/hooks/useConfig/useConfig.ts
3
+ var t = () => e.resolveConfig();
5
4
  export { t as useConfig };
6
5
 
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useConfig","useClientCommonConfigContext"],"sources":["../../../src/hooks/useConfig/useConfig.ts"],"sourcesContent":["import type { ConfigBase } from '../../models/config.models';\nimport { useClientCommonConfigContext } from '../../context/ClientCommonConfigContext';\n\nexport const useConfig = <TConfig extends ConfigBase = ConfigBase>(): TConfig => {\n return useClientCommonConfigContext<TConfig>().config;\n};\n"],"mappings":";;AAGA,IAAaA,UACJC,EAAsC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","names":["useConfig","DependencyContainerUtil"],"sources":["../../../src/hooks/useConfig/useConfig.ts"],"sourcesContent":["import type { ConfigBase } from '../../models/config.models';\nimport { DependencyContainerUtil } from '../../utils/DependencyContainerUtil';\n\n// eslint-disable-next-line @eslint-react/no-unnecessary-use-prefix\nexport const useConfig = <TConfig extends ConfigBase = ConfigBase>(): TConfig => {\n return DependencyContainerUtil.resolveConfig<TConfig>();\n};\n"],"mappings":";;AAIA,IAAaA,UACJC,EAAwB,cAAuB"}
@@ -1,20 +1,20 @@
1
- import { t as e } from "../../_chunks/QueryClientService.js";
2
- import { t } from "../../_chunks/useMutation.js";
3
- import { NotificationUtil as n } from "../../utils/NotificationUtil/index.js";
1
+ import { NotificationUtil as e } from "../../utils/NotificationUtil/index.js";
2
+ import { t } from "../../_chunks/QueryClientService.js";
3
+ import { t as n } from "../../_chunks/useMutation.js";
4
4
  import { NotificationService as r } from "../../classes/services/NotificationService/index.js";
5
- import { StringUtil as i } from "@gen-epix/ui-core/utils/StringUtil";
6
- import { container as a } from "tsyringe";
5
+ import { container as i } from "tsyringe";
6
+ import { StringUtil as a } from "@gen-epix/ui-core/utils/StringUtil";
7
7
  import { useMemo as o } from "react";
8
8
  import { ObjectUtil as s } from "@gen-epix/ui-core/utils/ObjectUtil";
9
- //#region src/hooks/useCreateMutation/useCreateMutation.ts
9
+ // src/hooks/useCreateMutation/useCreateMutation.ts
10
10
  var c = ({ associationQueryKeys: c, getErrorNotificationMessage: l, getProgressNotificationMessage: u, getSuccessNotificationMessage: d, onError: f, onSuccess: p, queryFn: m, resourceQueryKey: h }) => {
11
- let g = a.resolve(e).queryClient, _ = t({
11
+ let g = i.resolve(t).queryClient, _ = n({
12
12
  mutationFn: async (e) => m(s.deepNullifyEmptyStrings(e)),
13
- onError: async (t, i, o) => {
14
- h && g.setQueryData(h, (e) => Array.isArray(e) ? [...e.filter((e) => e?.id !== o.temporaryId)] : e), await a.resolve(e).invalidateQueryKeys(c), f && await f(t, i, o), a.resolve(r).fulfillNotification(o.notificationKey, n.wrapErrorNotificationMessage(l(i, t), t), "error");
13
+ onError: async (n, a, o) => {
14
+ h && g.setQueryData(h, (e) => Array.isArray(e) ? [...e.filter((e) => e?.id !== o.temporaryId)] : e), await i.resolve(t).invalidateQueryKeys(c), f && await f(n, a, o), i.resolve(r).fulfillNotification(o.notificationKey, e.wrapErrorNotificationMessage(l(a, n), n), "error");
15
15
  },
16
16
  onMutate: async (e) => {
17
- let t = a.resolve(r).showNotification({
17
+ let t = i.resolve(r).showNotification({
18
18
  isLoading: !0,
19
19
  message: u(e),
20
20
  severity: "info"
@@ -23,7 +23,7 @@ var c = ({ associationQueryKeys: c, getErrorNotificationMessage: l, getProgressN
23
23
  await g.cancelQueries({ queryKey: h });
24
24
  let n = g.getQueryData(h);
25
25
  if (Array.isArray(n)) {
26
- let r = i.createUuid();
26
+ let r = a.createUuid();
27
27
  return g.setQueryData(h, (t) => [{
28
28
  ...e,
29
29
  id: r
@@ -36,8 +36,8 @@ var c = ({ associationQueryKeys: c, getErrorNotificationMessage: l, getProgressN
36
36
  }
37
37
  return { notificationKey: t };
38
38
  },
39
- onSuccess: async (t, n, i) => {
40
- h && Array.isArray(i?.previousData) && !Array.isArray(t) && g.setQueryData(h, (e) => [t, ...e.filter((e) => e.id !== i.temporaryId)]), await a.resolve(e).invalidateQueryKeys(c), p && await p(t, n, i), a.resolve(r).fulfillNotification(i.notificationKey, d(t, i), "success");
39
+ onSuccess: async (e, n, a) => {
40
+ h && Array.isArray(a?.previousData) && !Array.isArray(e) && g.setQueryData(h, (t) => [e, ...t.filter((e) => e.id !== a.temporaryId)]), await i.resolve(t).invalidateQueryKeys(c), p && await p(e, n, a), i.resolve(r).fulfillNotification(a.notificationKey, d(e, a), "success");
41
41
  }
42
42
  }), v = o(() => _.mutate, [_.mutate]), y = o(() => _.isPending, [_.isPending]);
43
43
  return o(() => ({
@@ -45,7 +45,6 @@ var c = ({ associationQueryKeys: c, getErrorNotificationMessage: l, getProgressN
45
45
  mutate: v
46
46
  }), [y, v]);
47
47
  };
48
- //#endregion
49
48
  export { c as useCreateMutation };
50
49
 
51
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["QueryClientService","useCreateMutation","queryClient","container","createMutation","useMutation","queryFn","ObjectUtil","item","resourceQueryKey","oldItems","context","associationQueryKeys","onError","error","variables","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","temporaryId","StringUtil","x","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useCreateMutation/useCreateMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\nimport { StringUtil } from '@gen-epix/ui-core/utils/StringUtil';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextCreate<TData> = { notificationKey?: string; previousData?: TData[]; temporaryId?: string };\n\nexport type UseCreateMutationProps<TData extends GenericData | GenericData[], TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TVariables, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextCreate<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly queryFn?: (item: TVariables) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useCreateMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseCreateMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const createMutation = useMutation<TData, Error, TVariables, MutationContextCreate<TData>>({\n mutationFn: async (item) => {\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(item));\n },\n onError: async (error, variables, context) => {\n if (resourceQueryKey) {\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems.filter(item => (item as GenericData)?.id !== context.temporaryId)];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(variables, error), error), 'error');\n },\n onMutate: async (variables) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n if (Array.isArray(previousData)) {\n const temporaryId = StringUtil.createUuid();\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n return [\n {\n ...variables,\n id: temporaryId,\n },\n ...oldItems,\n ] as TData[];\n });\n return { notificationKey, previousData, temporaryId };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n if (resourceQueryKey && Array.isArray(context?.previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return [\n item,\n ...oldItems.filter(x => x.id !== context.temporaryId),\n ];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => createMutation.mutate, [createMutation.mutate]);\n const isMutating = useMemo(() => createMutation.isPending, [createMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;;;AA0BA,IAAaC,KAAoF,EAC/F,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BAC+C;CAC/C,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,IAAiBC,EAAoE;EACzF,YAAY,OAAO,MACVC,EAAQC,EAAW,wBAAwBC,CAAI,CAAC;EAEzD,SAAS,OAAO,GAAO,GAAW,MAAY;GAa5C,AAZIC,KACFP,EAAY,aAAsBO,IAAmB,MAC9C,MAAM,QAAQC,CAAQ,IAGpB,CAAC,GAAGA,EAAS,QAAO,MAASF,GAAsB,OAAOG,EAAQ,WAAW,CAAC,IAF5ED,CAGV,GAEH,MAAMP,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBY,CAAoB,GAChFC,KACF,MAAMA,EAAQC,GAAOC,GAAWJ,CAAO,GAEzCR,EAAU,Q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AY;CAAO,IAAI,CAACC,GAAYF,CAAM,CAAC;AACrE"}
1
+ {"version":3,"file":"index.js","names":["useMutation","useCreateMutation","queryClient","container","QueryClientService","createMutation","queryFn","ObjectUtil","item","resourceQueryKey","oldItems","context","associationQueryKeys","onError","error","variables","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","temporaryId","StringUtil","x","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useCreateMutation/useCreateMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\nimport { StringUtil } from '@gen-epix/ui-core/utils/StringUtil';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextCreate<TData> = { notificationKey?: string; previousData?: TData[]; temporaryId?: string };\n\nexport type UseCreateMutationProps<TData extends GenericData | GenericData[], TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TVariables, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextCreate<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly queryFn?: (item: TVariables) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useCreateMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseCreateMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const createMutation = useMutation<TData, Error, TVariables, MutationContextCreate<TData>>({\n mutationFn: async (item) => {\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(item));\n },\n onError: async (error, variables, context) => {\n if (resourceQueryKey) {\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems.filter(item => (item as GenericData)?.id !== context.temporaryId)];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(variables, error), error), 'error');\n },\n onMutate: async (variables) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n if (Array.isArray(previousData)) {\n const temporaryId = StringUtil.createUuid();\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n return [\n {\n ...variables,\n id: temporaryId,\n },\n ...oldItems,\n ] as TData[];\n });\n return { notificationKey, previousData, temporaryId };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n if (resourceQueryKey && Array.isArray(context?.previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return [\n item,\n ...oldItems.filter(x => x.id !== context.temporaryId),\n ];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => createMutation.mutate, [createMutation.mutate]);\n const isMutating = useMemo(() => createMutation.isPending, [createMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;;;AA0BA,IAAaC,KAAoF,EAC/F,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BAC+C;CAC/C,IAAMC,IAAcC,EAAU,QAAQC,CAAkB,CAAC,CAAC,aAEpDC,IAAiBL,EAAoE;EACzF,YAAY,OAAO,MACVM,EAAQC,EAAW,wBAAwBC,CAAI,CAAC;EAEzD,SAAS,OAAO,GAAO,GAAW,MAAY;GAa5C,AAZIC,KACFP,EAAY,aAAsBO,IAAmB,MAC9C,MAAM,QAAQC,CAAQ,IAGpB,CAAC,GAAGA,EAAS,QAAO,MAASF,GAAsB,OAAOG,EAAQ,WAAW,CAAC,IAF5ED,CAGV,GAEH,MAAMP,EAAU,QAAQC,CAAkB,CAAC,CAAC,oBAAoBQ,CAAoB,GAChFC,KACF,MAAMA,EAAQC,GAAOC,GAAWJ,CAAO,GAEzCR,EAAU,QAAQa,CAAmB,CAAC,CAAC,oBAAoBL,EAAQ,iBAAiBM,EAAiB,6BAA6BC,EAA4BH,GAAWD,CAAK,GAAGA,CAAK,GAAG,OAAO;EAClM;EACA,UAAU,OAAO,MAAc;GAC7B,IAAMK,IAAkBhB,EAAU,QAAQa,CAAmB,CAAC,CAAC,iBAAiB;IAC9E,WAAW;IACX,SAASI,EAA+BL,CAAS;IACjD,UAAU;GACZ,CAAC;GACD,IAAIN,GAAkB;IACpB,MAAMP,EAAY,cAAc,EAAE,UAAUO,EAAiB,CAAC;IAC9D,IAAMY,IAAenB,EAAY,aAAsBO,CAAgB;IACvE,IAAI,MAAM,QAAQY,CAAY,GAAG;KAC/B,IAAMC,IAAcC,EAAW,WAAW;KAU1C,OATArB,EAAY,aAAsBO,IAAmB,MAC5C,CACL;MACE,GAAGM;MACH,IAAIO;KACN,GACA,GAAGZ,CACL,CACD,GACM;MAAE;MAAiB;MAAc;KAAY;IACtD;GACF;GACA,OAAO,EAAE,mBAAgB;EAC3B;EACA,WAAW,OAAO,GAAM,GAAW,MAAY;GAa7C,AAZID,KAAoB,MAAM,QAAQE,GAAS,YAAY,KAAK,CAAC,MAAM,QAAQH,CAAI,KACjFN,EAAY,aAA4BO,IAAmB,MAClD,CACLD,GACA,GAAGE,EAAS,QAAO,MAAKc,EAAE,OAAOb,EAAQ,WAAW,CACtD,CACD,GAEH,MAAMR,EAAU,QAAQC,CAAkB,CAAC,CAAC,oBAAoBQ,CAAoB,GAChFa,KACF,MAAMA,EAAUjB,GAAMO,GAAWJ,CAAO,GAE1CR,EAAU,QAAQa,CAAmB,CAAC,CAAC,oBAAoBL,EAAQ,iBAAiBe,EAA8BlB,GAAMG,CAAO,GAAG,SAAS;EAC7I;CACF,CAAC,GAGKgB,IAASC,QAAcvB,EAAe,QAAQ,CAACA,EAAe,MAAM,CAAC,GACrEwB,IAAaD,QAAcvB,EAAe,WAAW,CAACA,EAAe,SAAS,CAAC;CACrF,OAAOuB,SAAe;EAAE;EAAY;CAAO,IAAI,CAACC,GAAYF,CAAM,CAAC;AACrE"}
@@ -1,15 +1,20 @@
1
- import { t as e } from "../../_chunks/QueryClientService.js";
2
- import { t } from "../../_chunks/useMutation.js";
3
- import { NotificationUtil as n } from "../../utils/NotificationUtil/index.js";
1
+ import { NotificationUtil as e } from "../../utils/NotificationUtil/index.js";
2
+ import { t } from "../../_chunks/QueryClientService.js";
3
+ import { t as n } from "../../_chunks/useMutation.js";
4
4
  import { NotificationService as r } from "../../classes/services/NotificationService/index.js";
5
5
  import { container as i } from "tsyringe";
6
6
  import { useMemo as a } from "react";
7
- //#region src/hooks/useDeleteMutation/useDeleteMutation.ts
7
+ // src/hooks/useDeleteMutation/useDeleteMutation.ts
8
8
  var o = ({ associationQueryKeys: o, getErrorNotificationMessage: s, getProgressNotificationMessage: c, getSuccessNotificationMessage: l, onError: u, onSuccess: d, queryFn: f, resourceQueryKey: p }) => {
9
- let m = i.resolve(e).queryClient, h = t({
10
- mutationFn: async (e) => f(e),
11
- onError: async (t, a, c) => {
12
- p && m.setQueryData(p, (e) => Array.isArray(e) ? [...e, a] : e), o && await i.resolve(e).invalidateQueryKeys(o), u && await u(t, a, c), i.resolve(r).fulfillNotification(c.notificationKey, n.wrapErrorNotificationMessage(s(a, t), t), "error");
9
+ let m = i.resolve(t).queryClient, h = n({
10
+ mutationFn: async (e) => {
11
+ if (!f) throw Error("Delete mutation queryFn is required");
12
+ return f(e);
13
+ },
14
+ onError: async (n, a, c) => {
15
+ p && Array.isArray(c.previousData) && m.setQueryData(p, c.previousData), o && await i.resolve(t).invalidateQueryKeys(o), u && await u(n, a, c);
16
+ let l = s?.(a, n) ?? String(n);
17
+ i.resolve(r).fulfillNotification(c.notificationKey, e.wrapErrorNotificationMessage(l, n), "error");
13
18
  },
14
19
  onMutate: async (e) => {
15
20
  let t = i.resolve(r).showNotification({
@@ -27,8 +32,10 @@ var o = ({ associationQueryKeys: o, getErrorNotificationMessage: s, getProgressN
27
32
  }
28
33
  return { notificationKey: t };
29
34
  },
30
- onSuccess: async (t, n, a) => {
31
- o && await i.resolve(e).invalidateQueryKeys(o), d && await d(n, a), i.resolve(r).fulfillNotification(a.notificationKey, l(n, a), "success");
35
+ onSuccess: async (e, n, a) => {
36
+ o && await i.resolve(t).invalidateQueryKeys(o), d && await d(n, a);
37
+ let s = l?.(n, a) ?? "Deleted successfully";
38
+ i.resolve(r).fulfillNotification(a.notificationKey, s, "success");
32
39
  }
33
40
  }), g = a(() => h.mutate, [h.mutate]), _ = a(() => h.isPending, [h.isPending]);
34
41
  return a(() => ({
@@ -36,7 +43,6 @@ var o = ({ associationQueryKeys: o, getErrorNotificationMessage: s, getProgressN
36
43
  mutate: g
37
44
  }), [_, g]);
38
45
  };
39
- //#endregion
40
46
  export { o as useDeleteMutation };
41
47
 
42
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["QueryClientService","useDeleteMutation","queryClient","container","deleteMutation","useMutation","queryFn","item","resourceQueryKey","oldItems","associationQueryKeys","onError","error","context","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","i","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useDeleteMutation/useDeleteMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextDelete<TData> = { notificationKey?: string; previousData?: TData[] };\n\nexport type UseDeleteMutationProps<TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage?: (data: TData, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TData) => ReactElement | string;\n readonly getSuccessNotificationMessage?: (data: TData, context: MutationContextDelete<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly queryFn?: (data: TData) => Promise<unknown>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useDeleteMutation = <TData extends GenericData | GenericData[]>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseDeleteMutationProps<TData>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const deleteMutation = useMutation<unknown, Error, TData, MutationContextDelete<TData>>({\n mutationFn: async (item) => {\n return queryFn(item);\n },\n onError: async (error, item, context) => {\n if (resourceQueryKey) {\n queryClient.setQueryData(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems, item];\n });\n }\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onError) {\n await onError(error, item, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(item, error), error), 'error');\n },\n onMutate: async (item) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(item),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n\n if (Array.isArray(previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return oldItems.filter(i => i.id !== item.id);\n });\n return { notificationKey, previousData };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (_data, item, context) => {\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onSuccess) {\n await onSuccess(item, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => deleteMutation.mutate, [deleteMutation.mutate]);\n const isMutating = useMemo(() => deleteMutation.isPending, [deleteMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;AAwBA,IAAaC,KAAgE,EAC3E,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BACmC;CACnC,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,IAAiBC,EAAiE;EACtF,YAAY,OAAO,MACVC,EAAQC,CAAI;EAErB,SAAS,OAAO,GAAO,GAAM,MAA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,SAAS,CAAC;CACrF,OAAOoB,SAAe;EAAE;EAAY;CAAO,IAAI,CAACC,GAAYF,CAAM,CAAC;AACrE"}
1
+ {"version":3,"file":"index.js","names":["useMutation","useDeleteMutation","queryClient","container","QueryClientService","deleteMutation","queryFn","item","resourceQueryKey","context","associationQueryKeys","onError","error","errorMessage","getErrorNotificationMessage","NotificationService","NotificationUtil","notificationKey","getProgressNotificationMessage","previousData","oldItems","i","onSuccess","successMessage","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useDeleteMutation/useDeleteMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextDelete<TData> = { notificationKey?: string; previousData?: TData[] };\n\nexport type UseDeleteMutationProps<TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage?: (data: TData, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TData) => ReactElement | string;\n readonly getSuccessNotificationMessage?: (data: TData, context: MutationContextDelete<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly queryFn?: (data: TData) => Promise<unknown>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useDeleteMutation = <TData extends GenericData | GenericData[]>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseDeleteMutationProps<TData>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const deleteMutation = useMutation<unknown, Error, TData, MutationContextDelete<TData>>({\n mutationFn: async (item) => {\n if (!queryFn) {\n throw new Error('Delete mutation queryFn is required');\n }\n return queryFn(item);\n },\n onError: async (error, item, context) => {\n if (resourceQueryKey && Array.isArray(context.previousData)) {\n queryClient.setQueryData<TData[]>(resourceQueryKey, context.previousData);\n }\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onError) {\n await onError(error, item, context);\n }\n const errorMessage = getErrorNotificationMessage?.(item, error) ?? String(error);\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(errorMessage, error), 'error');\n },\n onMutate: async (item) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(item),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n\n if (Array.isArray(previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return oldItems.filter(i => i.id !== item.id);\n });\n return { notificationKey, previousData };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (_data, item, context) => {\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onSuccess) {\n await onSuccess(item, context);\n }\n const successMessage = getSuccessNotificationMessage?.(item, context) ?? 'Deleted successfully';\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, successMessage, 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => deleteMutation.mutate, [deleteMutation.mutate]);\n const isMutating = useMemo(() => deleteMutation.isPending, [deleteMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;AAwBA,IAAaC,KAAgE,EAC3E,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BACmC;CACnC,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B,IAAMc,IAAiBC,IAAgCjB,GAAME,CAAO,KAAK;GACzE,EAAU,QAAQM,CAAmB,CAAC,CAAC,oBAAoBN,EAAQ,iBAAiBc,GAAgB,SAAS;EAC/G;CACF,CAAC,GAGKE,IAASC,QAAcrB,EAAe,QAAQ,CAACA,EAAe,MAAM,CAAC,GACrEsB,IAAaD,QAAcrB,EAAe,WAAW,CAACA,EAAe,SAAS,CAAC;CACrF,OAAOqB,SAAe;EAAE;EAAY;CAAO,IAAI,CAACC,GAAYF,CAAM,CAAC;AACrE"}
@@ -1,58 +1,72 @@
1
- import { t as e } from "../../_chunks/QueryClientService.js";
2
- import { t } from "../../_chunks/useMutation.js";
3
- import { NotificationUtil as n } from "../../utils/NotificationUtil/index.js";
1
+ import { NotificationUtil as e } from "../../utils/NotificationUtil/index.js";
2
+ import { t } from "../../_chunks/QueryClientService.js";
3
+ import { t as n } from "../../_chunks/useMutation.js";
4
4
  import { NotificationService as r } from "../../classes/services/NotificationService/index.js";
5
5
  import { container as i } from "tsyringe";
6
6
  import { useCallback as a, useMemo as o, useRef as s } from "react";
7
7
  import { ObjectUtil as c } from "@gen-epix/ui-core/utils/ObjectUtil";
8
- //#region src/hooks/useEditMutation/useEditMutation.ts
9
- var l = ({ associationQueryKeys: l, getErrorNotificationMessage: u, getIntermediateItem: d, getProgressNotificationMessage: f, getSuccessNotificationMessage: p, onError: m, onSuccess: h, queryFn: g, resourceQueryKey: _ }) => {
10
- let v = i.resolve(e).queryClient, y = s(void 0), b = a((e) => {
11
- y.current = e;
12
- }, []), x = a(async (e) => g(c.deepNullifyEmptyStrings(e), y.current), [y, g]), S = t({
13
- mutationFn: x,
14
- onError: async (t, a, o) => {
15
- y.current = void 0, _ && Array.isArray(o.previousData) && v.setQueryData(_, (e) => Array.isArray(e) ? [...e.filter((e) => e.id !== o.item.id), o.item] : e), await i.resolve(e).invalidateQueryKeys(l), m && await m(t, a, o), i.resolve(r).fulfillNotification(o.notificationKey, n.wrapErrorNotificationMessage(u(o.item, a, t), t), "error");
8
+ // src/hooks/useEditMutation/useEditMutation.ts
9
+ var l = (e) => !Array.isArray(e), u = ({ associationQueryKeys: u, getErrorNotificationMessage: d, getIntermediateItem: f, getProgressNotificationMessage: p, getSuccessNotificationMessage: m, onError: h, onSuccess: g, queryFn: _, resourceQueryKey: v }) => {
10
+ let y = i.resolve(t).queryClient, b = s(void 0), x = a((e) => {
11
+ b.current = e;
12
+ }, []), S = a(async (e) => {
13
+ if (!_) throw Error("Edit mutation queryFn is required");
14
+ return _(c.deepNullifyEmptyStrings(e), b.current);
15
+ }, [b, _]), C = n({
16
+ mutationFn: S,
17
+ onError: async (n, a, o) => {
18
+ b.current = void 0;
19
+ let s = o ?? {};
20
+ v && Array.isArray(s.previousData) && y.setQueryData(v, s.previousData), await i.resolve(t).invalidateQueryKeys(u), h && await h(n, a, s);
21
+ let c = s.item ? d(s.item, a, n) : String(n);
22
+ s.notificationKey && i.resolve(r).fulfillNotification(s.notificationKey, e.wrapErrorNotificationMessage(c, n), "error");
16
23
  },
17
24
  onMutate: async (e) => {
18
- let t = i.resolve(r).showNotification({
25
+ let t = b.current;
26
+ if (!t) throw Error("previousItem is not set");
27
+ let n = i.resolve(r).showNotification({
19
28
  isLoading: !0,
20
- message: f(y.current, e),
29
+ message: p(t, e),
21
30
  severity: "info"
22
31
  });
23
- if (_) {
24
- if (!y.current) throw Error("previousItem is not set");
25
- await v.cancelQueries({ queryKey: _ });
26
- let n = v.getQueryData(_);
27
- if (Array.isArray(n) && !Array.isArray(e)) {
28
- let r = d ? d(e, y.current) : {
32
+ if (v) {
33
+ await y.cancelQueries({ queryKey: v });
34
+ let r = y.getQueryData(v);
35
+ if (Array.isArray(r) && !Array.isArray(e)) {
36
+ let i = f ? f(e, t) : {
29
37
  ...e,
30
- id: y.current.id
38
+ id: t.id
31
39
  };
32
- return v.setQueryData(_, (e) => [...e.filter((e) => e.id !== y.current.id), r]), {
33
- item: y.current,
34
- notificationKey: t,
35
- previousData: n
40
+ return y.setQueryData(v, (e) => e.map((e) => e.id === t.id ? i : e)), {
41
+ item: t,
42
+ notificationKey: n,
43
+ previousData: r
36
44
  };
37
45
  }
38
46
  }
39
- return { notificationKey: t };
47
+ return {
48
+ item: t,
49
+ notificationKey: n
50
+ };
40
51
  },
41
- onSuccess: async (t, n, a) => {
42
- y.current = void 0, await i.resolve(e).invalidateQueryKeys(l), h && await h(t, n, a), i.resolve(r).fulfillNotification(a.notificationKey, p(t, a), "success");
52
+ onSuccess: async (e, n, a) => {
53
+ if (b.current = void 0, v && Array.isArray(a?.previousData) && l(e)) {
54
+ let t = a.item?.id;
55
+ y.setQueryData(v, (n) => Array.isArray(n) ? n.map((n) => n.id === t ? e : n) : n);
56
+ }
57
+ await i.resolve(t).invalidateQueryKeys(u), g && await g(e, n, a), i.resolve(r).fulfillNotification(a.notificationKey, m(e, a), "success");
43
58
  }
44
- }), C = o(() => S.mutate, [S.mutate]), w = o(() => S.isPending, [S.isPending]);
59
+ }), w = o(() => C.mutate, [C.mutate]), T = o(() => C.isPending, [C.isPending]);
45
60
  return o(() => ({
46
- isMutating: w,
47
- mutate: C,
48
- setPreviousItem: b
61
+ isMutating: T,
62
+ mutate: w,
63
+ setPreviousItem: x
49
64
  }), [
65
+ T,
50
66
  w,
51
- C,
52
- b
67
+ x
53
68
  ]);
54
69
  };
55
- //#endregion
56
- export { l as useEditMutation };
70
+ export { u as useEditMutation };
57
71
 
58
72
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["QueryClientService","useEditMutation","queryClient","container","previousItemRef","useRef","setPreviousItem","useCallback","item","mutationFn","queryFn","ObjectUtil","variables","editMutation","useMutation","resourceQueryKey","context","oldItems","x","associationQueryKeys","onError","error","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","intermediateItem","getIntermediateItem","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useEditMutation/useEditMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\n\nexport type MutationContextEdit<TData> = { item?: TData; notificationKey?: string; previousData?: TData[] };\n\nexport type UseEditMutationProps<TData, TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TData, variables: TVariables, error: unknown) => ReactElement | string;\n // Optional function to get an intermediate item to be set in the query cache before the mutation is completed.\n // This is useful for optimistic updates where you want to show a temporary state before the mutation is confirmed.\n // The function receives the variables and the previous item, and should return the intermediate item.\n // Only needed if the variables are different from the previous item.\n readonly getIntermediateItem?: (variables: TVariables, previousItem: TData) => TData;\n readonly getProgressNotificationMessage: (data: TData, variables: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextEdit<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly queryFn?: (variables: TVariables, previousData: TData) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useEditMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getIntermediateItem,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseEditMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n const previousItemRef = useRef<TData>(undefined);\n\n const setPreviousItem = useCallback((item: TData) => {\n previousItemRef.current = item;\n }, []);\n\n const mutationFn = useCallback(async (variables: TVariables) => {\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(variables), previousItemRef.current);\n }, [previousItemRef, queryFn]);\n\n const editMutation = useMutation<TData, Error, TVariables, MutationContextEdit<TData>>({\n mutationFn,\n onError: async (error, variables, context) => {\n previousItemRef.current = undefined;\n if (resourceQueryKey && Array.isArray(context.previousData)) {\n queryClient.setQueryData(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems.filter(x => (x as GenericData).id !== (context.item as GenericData).id), context.item];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(context.item, variables, error), error), 'error');\n },\n onMutate: async (variables) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(previousItemRef.current, variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n if (!previousItemRef.current) {\n throw new Error('previousItem is not set');\n }\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n if (Array.isArray(previousData) && !Array.isArray(variables)) {\n const intermediateItem = getIntermediateItem ? getIntermediateItem(variables, previousItemRef.current) : {\n ...variables,\n id: (previousItemRef.current as GenericData).id,\n } as GenericData;\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return [...oldItems.filter(x => x.id !== (previousItemRef.current as GenericData).id), intermediateItem] as GenericData[];\n });\n return { item: previousItemRef.current, notificationKey, previousData };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n previousItemRef.current = undefined;\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => editMutation.mutate, [editMutation.mutate]);\n const isMutating = useMemo(() => editMutation.isPending, [editMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate, setPreviousItem }), [isMutating, mutate, setPreviousItem]);\n};\n"],"mappings":";;;;;;;;AAiCA,IAAaC,KAAkF,EAC7F,yBACA,gCACA,wBACA,mCACA,kCACA,YACA,cACA,YACA,0BAC6C;CAC7C,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aACpDI,IAAkBC,EAAc,KAAA,CAAS,GAEzCC,IAAkBC,GAAa,MAAgB;EACnD,EAAgB,UAAUC;CAC5B,GAAG,CAAC,CAAC,GAECC,IAAaF,EAAY,OAAO,MAC7BG,EAAQC,EAAW,wBAAwBC,CAAS,GAAGR,EAAgB,OAAO,GACpF,CAACA,GAAiBM,CAAO,CAAC,GAEvBG,IAAeC,EAAkE;EACrF;EACA,SAAS,OAAO,GAAO,GAAW,MAAY;GAc5C,AAbA,EAAgB,UAAU,KAAA,GACtBC,KAAoB,MAAM,QAAQC,EAAQ,YAAY,KACxDd,EAAY,aAAaa,IAAmB,MACrC,MAAM,QAAQE,CAAQ,IAGpB,CAAC,GAAGA,EAAS,QAAO,MAAMC,EAAkB,OAAQF,EAAQ,KAAqB,EAAE,GAAGA,EAAQ,IAAI,IAFhGC,CAGV,GAEH,MAAMd,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBmB,CAAoB,GAChFC,KACF,MAAMA,EAAQC,GAAOT,GAAWI,CAAO,GAEzCb,EAAU,QAAQmB,CAAmB,CAAC,CAAC,oBAAoBN,EAAQ,iBAAiBO,EAAiB,6BAA6BC,EAA4BR,EAAQ,MAAMJ,GAAWS,CAAK,GAAGA,CAAK,GAAG,OAAO;EAChN;EACA,UAAU,OAAO,MAAc;GAC7B,IAAMI,IAAkBtB,EAAU,QAA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ation","isSingleGenericData","item","useEditMutation","queryClient","container","QueryClientService","previousItemRef","useRef","setPreviousItem","useCallback","mutationFn","queryFn","ObjectUtil","variables","editMutation","safeContext","context","resourceQueryKey","associationQueryKeys","onError","error","errorMessage","getErrorNotificationMessage","NotificationService","NotificationUtil","previousItem","notificationKey","getProgressNotificationMessage","previousData","intermediateItem","getIntermediateItem","oldItems","x","previousItemId","oldItem","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useEditMutation/useEditMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\n\nexport type MutationContextEdit<TData> = { item?: TData; notificationKey?: string; previousData?: TData[] };\n\nexport type UseEditMutationProps<TData, TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TData, variables: TVariables, error: unknown) => ReactElement | string;\n // Optional function to get an intermediate item to be set in the query cache before the mutation is completed.\n // This is useful for optimistic updates where you want to show a temporary state before the mutation is confirmed.\n // The function receives the variables and the previous item, and should return the intermediate item.\n // Only needed if the variables are different from the previous item.\n readonly getIntermediateItem?: (variables: TVariables, previousItem: TData) => TData;\n readonly getProgressNotificationMessage: (data: TData, variables: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextEdit<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly queryFn?: (variables: TVariables, previousData: TData) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nconst isSingleGenericData = (item: GenericData | GenericData[]): item is GenericData => !Array.isArray(item);\n\nexport const useEditMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getIntermediateItem,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseEditMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n const previousItemRef = useRef<TData>(undefined);\n\n const setPreviousItem = useCallback((item: TData) => {\n previousItemRef.current = item;\n }, []);\n\n const mutationFn = useCallback(async (variables: TVariables) => {\n if (!queryFn) {\n throw new Error('Edit mutation queryFn is required');\n }\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(variables), previousItemRef.current);\n }, [previousItemRef, queryFn]);\n\n const editMutation = useMutation<TData, Error, TVariables, MutationContextEdit<TData>>({\n mutationFn,\n onError: async (error, variables, context) => {\n previousItemRef.current = undefined;\n const safeContext: MutationContextEdit<TData> = context ?? {};\n if (resourceQueryKey && Array.isArray(safeContext.previousData)) {\n queryClient.setQueryData<TData[]>(resourceQueryKey, safeContext.previousData);\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, safeContext);\n }\n const errorMessage = safeContext.item\n ? getErrorNotificationMessage(safeContext.item, variables, error)\n : String(error);\n if (safeContext.notificationKey) {\n container.resolve(NotificationService).fulfillNotification(safeContext.notificationKey, NotificationUtil.wrapErrorNotificationMessage(errorMessage, error), 'error');\n }\n },\n onMutate: async (variables) => {\n const previousItem = previousItemRef.current;\n if (!previousItem) {\n throw new Error('previousItem is not set');\n }\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(previousItem, variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n\n if (Array.isArray(previousData) && !Array.isArray(variables)) {\n const intermediateItem = getIntermediateItem ? getIntermediateItem(variables, previousItem) : {\n ...variables,\n id: (previousItem as GenericData).id,\n } as GenericData;\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return oldItems.map(x => x.id === (previousItem as GenericData).id ? intermediateItem : x) as GenericData[];\n });\n return { item: previousItem, notificationKey, previousData };\n }\n }\n return { item: previousItem, notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n previousItemRef.current = undefined;\n if (resourceQueryKey && Array.isArray(context?.previousData) && isSingleGenericData(item)) {\n const previousItemId = (context.item as GenericData)?.id;\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return oldItems.map(oldItem => oldItem.id === previousItemId ? item : oldItem);\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => editMutation.mutate, [editMutation.mutate]);\n const isMutating = useMemo(() => editMutation.isPending, [editMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate, setPreviousItem }), [isMutating, mutate, setPreviousItem]);\n};\n"],"mappings":";;;;;;;;AAiCA,IAAMC,KAAuB,MAA2D,CAAC,MAAM,QAAQC,CAAI,GAE9FC,KAAkF,EAC7F,yBACA,gCACA,wBACA,mCACA,kCACA,YACA,cACA,YACA,0BAC6C;CAC7C,IAAMC,IAAcC,EAAU,QAAQC,CAAkB,CAAC,CAAC,aACpDC,IAAkBC,EAAc,KAAA,CAAS,GAEzCC,IAAkBC,GAAa,MAAgB;EACnD,EAAgB,UAAUR;CAC5B,GAAG,CAAC,CAAC,GAECS,IAAaD,EAAY,OAAO,MAA0B;EAC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AY,aAA4Bc,IAAmB,MAClDc,EAAS,KAAI,MAAKC,EAAE,OAAQP,EAA6B,KAAKI,IAAmBG,CAAC,CAC1F,GACM;MAAE,MAAMP;MAAc;MAAiB;KAAa;IAC7D;GACF;GACA,OAAO;IAAE,MAAMA;IAAc;GAAgB;EAC/C;EACA,WAAW,OAAO,GAAM,GAAW,MAAY;GAE7C,IADA,EAAgB,UAAU,KAAA,GACtBR,KAAoB,MAAM,QAAQD,GAAS,YAAY,KAAKhB,EAAoBC,CAAI,GAAG;IACzF,IAAMgC,IAAkBjB,EAAQ,MAAsB;IACtD,EAAY,aAA4BC,IAAmB,MACpD,MAAM,QAAQc,CAAQ,IAGpBA,EAAS,KAAI,MAAWG,EAAQ,OAAOD,IAAiBhC,IAAOiC,CAAO,IAFpEH,CAGV;GACH;GAKA,AAJA,MAAM3B,EAAU,QAAQC,CAAkB,CAAC,CAAC,oBAAoBa,CAAoB,GAChFiB,KACF,MAAMA,EAAUlC,GAAMY,GAAWG,CAAO,GAE1CZ,EAAU,QAAQmB,CAAmB,CAAC,CAAC,oBAAoBP,EAAQ,iBAAiBoB,EAA8BnC,GAAMe,CAAO,GAAG,SAAS;EAC7I;CACF,CAAC,GAGKqB,IAASC,QAAcxB,EAAa,QAAQ,CAACA,EAAa,MAAM,CAAC,GACjEyB,IAAaD,QAAcxB,EAAa,WAAW,CAACA,EAAa,SAAS,CAAC;CACjF,OAAOwB,SAAe;EAAE;EAAY;EAAQ;CAAgB,IAAI;EAACC;EAAYF;EAAQ7B;CAAe,CAAC;AACvG"}
@@ -2,7 +2,7 @@ import { t as e } from "../../_chunks/TableUtil.js";
2
2
  import { DEFAULT_FILTER_GROUP as t } from "../../classes/abstracts/FilterAbstract/index.js";
3
3
  import { t as n } from "../../_chunks/react.js";
4
4
  import { useEffect as r } from "react";
5
- //#region src/hooks/useInitializeTableStore/useInitializeTableStore.ts
5
+ // src/hooks/useInitializeTableStore/useInitializeTableStore.ts
6
6
  var i = ({ columns: i, context: a, createFiltersFromColumns: o, rows: s, store: c }) => {
7
7
  let l = n(c, (e) => e.setColumns), u = n(c, (e) => e.setBaseData), d = n(c, (e) => e.setFilters), f = n(c, (e) => e.initialize);
8
8
  r(() => {
@@ -22,7 +22,6 @@ var i = ({ columns: i, context: a, createFiltersFromColumns: o, rows: s, store:
22
22
  a
23
23
  ]);
24
24
  };
25
- //#endregion
26
25
  export { i as useInitializeTableStore };
27
26
 
28
27
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,17 @@
1
- import { t as e } from "../../_chunks/QueryClientService.js";
2
- import { t } from "../../_chunks/useQueryMemo.js";
1
+ import { t as e } from "../../_chunks/useQueryMemo.js";
2
+ import { t } from "../../_chunks/QueryClientService.js";
3
3
  import { container as n } from "tsyringe";
4
4
  import { useEffect as r, useMemo as i, useState as a } from "react";
5
- //#region src/hooks/useItemQuery/useItemQuery.ts
5
+ // src/hooks/useItemQuery/useItemQuery.ts
6
6
  var o = [
7
7
  "added",
8
8
  "removed",
9
9
  "updated"
10
10
  ], s = ({ baseQueryKey: s, itemId: c, useQueryOptions: l }) => {
11
- let { queryCache: u } = n.resolve(e), [d, f] = a(n.resolve(e).getItemFromCache(s, c)), p = t({
11
+ let { queryCache: u } = n.resolve(t), [d, f] = a(n.resolve(t).getItemFromCache(s, c)), p = e({
12
12
  ...l,
13
13
  enabled: !d && l.enabled,
14
- queryKey: n.resolve(e).getGenericKey(s, c)
14
+ queryKey: n.resolve(t).getGenericKey(s, c)
15
15
  });
16
16
  return r(() => {
17
17
  let e = u.subscribe((e) => {
@@ -56,7 +56,6 @@ var o = [
56
56
  p.error
57
57
  ]);
58
58
  };
59
- //#endregion
60
59
  export { s as useItemQuery };
61
60
 
62
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["QueryClientService","eventTypes","useItemQuery","container","itemFromCache","setItemFromCache","useState","baseQueryKey","itemId","useQueryResult","useQueryMemo","useQueryOptions","useEffect","removeListener","queryCache","event","list","newValue","item","useMemo"],"sources":["../../../src/hooks/useItemQuery/useItemQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport type {\n QueryCacheNotifyEvent,\n UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport type { GenericData } from '../../models/data.models';\nimport { useQueryMemo } from '../useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\nexport type UseItemQueryProps<T extends GenericData, TQueryKey extends string = string> = {\n readonly baseQueryKey: TQueryKey;\n readonly itemId: string;\n readonly useQueryOptions: Omit<UseQueryOptions<T>, 'queryKey'>;\n};\n\nconst eventTypes: QueryCacheNotifyEvent['type'][] = ['added', 'removed', 'updated'];\n\nexport const useItemQuery = <T extends GenericData>({\n baseQueryKey,\n itemId,\n useQueryOptions,\n}: UseItemQueryProps<T>) => {\n const { queryCache } = container.resolve(QueryClientService);\n const [itemFromCache, setItemFromCache] = useState<T>(container.resolve(QueryClientService).getItemFromCache<T>(baseQueryKey, itemId));\n\n const useQueryResult = useQueryMemo({\n ...useQueryOptions,\n enabled: !itemFromCache && useQueryOptions.enabled,\n queryKey: container.resolve(QueryClientService).getGenericKey(baseQueryKey, itemId),\n });\n\n useEffect(() => {\n const handleQueryCacheEvent = (event: QueryCacheNotifyEvent) => {\n if (Array.isArray(event.query.queryKey) && event.query.queryKey[0] === baseQueryKey && eventTypes.includes(event.type)) {\n if (event.query.queryKey.length === 1) {\n const list = (event.query.state.data as T[]);\n if (event.type === 'removed') {\n setItemFromCache(undefined);\n return;\n }\n if (!list) {\n return;\n }\n const newValue = list?.find(item => item.id === itemId);\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n } else if (event.query.queryKey.length === 2 && (event.query.state.data as T)?.id === itemId) {\n const newValue = event.query.state.data as T;\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n }\n }\n };\n\n const removeListener = queryCache.subscribe(handleQueryCacheEvent);\n return () => {\n removeListener();\n };\n }, [baseQueryKey, itemId, queryCache, itemFromCache]);\n\n\n const result = useMemo(() => {\n return {\n data: itemFromCache || useQueryResult.data,\n error: itemFromCache ? false : useQueryResult.error,\n isEnabled: itemFromCache ? true : useQueryResult.isEnabled,\n isFetching: itemFromCache ? false : useQueryResult.isFetching,\n isLoading: itemFromCache ? false : useQueryResult.isLoading,\n isPending: itemFromCache ? false : useQueryResult.isPending,\n };\n }, [itemFromCache, useQueryResult.data, useQueryResult.isLoading, useQueryResult.isPending, useQueryResult.isFetching, useQueryResult.isEnabled, useQueryResult.error]);\n\n return result;\n};\n"],"mappings":";;;;;AAqBA,IAAMC,IAA8C;CAAC;CAAS;CAAW;AAAS,GAErEC,KAAuC,EAClD,iBACA,WACA,yBAC0B;CAC1B,IAAM,EAAE,kBAAeC,EAAU,QAAQH,CAAkB,GACrD,CAACI,GAAeC,KAAoBC,EAAYH,EAAU,QAAQH,CAAkB,CAAC,CAAC,iBAAoBO,GAAcC,CAAM,CAAC,GAE/HC,IAAiBC,EAAa;EAClC,GAAGC;EACH,SAAS,CAACP,KAAiBO,EAAgB;EAC3C,UAAUR,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcO,GAAcC,CAAM;CACpF,CAAC;CA6CD,OA3CAI,QAAgB;EAyBd,IAAMC,IAAiBC,EAAW,WAxBH,MAAiC;GAC9D,IAAI,MAAM,QAAQC,EAAM,MAAM,QAAQ,KAAKA,EAAM,MAAM,SAAS,OAAOR,KAAgBN,EAAW,SAASc,EAAM,IAAI,GAAG;IACtH,IAAIA,EAAM,MAAM,SAAS,WAAW,GAAG;KACrC,IAAMC,IAAQD,EAAM,MAAM,MAAM;KAChC,IAAIA,EAAM,SAAS,WAAW;MAC5B,EAAiB,KAAA,CAAS;MAC1B;KACF;KACA,IAAI,CAACC,GACH;KAEF,IAAMC,IAAWD,GAAM,MAAK,MAAQE,EAAK,OAAOV,CAAM;KACtD,AAAI,KAAK,UAAUJ,CAAa,MAAM,KAAK,UAAUa,CAAQ,KAC3DZ,EAAiBY,CAAQ;IAE7B,OAAO,IAAIF,EAAM,MAAM,SAAS,WAAW,KAAMA,EAAM,MAAM,MAAM,MAAY,OAAOP,GAAQ;KAC5F,IAAMS,IAAWF,EAAM,MAAM,MAAM;KACnC,AAAI,KAAK,UAAUX,CAAa,MAAM,KAAK,UAAUa,CAAQ,KAC3DZ,EAAiBY,CAAQ;IAE7B;GACF;EACF,CAEiE;EACjE,aAAa;GACX,EAAe;EACjB;CACF,GAAG;EAACV;EAAcC;EAAQM;EAAYV;CAAa,CAAC,GAGrCe,SACN;EACL,MAAMf,KAAiBK,EAAe;EACtC,OAAO,MAAwBA,EAAe;EAC9C,WAAWL,IAAgB,KAAOK,EAAe;EACjD,YAAY,MAAwBA,EAAe;EACnD,WAAW,MAAwBA,EAAe;EAClD,WAAW,MAAwBA,EAAe;CACpD,IACC;EAACL;EAAeK,EAAe;EAAMA,EAAe;EAAWA,EAAe;EAAWA,EAAe;EAAYA,EAAe;EAAWA,EAAe;CAAK,CAE9J;AACT"}
1
+ {"version":3,"file":"index.js","names":["useQueryMemo","eventTypes","useItemQuery","container","QueryClientService","itemFromCache","setItemFromCache","useState","baseQueryKey","itemId","useQueryResult","useQueryOptions","useEffect","removeListener","queryCache","event","list","newValue","item","useMemo"],"sources":["../../../src/hooks/useItemQuery/useItemQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport type {\n QueryCacheNotifyEvent,\n UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport type { GenericData } from '../../models/data.models';\nimport { useQueryMemo } from '../useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\nexport type UseItemQueryProps<T extends GenericData, TQueryKey extends string = string> = {\n readonly baseQueryKey: TQueryKey;\n readonly itemId: string;\n readonly useQueryOptions: Omit<UseQueryOptions<T>, 'queryKey'>;\n};\n\nconst eventTypes: QueryCacheNotifyEvent['type'][] = ['added', 'removed', 'updated'];\n\nexport const useItemQuery = <T extends GenericData>({\n baseQueryKey,\n itemId,\n useQueryOptions,\n}: UseItemQueryProps<T>) => {\n const { queryCache } = container.resolve(QueryClientService);\n const [itemFromCache, setItemFromCache] = useState<T>(container.resolve(QueryClientService).getItemFromCache<T>(baseQueryKey, itemId));\n\n const useQueryResult = useQueryMemo({\n ...useQueryOptions,\n enabled: !itemFromCache && useQueryOptions.enabled,\n queryKey: container.resolve(QueryClientService).getGenericKey(baseQueryKey, itemId),\n });\n\n useEffect(() => {\n const handleQueryCacheEvent = (event: QueryCacheNotifyEvent) => {\n if (Array.isArray(event.query.queryKey) && event.query.queryKey[0] === baseQueryKey && eventTypes.includes(event.type)) {\n if (event.query.queryKey.length === 1) {\n const list = (event.query.state.data as T[]);\n if (event.type === 'removed') {\n setItemFromCache(undefined);\n return;\n }\n if (!list) {\n return;\n }\n const newValue = list?.find(item => item.id === itemId);\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n } else if (event.query.queryKey.length === 2 && (event.query.state.data as T)?.id === itemId) {\n const newValue = event.query.state.data as T;\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n }\n }\n };\n\n const removeListener = queryCache.subscribe(handleQueryCacheEvent);\n return () => {\n removeListener();\n };\n }, [baseQueryKey, itemId, queryCache, itemFromCache]);\n\n\n const result = useMemo(() => {\n return {\n data: itemFromCache || useQueryResult.data,\n error: itemFromCache ? false : useQueryResult.error,\n isEnabled: itemFromCache ? true : useQueryResult.isEnabled,\n isFetching: itemFromCache ? false : useQueryResult.isFetching,\n isLoading: itemFromCache ? false : useQueryResult.isLoading,\n isPending: itemFromCache ? false : useQueryResult.isPending,\n };\n }, [itemFromCache, useQueryResult.data, useQueryResult.isLoading, useQueryResult.isPending, useQueryResult.isFetching, useQueryResult.isEnabled, useQueryResult.error]);\n\n return result;\n};\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,KAAiBK,EAAe;EACtC,OAAO,MAAwBA,EAAe;EAC9C,WAAWL,IAAgB,KAAOK,EAAe;EACjD,YAAY,MAAwBA,EAAe;EACnD,WAAW,MAAwBA,EAAe;EAClD,WAAW,MAAwBA,EAAe;CACpD,IACC;EAACL;EAAeK,EAAe;EAAMA,EAAe;EAAWA,EAAe;EAAWA,EAAe;EAAYA,EAAe;EAAWA,EAAe;CAAK,CAE9J;AACT"}
@@ -1,7 +1,7 @@
1
1
  import { BreadcrumbService as e } from "../../classes/services/BreadcrumbService/index.js";
2
2
  import { container as t } from "tsyringe";
3
3
  import { useCallback as n, useEffect as r } from "react";
4
- //#region src/hooks/useUpdateBreadcrumb/useUpdateBreadcrumb.ts
4
+ // src/hooks/useUpdateBreadcrumb/useUpdateBreadcrumb.ts
5
5
  var i = (i) => {
6
6
  let a = n((n) => {
7
7
  t.resolve(e).update(i, n);
@@ -10,7 +10,6 @@ var i = (i) => {
10
10
  t.resolve(e).remove(i);
11
11
  }, [i]), a;
12
12
  };
13
- //#endregion
14
13
  export { i as useUpdateBreadcrumb };
15
14
 
16
15
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,12 @@
1
1
  import { useConfig as e } from "../useConfig/index.js";
2
2
  import { useEffect as t } from "react";
3
- //#region src/hooks/useUpdateDocumentTitle/useUpdateDocumentTitle.ts
3
+ // src/hooks/useUpdateDocumentTitle/useUpdateDocumentTitle.ts
4
4
  var n = (n) => {
5
5
  let r = e();
6
6
  t(() => {
7
7
  document.title = `${r.applicationName} - ${n}`;
8
8
  }, [r.applicationName, n]);
9
9
  };
10
- //#endregion
11
10
  export { n as useUpdateDocumentTitle };
12
11
 
13
12
  //# sourceMappingURL=index.js.map
@@ -114,6 +114,7 @@
114
114
  "Enable all with data": "Enable all with data",
115
115
  "Error": "Error",
116
116
  "Error anonymizing user: {{userName}}": "Error anonymizing user: {{userName}}",
117
+ "Error loading organization admins": "Error loading organization admins",
117
118
  "Execute": "Execute",
118
119
  "Expected end: ": "Expected end: ",
119
120
  "Expected start: ": "Expected start: ",
@@ -114,6 +114,7 @@
114
114
  "Enable all with data": "Alles met data inschakelen",
115
115
  "Error": "Fout",
116
116
  "Error anonymizing user: {{userName}}": "Fout bij anonimiseren van gebruiker: {{userName}}",
117
+ "Error loading organization admins": "Fout bij het laden van de organisatiebeheerders",
117
118
  "Execute": "Uitvoeren",
118
119
  "Expected end: ": "Verwacht einde: ",
119
120
  "Expected start: ": "Verwachte start: ",
@@ -1,8 +1,7 @@
1
- //#region src/models/admin.models.ts
1
+ // src/models/admin.models.ts
2
2
  var e = /* @__PURE__ */ function(e) {
3
3
  return e.ACCESS_RIGHTS = "ACCESS_RIGHTS", e.HELPERS = "HELPERS", e.REFERENCE_DATA = "REFERENCE_DATA", e.SYSTEM = "SYSTEM", e.USERS_AND_ORGANIZATIONS = "USERS_AND_ORGANIZATIONS", e;
4
4
  }({});
5
- //#endregion
6
5
  export { e as ADMIN_PAGE_CATEGORY };
7
6
 
8
7
  //# sourceMappingURL=admin.models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.models.js","names":["ADMIN_PAGE_CATEGORY","\"ACCESS_RIGHTS\"","\"HELPERS\"","\"REFERENCE_DATA\"","\"SYSTEM\"","\"USERS_AND_ORGANIZATIONS\""],"sources":["../../src/models/admin.models.ts"],"sourcesContent":["export enum ADMIN_PAGE_CATEGORY {\n ACCESS_RIGHTS = 'ACCESS_RIGHTS',\n HELPERS = 'HELPERS',\n REFERENCE_DATA = 'REFERENCE_DATA',\n SYSTEM = 'SYSTEM',\n USERS_AND_ORGANIZATIONS = 'USERS_AND_ORGANIZATIONS',\n}\n"],"mappings":";AAAA,IAAYA,IAAL,yBAAA,GAAA;QACL,EAAAC,gBAAA,iBACA,EAAAC,UAAA,WACA,EAAAC,iBAAA,kBACA,EAAAC,SAAA,UACA,EAAAC,0BAAA;AACF,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"admin.models.js","names":["ADMIN_PAGE_CATEGORY","\"ACCESS_RIGHTS\"","\"HELPERS\"","\"REFERENCE_DATA\"","\"SYSTEM\"","\"USERS_AND_ORGANIZATIONS\""],"sources":["../../src/models/admin.models.ts"],"sourcesContent":["export enum ADMIN_PAGE_CATEGORY {\n ACCESS_RIGHTS = 'ACCESS_RIGHTS',\n HELPERS = 'HELPERS',\n REFERENCE_DATA = 'REFERENCE_DATA',\n SYSTEM = 'SYSTEM',\n USERS_AND_ORGANIZATIONS = 'USERS_AND_ORGANIZATIONS',\n}\n"],"mappings":";AAAA,IAAYA,IAAL,yBAAA,GAAA;C,OACL,EAAAC,gBAAA,iBACA,EAAAC,UAAA,WACA,EAAAC,iBAAA,kBACA,EAAAC,SAAA,UACA,EAAAC,0BAAA,2B;AACF,EAAA,CAAA,CAAA"}