@gen-epix/ui-client-common 4.5.0 → 4.5.1
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.
- package/README.md +5 -4
- package/dist/@types/mui.d.ts +13 -5
- package/dist/@types/ui-client-common.d.ts +1 -0
- package/dist/_chunks/ApplicationFooter.js +44 -44
- package/dist/_chunks/ApplicationFooter.js.map +1 -1
- package/dist/_chunks/Breadcrumbs.js +13 -13
- package/dist/_chunks/CrudPage.js +300 -300
- package/dist/_chunks/CrudPage.js.map +1 -1
- package/dist/_chunks/Notifications.js +51 -51
- package/dist/_chunks/OutageList.js +29 -29
- package/dist/_chunks/OutageUtil.js +1 -2
- package/dist/_chunks/OutageUtil.js.map +1 -1
- package/dist/_chunks/QueryClientService.js +96 -388
- package/dist/_chunks/QueryClientService.js.map +1 -1
- package/dist/_chunks/Table.js +518 -512
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/TableUtil.js +8 -16
- package/dist/_chunks/TableUtil.js.map +1 -1
- package/dist/_chunks/TextFilter.js +14 -12
- package/dist/_chunks/TextFilter.js.map +1 -1
- package/dist/_chunks/UserInvitationsAdminPage.js +77 -77
- package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
- package/dist/_chunks/UserManagerUtil.js +210 -209
- package/dist/_chunks/UserManagerUtil.js.map +1 -1
- package/dist/_chunks/_baseFlatten.js +8 -8
- package/dist/_chunks/_baseFlatten.js.map +1 -1
- package/dist/_chunks/_baseGet.js +280 -0
- package/dist/_chunks/_baseGet.js.map +1 -0
- package/dist/_chunks/_baseIteratee.js +274 -0
- package/dist/_chunks/_baseIteratee.js.map +1 -0
- package/dist/_chunks/_baseUnset.js +22 -299
- package/dist/_chunks/_baseUnset.js.map +1 -1
- package/dist/_chunks/last.js +13 -0
- package/dist/_chunks/last.js.map +1 -0
- package/dist/_chunks/omit.js +41 -40
- package/dist/_chunks/omit.js.map +1 -1
- package/dist/_chunks/tableStore.js +190 -183
- package/dist/_chunks/tableStore.js.map +1 -1
- package/dist/_chunks/uniq.js +44 -0
- package/dist/_chunks/uniq.js.map +1 -0
- package/dist/_chunks/useMutation.js +22 -22
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +25 -8
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/classes/abstracts/FilterAbstract/index.js +3 -1
- package/dist/classes/abstracts/FilterAbstract/index.js.map +1 -1
- package/dist/classes/filters/MultiSelectFilter.d.ts +1 -1
- package/dist/classes/services/AuthenticationService/AuthenticationService.d.ts +1 -1
- package/dist/classes/services/AuthenticationService/index.js +15 -15
- package/dist/classes/services/AuthenticationService/index.js.map +1 -1
- package/dist/classes/services/AuthorizationService/index.js +4 -4
- package/dist/classes/services/AuthorizationService/index.js.map +1 -1
- package/dist/classes/services/BackendVersionService/index.js +3 -2
- package/dist/classes/services/BackendVersionService/index.js.map +1 -1
- package/dist/classes/services/BreadcrumbService/index.js +16 -38
- package/dist/classes/services/BreadcrumbService/index.js.map +1 -1
- package/dist/classes/services/EmotionCacheService/index.js +9 -8
- package/dist/classes/services/EmotionCacheService/index.js.map +1 -1
- package/dist/classes/services/I18nService/index.js +11 -10
- package/dist/classes/services/I18nService/index.js.map +1 -1
- package/dist/classes/services/InactivityService/index.js +12 -12
- package/dist/classes/services/InactivityService/index.js.map +1 -1
- package/dist/classes/services/LogService/index.js +39 -33
- package/dist/classes/services/LogService/index.js.map +1 -1
- package/dist/classes/services/NotificationService/index.js +8 -8
- package/dist/classes/services/NotificationService/index.js.map +1 -1
- package/dist/classes/services/PageEventBusService/index.js +13 -9
- package/dist/classes/services/PageEventBusService/index.js.map +1 -1
- package/dist/classes/services/RouterService/index.js +3 -6
- package/dist/classes/services/RouterService/index.js.map +1 -1
- package/dist/components/app/App/App.d.ts +1 -1
- package/dist/components/app/App/index.js +34 -38
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +28 -28
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js +47 -45
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
- package/dist/components/app/AuthenticationWrapper/index.js +35 -35
- package/dist/components/app/AuthenticationWrapper/index.js.map +1 -1
- package/dist/components/app/AuthorizationWrapper/index.js +19 -19
- package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
- package/dist/components/app/RouterRoot/index.js +52 -50
- package/dist/components/app/RouterRoot/index.js.map +1 -1
- package/dist/components/epi/EpiContactDetailsDialog/index.js +21 -21
- package/dist/components/filters/BooleanFilterField/index.js +5 -5
- package/dist/components/filters/DateFilterField/index.js +3 -3
- package/dist/components/filters/GeoFilterField/index.js +4 -4
- package/dist/components/filters/MultiSelectFilterField/index.js +4 -4
- package/dist/components/filters/NumberRangeFilterField/index.js +3 -3
- package/dist/components/filters/TextFilterField/index.js +3 -3
- package/dist/components/ui/ApplicationBar/index.js +188 -188
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/GenericErrorMessage/index.js +29 -29
- package/dist/components/ui/LicensesDialog/index.js +38 -38
- package/dist/components/ui/LicensesDialog/index.js.map +1 -1
- package/dist/components/ui/MyPermissionsDialog/index.js +16 -16
- package/dist/components/ui/NavLink/index.js +6 -6
- package/dist/components/ui/OrganizationSwitcherDialog/index.js +21 -21
- package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
- package/dist/components/ui/PageContainer/index.js +24 -24
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/Sidebar/index.js +30 -30
- package/dist/components/ui/UserFeedbackDialog/index.js +12 -12
- package/dist/constants/config.constants.d.ts +0 -2
- package/dist/constants/config.constants.js +2 -2
- package/dist/constants/config.constants.js.map +1 -1
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js +12 -12
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js.map +1 -1
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js +14 -14
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js.map +1 -1
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js +12 -12
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js +13 -13
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js +4 -4
- package/dist/dataHooks/useOrganizationsQuery/index.js +13 -13
- package/dist/dataHooks/useOrganizationsQuery/index.js.map +1 -1
- package/dist/dataHooks/useUsersQuery/index.js +10 -10
- package/dist/dataHooks/useUsersQuery/index.js.map +1 -1
- package/dist/hooks/useConfig/index.js +2 -2
- package/dist/hooks/useConfig/index.js.map +1 -1
- package/dist/hooks/useCreateMutation/index.js +12 -12
- package/dist/hooks/useCreateMutation/index.js.map +1 -1
- package/dist/hooks/useDeleteMutation/index.js +16 -9
- package/dist/hooks/useDeleteMutation/index.js.map +1 -1
- package/dist/hooks/useEditMutation/index.js +48 -33
- package/dist/hooks/useEditMutation/index.js.map +1 -1
- package/dist/hooks/useItemQuery/index.js +4 -4
- package/dist/hooks/useItemQuery/index.js.map +1 -1
- package/dist/locale/en.json +1 -0
- package/dist/locale/nl.json +1 -0
- package/dist/models/config.models.d.ts +1 -5
- package/dist/models/theme.models.d.ts +19 -16
- package/dist/pages/AcceptInvitationPage/index.js +25 -25
- package/dist/pages/AcceptInvitationPage/index.js.map +1 -1
- package/dist/pages/AdminPage/index.js +16 -16
- package/dist/pages/ChooseIdentityProviderPage/index.js +21 -21
- package/dist/pages/IdentifierIssuersAdminPage/index.js +5 -5
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +5 -5
- package/dist/pages/OrganizationContactsAdminPage/index.js +6 -6
- package/dist/pages/OrganizationSitesAdminPage/index.js +9 -9
- package/dist/pages/OrganizationsAdminPage/index.js +13 -13
- package/dist/pages/OutagesAdminPage/index.js +20 -20
- package/dist/pages/PostLoginPage/index.js +6 -6
- package/dist/pages/PostLogoutPage/index.js +8 -8
- package/dist/pages/UsersAdminPage/index.js +39 -39
- package/dist/pages/UsersAdminPage/index.js.map +1 -1
- package/dist/setup/setup.js +11 -4
- package/dist/setup/setup.js.map +1 -1
- package/dist/theme/demoTheme/index.js +17 -15
- package/dist/theme/demoTheme/index.js.map +1 -1
- package/dist/utils/DataHookUtil/index.js +1 -1
- package/dist/utils/DataHookUtil/index.js.map +1 -1
- package/dist/utils/DependencyContainerUtil/DependencyContainerUtil.d.ts +2 -3
- package/dist/utils/DependencyContainerUtil/index.js +10 -15
- package/dist/utils/DependencyContainerUtil/index.js.map +1 -1
- package/dist/utils/MenuDataUtil/index.js +1 -1
- package/dist/utils/MenuDataUtil/index.js.map +1 -1
- package/dist/utils/StandardConfigUtil/index.js +0 -4
- package/dist/utils/StandardConfigUtil/index.js.map +1 -1
- package/dist/utils/TimeUtil/index.js +1 -1
- package/dist/utils/TimeUtil/index.js.map +1 -1
- package/package.json +10 -13
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContext.d.ts +0 -9
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContextProvider.d.ts +0 -6
- package/dist/context/ClientCommonConfigContext/index.d.ts +0 -3
- package/dist/context/ClientCommonConfigContext/index.js +0 -34
- package/dist/context/ClientCommonConfigContext/index.js.map +0 -1
- package/dist/context/ClientCommonConfigContext/useClientCommonConfigContext.d.ts +0 -3
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../_chunks/
|
|
3
|
-
import {
|
|
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
7
|
//#region 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(
|
|
10
|
-
mutationFn: async (e) =>
|
|
11
|
-
|
|
12
|
-
|
|
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 (
|
|
31
|
-
o && await i.resolve(
|
|
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(() => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
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,IAAMC,IAAcC,EAAU,QAAQC,CAAkB,CAAC,CAAC,aAEpDC,IAAiBL,EAAiE;EACtF,YAAY,OAAO,MAAS;GAC1B,IAAI,CAACM,GACH,MAAU,MAAM,qCAAqC;GAEvD,OAAOA,EAAQC,CAAI;EACrB;EACA,SAAS,OAAO,GAAO,GAAM,MAAY;GAOvC,AANIC,KAAoB,MAAM,QAAQC,EAAQ,YAAY,KACxDP,EAAY,aAAsBM,GAAkBC,EAAQ,YAAY,GAEtEC,KACF,MAAMP,EAAU,QAAQC,CAAkB,CAAC,CAAC,oBAAoBM,CAAoB,GAElFC,KACF,MAAMA,EAAQC,GAAOL,GAAME,CAAO;GAEpC,IAAMI,IAAeC,IAA8BP,GAAMK,CAAK,KAAK,OAAOA,CAAK;GAC/E,EAAU,QAAQG,CAAmB,CAAC,CAAC,oBAAoBN,EAAQ,iBAAiBO,EAAiB,6BAA6BH,GAAcD,CAAK,GAAG,OAAO;EACjK;EACA,UAAU,OAAO,MAAS;GACxB,IAAMK,IAAkBd,EAAU,QAAQY,CAAmB,CAAC,CAAC,iBAAiB;IAC9E,WAAW;IACX,SAASG,EAA+BX,CAAI;IAC5C,UAAU;GACZ,CAAC;GACD,IAAIC,GAAkB;IACpB,MAAMN,EAAY,cAAc,EAAE,UAAUM,EAAiB,CAAC;IAC9D,IAAMW,IAAejB,EAAY,aAAsBM,CAAgB;IAEvE,IAAI,MAAM,QAAQW,CAAY,KAAK,CAAC,MAAM,QAAQZ,CAAI,GAIpD,OAHAL,EAAY,aAA4BM,IAAmB,MAClDY,EAAS,QAAO,MAAKC,EAAE,OAAOd,EAAK,EAAE,CAC7C,GACM;KAAE;KAAiB;IAAa;GAE3C;GACA,OAAO,EAAE,mBAAgB;EAC3B;EACA,WAAW,OAAO,GAAO,GAAM,MAAY;GAIzC,AAHIG,KACF,MAAMP,EAAU,QAAQC,CAAkB,CAAC,CAAC,oBAAoBM,CAAoB,GAElFY,KACF,MAAMA,EAAUf,GAAME,CAAO;GAE/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,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../_chunks/
|
|
3
|
-
import {
|
|
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
8
|
//#region src/hooks/useEditMutation/useEditMutation.ts
|
|
9
|
-
var l = ({ associationQueryKeys:
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
}, []),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 =
|
|
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:
|
|
29
|
+
message: p(t, e),
|
|
21
30
|
severity: "info"
|
|
22
31
|
});
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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:
|
|
38
|
+
id: t.id
|
|
31
39
|
};
|
|
32
|
-
return
|
|
33
|
-
item:
|
|
34
|
-
notificationKey:
|
|
35
|
-
previousData:
|
|
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 {
|
|
47
|
+
return {
|
|
48
|
+
item: t,
|
|
49
|
+
notificationKey: n
|
|
50
|
+
};
|
|
40
51
|
},
|
|
41
|
-
onSuccess: async (
|
|
42
|
-
|
|
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
|
-
}),
|
|
59
|
+
}), w = o(() => C.mutate, [C.mutate]), T = o(() => C.isPending, [C.isPending]);
|
|
45
60
|
return o(() => ({
|
|
46
|
-
isMutating:
|
|
47
|
-
mutate:
|
|
48
|
-
setPreviousItem:
|
|
61
|
+
isMutating: T,
|
|
62
|
+
mutate: w,
|
|
63
|
+
setPreviousItem: x
|
|
49
64
|
}), [
|
|
65
|
+
T,
|
|
50
66
|
w,
|
|
51
|
-
|
|
52
|
-
b
|
|
67
|
+
x
|
|
53
68
|
]);
|
|
54
69
|
};
|
|
55
70
|
//#endregion
|
|
56
|
-
export {
|
|
71
|
+
export { u as useEditMutation };
|
|
57
72
|
|
|
58
73
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useMutation","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":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "../../_chunks/
|
|
2
|
-
import { t } from "../../_chunks/
|
|
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
5
|
//#region src/hooks/useItemQuery/useItemQuery.ts
|
|
@@ -8,10 +8,10 @@ var o = [
|
|
|
8
8
|
"removed",
|
|
9
9
|
"updated"
|
|
10
10
|
], s = ({ baseQueryKey: s, itemId: c, useQueryOptions: l }) => {
|
|
11
|
-
let { queryCache: u } = n.resolve(
|
|
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(
|
|
14
|
+
queryKey: n.resolve(t).getGenericKey(s, c)
|
|
15
15
|
});
|
|
16
16
|
return r(() => {
|
|
17
17
|
let e = u.subscribe((e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
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};\n"],"mappings":";;;;;AAqBA,IAAMC,IAA8C;CAAC;CAAS;CAAW;AAAS,GAErEC,KAAuC,EAClD,iBACA,WACA,yBAC0B;CAC1B,IAAM,EAAE,kBAAeC,EAAU,QAAQC,CAAkB,GACrD,CAACC,GAAeC,KAAoBC,EAAYJ,EAAU,QAAQC,CAAkB,CAAC,CAAC,iBAAoBI,GAAcC,CAAM,CAAC,GAE/HC,IAAiBV,EAAa;EAClC,GAAGW;EACH,SAAS,CAACN,KAAiBM,EAAgB;EAC3C,UAAUR,EAAU,QAAQC,CAAkB,CAAC,CAAC,cAAcI,GAAcC,CAAM;CACpF,CAAC;CA6CD,OA3CAG,QAAgB;EAyBd,IAAMC,IAAiBC,EAAW,WAxBH,MAAiC;GAC9D,IAAI,MAAM,QAAQC,EAAM,MAAM,QAAQ,KAAKA,EAAM,MAAM,SAAS,OAAOP,KAAgBP,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,OAAOT,CAAM;KACtD,AAAI,KAAK,UAAUJ,CAAa,MAAM,KAAK,UAAUY,CAAQ,KAC3DX,EAAiBW,CAAQ;IAE7B,OAAO,IAAIF,EAAM,MAAM,SAAS,WAAW,KAAMA,EAAM,MAAM,MAAM,MAAY,OAAON,GAAQ;KAC5F,IAAMQ,IAAWF,EAAM,MAAM,MAAM;KACnC,AAAI,KAAK,UAAUV,CAAa,MAAM,KAAK,UAAUY,CAAQ,KAC3DX,EAAiBW,CAAQ;IAE7B;GACF;EACF,CAEiE;EACjE,aAAa;GACX,EAAe;EACjB;CACF,GAAG;EAACT;EAAcC;EAAQK;EAAYT;CAAa,CAAC,GAGrCc,SACN;EACL,MAAMd,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"}
|
package/dist/locale/en.json
CHANGED
|
@@ -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: ",
|
package/dist/locale/nl.json
CHANGED
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
3
|
export type ApplicationHeaderProps = {
|
|
4
4
|
readonly fullHeight?: boolean;
|
|
5
5
|
readonly fullWidth?: boolean;
|
|
@@ -45,10 +45,6 @@ export interface ConfigBase {
|
|
|
45
45
|
retry: (failureCount: number, error: unknown) => boolean;
|
|
46
46
|
retryDelay: (attempt: number) => number;
|
|
47
47
|
};
|
|
48
|
-
spinner: {
|
|
49
|
-
DEFAULT_CIRCULAR_PROGRESS_SIZE: CircularProgressProps['size'];
|
|
50
|
-
DEFAULT_TAKING_LONGER_TIMEOUT_MS: number;
|
|
51
|
-
};
|
|
52
48
|
table: {
|
|
53
49
|
CONDENSED_WIDTH_PX: number;
|
|
54
50
|
DEFAULT_OVERSCAN_MAIN: number;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { GenEpixCoreComponentsTheme } from '@gen-epix/ui-core-components/models/theme.models';
|
|
2
|
+
export interface GenEpixUiClientCommonFooterTheme {
|
|
3
|
+
background: string;
|
|
4
|
+
color: string;
|
|
5
|
+
sectionBorderColor: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GenEpixUiClientCommonNavbarTheme {
|
|
8
|
+
activeBackground: string;
|
|
9
|
+
activeColor: string;
|
|
10
|
+
background: string;
|
|
11
|
+
environmentMessageColor: string;
|
|
12
|
+
primaryColor: string;
|
|
13
|
+
secondaryColor: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GenEpixUiClientCommonTheme extends GenEpixCoreComponentsTheme {
|
|
16
|
+
components: {
|
|
17
|
+
GenEpixUiClientCommonFooter: GenEpixUiClientCommonFooterTheme;
|
|
18
|
+
GenEpixUiClientCommonNavbar: GenEpixUiClientCommonNavbarTheme;
|
|
19
|
+
} & GenEpixCoreComponentsTheme['components'];
|
|
17
20
|
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
|
+
import { useConfig as t } from "../../hooks/useConfig/index.js";
|
|
3
|
+
import { PageContainer as n } from "../../components/ui/PageContainer/index.js";
|
|
4
|
+
import { ResponseHandler as r } from "../../components/ui/ResponseHandler/index.js";
|
|
5
|
+
import { t as i } from "../../_chunks/useQueryMemo.js";
|
|
6
|
+
import { t as a } from "../../_chunks/QueryClientService.js";
|
|
7
7
|
import { COMMON_QUERY_KEY as o } from "../../constants/query.constants.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
8
|
+
import { container as s } from "tsyringe";
|
|
9
|
+
import { WindowService as c } from "@gen-epix/ui-core/classes/services/WindowService";
|
|
10
|
+
import { Box as l, Button as u, Typography as d } from "@mui/material";
|
|
11
|
+
import { useCallback as f, useState as p } from "react";
|
|
12
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
13
|
import { useTranslation as _ } from "react-i18next";
|
|
14
14
|
import { TestIdUtil as v } from "@gen-epix/ui-core/utils/TestIdUtil";
|
|
15
15
|
import { useParams as y } from "react-router-dom";
|
|
16
16
|
//#region src/pages/AcceptInvitationPage/AcceptInvitationPage.tsx
|
|
17
17
|
var b = () => {
|
|
18
|
-
let { token: b } = y(), x =
|
|
18
|
+
let { token: b } = y(), x = t(), [S, C] = p(!1), { data: w, error: T, isLoading: E } = i({
|
|
19
19
|
enabled: S,
|
|
20
20
|
gcTime: 0,
|
|
21
|
-
queryFn: async ({ signal:
|
|
22
|
-
queryKey:
|
|
21
|
+
queryFn: async ({ signal: t }) => (await s.resolve(e).userRegistrationsPostOne(b, { signal: t })).data,
|
|
22
|
+
queryKey: s.resolve(a).getGenericKey(o.USER_INVITATIONS, b),
|
|
23
23
|
staleTime: 0
|
|
24
|
-
}), { t: D } = _(), O =
|
|
25
|
-
s.
|
|
26
|
-
}, []), k =
|
|
24
|
+
}), { t: D } = _(), O = f(() => {
|
|
25
|
+
s.resolve(c).window.location.href = "/";
|
|
26
|
+
}, []), k = f(() => {
|
|
27
27
|
C(!0);
|
|
28
28
|
}, []);
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ h(n, {
|
|
30
30
|
singleAction: !0,
|
|
31
31
|
testIdAttributes: v.createAttributes("AcceptInvitationPage"),
|
|
32
32
|
title: D`Invitation`,
|
|
33
|
-
children: /* @__PURE__ */
|
|
33
|
+
children: /* @__PURE__ */ g(r, {
|
|
34
34
|
enabled: S,
|
|
35
35
|
error: T,
|
|
36
36
|
isLoading: E,
|
|
37
|
-
children: [!w && /* @__PURE__ */
|
|
37
|
+
children: [!w && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(l, {
|
|
38
38
|
sx: { marginY: 2 },
|
|
39
|
-
children: /* @__PURE__ */
|
|
40
|
-
}), /* @__PURE__ */
|
|
39
|
+
children: /* @__PURE__ */ h(d, { children: D("You have been invited to join {{applicationName}}.", { applicationName: x.applicationName }) })
|
|
40
|
+
}), /* @__PURE__ */ h(l, {
|
|
41
41
|
sx: { marginY: 2 },
|
|
42
|
-
children: /* @__PURE__ */
|
|
42
|
+
children: /* @__PURE__ */ h(u, {
|
|
43
43
|
color: "primary",
|
|
44
44
|
onClick: k,
|
|
45
45
|
type: "submit",
|
|
46
46
|
children: D`Complete registration`
|
|
47
47
|
})
|
|
48
|
-
})] }), w && /* @__PURE__ */
|
|
48
|
+
})] }), w && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(l, { children: /* @__PURE__ */ h(d, { children: D("You have been successfully registered to {{applicationName}}.", { applicationName: x.applicationName }) }) }), /* @__PURE__ */ h(l, {
|
|
49
49
|
sx: { marginY: 2 },
|
|
50
|
-
children: /* @__PURE__ */
|
|
50
|
+
children: /* @__PURE__ */ h(u, {
|
|
51
51
|
color: "primary",
|
|
52
52
|
onClick: O,
|
|
53
53
|
children: D`Click here to visit the home page`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","QueryClientService","Fragment$1","AcceptInvitationPage","useParams","config","useConfig","shouldRegister","setShouldRegister","useState","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","useQueryMemo","QueryClientService","Fragment$1","AcceptInvitationPage","useParams","config","useConfig","shouldRegister","setShouldRegister","useState","container","API_ORGANIZATION_TOKEN","token","COMMON_QUERY_KEY","useTranslation","onGoToHomePageButtonClick","useCallback","WindowService","onCompleteRegistrationButtonClick","PageContainer","TestIdUtil","ResponseHandler","data","Box","Typography","t","Button"],"sources":["../../../src/pages/AcceptInvitationPage/AcceptInvitationPage.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useTranslation } from 'react-i18next';\nimport { useParams } from 'react-router-dom';\nimport {\n Box,\n Button,\n Typography,\n} from '@mui/material';\nimport {\n useCallback,\n useState,\n} from 'react';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport { PageContainer } from '../../components/ui/PageContainer';\nimport { ResponseHandler } from '../../components/ui/ResponseHandler';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { useConfig } from '../../hooks/useConfig';\n\nexport const AcceptInvitationPage = () => {\n const { token } = useParams();\n const config = useConfig();\n const [shouldRegister, setShouldRegister] = useState(false);\n\n const { data, error, isLoading } = useQueryMemo({\n enabled: shouldRegister,\n gcTime: 0,\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).userRegistrationsPostOne(token, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USER_INVITATIONS, token),\n staleTime: 0,\n });\n\n const { t } = useTranslation();\n\n const onGoToHomePageButtonClick = useCallback(() => {\n container.resolve(WindowService).window.location.href = '/';\n }, []);\n\n const onCompleteRegistrationButtonClick = useCallback(() => {\n setShouldRegister(true);\n }, []);\n\n return (\n <PageContainer\n singleAction\n testIdAttributes={TestIdUtil.createAttributes('AcceptInvitationPage')}\n title={t`Invitation`}\n >\n <ResponseHandler\n enabled={shouldRegister}\n error={error}\n isLoading={isLoading}\n >\n {!data && (\n <>\n <Box\n sx={{\n marginY: 2,\n }}\n >\n <Typography>\n {t('You have been invited to join {{applicationName}}.', { applicationName: config.applicationName })}\n </Typography>\n </Box>\n <Box\n sx={{\n marginY: 2,\n }}\n >\n <Button\n color={'primary'}\n onClick={onCompleteRegistrationButtonClick}\n type={'submit'}\n >\n {t`Complete registration`}\n </Button>\n </Box>\n </>\n )}\n {data && (\n <>\n <Box>\n <Typography>\n {t('You have been successfully registered to {{applicationName}}.', { applicationName: config.applicationName })}\n </Typography>\n </Box>\n <Box\n sx={{\n marginY: 2,\n }}\n >\n <Button\n color={'primary'}\n onClick={onGoToHomePageButtonClick}\n >\n {t`Click here to visit the home page`}\n </Button>\n </Box>\n </>\n )}\n </ResponseHandler>\n </PageContainer>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,IAAaI,UAA6B;CACxC,IAAM,EAAE,aAAUC,EAAU,GACtBC,IAASC,EAAU,GACnB,CAACC,GAAgBC,KAAqBC,EAAS,EAAK,GAEpD,EAAE,SAAM,UAAO,iBAAcT,EAAa;EAC9C,SAASO;EACT,QAAQ;EACR,SAAS,OAAO,EAAE,iBAET,MADgBG,EAAU,QAAQC,CAAsB,CAAC,CAAC,yBAAyBC,GAAO,EAAE,UAAO,CAAC,EAAA,CAC3F;EAElB,UAAUF,EAAU,QAAQT,CAAkB,CAAC,CAAC,cAAcY,EAAiB,kBAAkBD,CAAK;EACtG,WAAW;CACb,CAAC,GAEK,EAAE,SAAME,EAAe,GAEvBC,IAA4BC,QAAkB;EAClD,EAAU,QAAQC,CAAa,CAAC,CAAC,OAAO,SAAS,OAAO;CAC1D,GAAG,CAAC,CAAC,GAECC,IAAoCF,QAAkB;EAC1D,EAAkB,EAAI;CACxB,GAAG,CAAC,CAAC;CAEL,OACE,kBAACG,GAAD;EACE,cAAA;EACA,kBAAkBC,EAAW,iBAAiB,sBAAsB;EACpE,OAAO,CAAC;EAER,UAAA,kBAACC,GAAD;GACE,SAASd;GACF;GACI;GAHb,UAAA,CAKG,CAACe,KACA,kBAAAvB,GAAA,EAAA,UAAA,CACE,kBAACwB,GAAD;IACE,IAAI,EACF,SAAS,EACX;IAEA,UAAA,kBAACC,GAAD,EAAA,UACGC,EAAE,sDAAsD,EAAE,iBAAiBpB,EAAO,gBAAgB,CAAC,EAC1F,CAAA;GACT,CAAA,GACL,kBAACkB,GAAD;IACE,IAAI,EACF,SAAS,EACX;IAEA,UAAA,kBAACG,GAAD;KACE,OAAO;KACP,SAASR;KACT,MAAM;KAEL,UAAA,CAAC;IACI,CAAA;GACL,CAAA,CACL,EAAA,CAAA,GAEHI,KACC,kBAAAvB,GAAA,EAAA,UAAA,CACE,kBAACwB,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UACGC,EAAE,iEAAiE,EAAE,iBAAiBpB,EAAO,gBAAgB,CAAC,EACrG,CAAA,EACT,CAAA,GACL,kBAACkB,GAAD;IACE,IAAI,EACF,SAAS,EACX;IAEA,UAAA,kBAACG,GAAD;KACE,OAAO;KACP,SAASX;KAER,UAAA,CAAC;IACI,CAAA;GACL,CAAA,CACL,EAAA,CAAA,CAEW;;CACJ,CAAA;AAEnB"}
|
|
@@ -3,24 +3,24 @@ import { AuthorizationService as t } from "../../classes/services/AuthorizationS
|
|
|
3
3
|
import { RouterService as n } from "../../classes/services/RouterService/index.js";
|
|
4
4
|
import { PageContainer as r } from "../../components/ui/PageContainer/index.js";
|
|
5
5
|
import { container as i } from "tsyringe";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { Box as a, Card as o, CardActionArea as s, CardContent as c, CardHeader as l, Divider as u, Typography as d, useTheme as f } from "@mui/material";
|
|
7
|
+
import { useCallback as p, useMemo as m } from "react";
|
|
8
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
9
9
|
import { useTranslation as _ } from "react-i18next";
|
|
10
10
|
import { TestIdUtil as v } from "@gen-epix/ui-core/utils/TestIdUtil";
|
|
11
11
|
import { Outlet as y, useLocation as b } from "react-router-dom";
|
|
12
12
|
//#region src/pages/AdminPage/AdminPage.tsx
|
|
13
13
|
var x = () => {
|
|
14
|
-
let { t: x } = _(), S = b(), C =
|
|
14
|
+
let { t: x } = _(), S = b(), C = f(), w = m(() => i.resolve(n).adminRoutes.map((e) => e.children?.length ? e.children.find((e) => e.index) : e).filter((e) => {
|
|
15
15
|
let n = i.resolve(t).doesUserHavePermission(e.handle.requiredPermissions);
|
|
16
16
|
return !e.handle?.hidden && n;
|
|
17
|
-
}), []), T =
|
|
17
|
+
}), []), T = m(() => ({
|
|
18
18
|
[e.ACCESS_RIGHTS]: x`Access rights`,
|
|
19
19
|
[e.HELPERS]: x`Helpers`,
|
|
20
20
|
[e.REFERENCE_DATA]: x`Reference data`,
|
|
21
21
|
[e.SYSTEM]: x`System`,
|
|
22
22
|
[e.USERS_AND_ORGANIZATIONS]: x`Users and organizations`
|
|
23
|
-
}), [x]), E =
|
|
23
|
+
}), [x]), E = m(() => [
|
|
24
24
|
e.USERS_AND_ORGANIZATIONS,
|
|
25
25
|
e.ACCESS_RIGHTS,
|
|
26
26
|
e.SYSTEM,
|
|
@@ -30,26 +30,26 @@ var x = () => {
|
|
|
30
30
|
items: w.filter((t) => t.handle.category === e),
|
|
31
31
|
label: T[e],
|
|
32
32
|
name: e
|
|
33
|
-
})).filter((e) => e.items.length), [T, w]), D =
|
|
33
|
+
})).filter((e) => e.items.length), [T, w]), D = p(async (e) => {
|
|
34
34
|
await i.resolve(n).router.navigate(e);
|
|
35
35
|
}, []);
|
|
36
|
-
return S?.pathname === "/management" ? /* @__PURE__ */
|
|
36
|
+
return S?.pathname === "/management" ? /* @__PURE__ */ h(r, {
|
|
37
37
|
showBreadcrumbs: !0,
|
|
38
38
|
testIdAttributes: v.createAttributes("AdminPage"),
|
|
39
39
|
title: x`Management`,
|
|
40
|
-
children: /* @__PURE__ */
|
|
40
|
+
children: /* @__PURE__ */ h(a, { children: E.map((e) => /* @__PURE__ */ g(a, {
|
|
41
41
|
sx: {
|
|
42
42
|
marginBottom: 3,
|
|
43
43
|
marginTop: 1
|
|
44
44
|
},
|
|
45
45
|
children: [
|
|
46
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ h(d, {
|
|
47
47
|
component: "h2",
|
|
48
48
|
sx: { marginBottom: 1 },
|
|
49
49
|
variant: "h3",
|
|
50
50
|
children: e.label
|
|
51
51
|
}),
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ h(a, {
|
|
53
53
|
sx: {
|
|
54
54
|
display: "grid",
|
|
55
55
|
gap: C.spacing(1),
|
|
@@ -58,25 +58,25 @@ var x = () => {
|
|
|
58
58
|
[C.breakpoints.up("md")]: { gridTemplateColumns: "repeat(2, 1fr)" },
|
|
59
59
|
[C.breakpoints.up("xl")]: { gridTemplateColumns: "repeat(4, 1fr)" }
|
|
60
60
|
},
|
|
61
|
-
children: e.items.map((e) => /* @__PURE__ */
|
|
61
|
+
children: e.items.map((e) => /* @__PURE__ */ h(o, {
|
|
62
62
|
square: !0,
|
|
63
63
|
sx: {
|
|
64
64
|
flexDirection: "column",
|
|
65
65
|
justifyContent: "space-between"
|
|
66
66
|
},
|
|
67
|
-
children: /* @__PURE__ */
|
|
67
|
+
children: /* @__PURE__ */ g(s, {
|
|
68
68
|
onClick: async () => D(e.path),
|
|
69
|
-
children: [/* @__PURE__ */
|
|
69
|
+
children: [/* @__PURE__ */ h(l, { title: e.handle.title }), /* @__PURE__ */ h(c, { children: e.handle.subTitle })]
|
|
70
70
|
})
|
|
71
71
|
}, e.path))
|
|
72
72
|
}),
|
|
73
|
-
/* @__PURE__ */
|
|
73
|
+
/* @__PURE__ */ h(u, { sx: {
|
|
74
74
|
marginBottom: 2,
|
|
75
75
|
marginTop: 2
|
|
76
76
|
} })
|
|
77
77
|
]
|
|
78
78
|
}, e.name)) })
|
|
79
|
-
}) : /* @__PURE__ */
|
|
79
|
+
}) : /* @__PURE__ */ h(y, {});
|
|
80
80
|
};
|
|
81
81
|
//#endregion
|
|
82
82
|
export { x as AdminPage };
|