@gen-epix/ui-client-common 4.6.1 → 4.7.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.
- package/README.md +2 -2
- package/dist/_chunks/Breadcrumbs.js +4 -4
- package/dist/_chunks/CrudPage.js +166 -166
- package/dist/_chunks/CrudPage.js.map +1 -1
- package/dist/_chunks/Notifications.js +16 -16
- package/dist/_chunks/QueryClientProvider.js +1 -1
- package/dist/_chunks/QueryClientProvider.js.map +1 -1
- package/dist/_chunks/QueryClientService.js +73 -72
- package/dist/_chunks/QueryClientService.js.map +1 -1
- package/dist/_chunks/Table.js +853 -744
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/TableUtil.js +38 -38
- package/dist/_chunks/TableUtil.js.map +1 -1
- package/dist/_chunks/UserInvitationsAdminPage.js +131 -131
- package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
- package/dist/_chunks/_baseFlatten.js +12 -12
- package/dist/_chunks/_baseFlatten.js.map +1 -1
- package/dist/_chunks/_baseIteratee.js +78 -78
- package/dist/_chunks/_baseIteratee.js.map +1 -1
- package/dist/_chunks/decorate.js +1 -1
- package/dist/_chunks/decorateParam.js +1 -1
- package/dist/_chunks/middleware.js +66 -70
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/omit.js +98 -98
- package/dist/_chunks/omit.js.map +1 -1
- package/dist/_chunks/query.js +108 -92
- package/dist/_chunks/query.js.map +1 -1
- package/dist/_chunks/react.js +1 -1
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/tableStore.js +61 -58
- package/dist/_chunks/tableStore.js.map +1 -1
- package/dist/_chunks/useColumnsMenu.js +73 -71
- package/dist/_chunks/useColumnsMenu.js.map +1 -1
- package/dist/_chunks/useMutation.js +2 -2
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +15 -16
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -1
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -2
- package/dist/_chunks/yup.js.map +1 -1
- package/dist/classes/services/AuthenticationService/index.js +8 -8
- 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/BreadcrumbService/index.js +4 -4
- package/dist/classes/services/BreadcrumbService/index.js.map +1 -1
- package/dist/classes/services/EmotionCacheService/index.js.map +1 -1
- package/dist/classes/services/InactivityService/index.js +30 -30
- package/dist/classes/services/InactivityService/index.js.map +1 -1
- package/dist/classes/services/LogService/index.js +15 -15
- package/dist/classes/services/LogService/index.js.map +1 -1
- package/dist/classes/services/PageEventBusService/index.js.map +1 -1
- package/dist/components/app/App/index.js +26 -24
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +18 -18
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js +18 -18
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
- package/dist/components/app/AuthenticationWrapper/index.js +15 -15
- package/dist/components/app/AuthorizationWrapper/index.js +16 -16
- package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
- package/dist/components/app/RouterRoot/index.js +33 -33
- package/dist/components/app/RouterRoot/index.js.map +1 -1
- package/dist/components/epi/EpiContactDetailsDialog/index.js +4 -4
- package/dist/components/epi/EpiContactDetailsDialog/index.js.map +1 -1
- package/dist/components/ui/ApplicationBar/index.js +234 -234
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/GenericErrorMessage/index.js +13 -13
- package/dist/components/ui/LicensesDialog/index.js +6 -6
- package/dist/components/ui/OrganizationSwitcherDialog/index.js +11 -11
- package/dist/components/ui/OutagesDialog/index.js +4 -4
- package/dist/components/ui/OutagesDialog/index.js.map +1 -1
- package/dist/components/ui/PageContainer/index.js +5 -5
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/ResponseHandler/index.js +4 -4
- package/dist/components/ui/SortableList/SortableList.d.ts +5 -3
- package/dist/components/ui/Table/Table.d.ts +5 -2
- package/dist/components/ui/Table/TableColumnsEditorDialog.d.ts +13 -2
- package/dist/components/ui/Table/index.d.ts +1 -0
- package/dist/components/ui/Table/index.js +1 -1
- package/dist/components/ui/UserFeedbackDialog/index.js +15 -15
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js +12 -12
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js +11 -11
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js +5 -5
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js +15 -15
- package/dist/dataHooks/useOrganizationsQuery/index.js +7 -7
- package/dist/dataHooks/useUsersQuery/index.js +10 -10
- package/dist/hooks/useCreateMutation/index.js +14 -14
- package/dist/hooks/useCreateMutation/index.js.map +1 -1
- package/dist/hooks/useDeleteMutation/index.js +17 -17
- package/dist/hooks/useDeleteMutation/index.js.map +1 -1
- package/dist/hooks/useEditMutation/index.js +22 -22
- package/dist/hooks/useEditMutation/index.js.map +1 -1
- package/dist/hooks/useInitializeTableStore/index.js +6 -6
- package/dist/hooks/useInitializeTableStore/index.js.map +1 -1
- package/dist/locale/en.json +13 -5
- package/dist/locale/nl.json +13 -5
- package/dist/pages/AcceptInvitationPage/index.js +10 -10
- package/dist/pages/AdminPage/index.js +19 -19
- package/dist/pages/ChooseIdentityProviderPage/index.js +5 -5
- package/dist/pages/ErrorPage/index.js +4 -4
- package/dist/pages/IdentifierIssuersAdminPage/index.js +7 -7
- package/dist/pages/IdentifierIssuersAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +16 -16
- package/dist/pages/OrganizationContactsAdminPage/index.js +10 -10
- package/dist/pages/OrganizationContactsAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationSitesAdminPage/index.js +12 -12
- package/dist/pages/OrganizationSitesAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationsAdminPage/index.js +20 -20
- package/dist/pages/OrganizationsAdminPage/index.js.map +1 -1
- package/dist/pages/OutagesAdminPage/index.js +11 -11
- package/dist/pages/OutagesAdminPage/index.js.map +1 -1
- package/dist/pages/RouterErrorPage/index.js +4 -4
- package/dist/pages/UsersAdminPage/index.js +34 -34
- package/dist/pages/UsersAdminPage/index.js.map +1 -1
- package/dist/setup/setup.js +4 -4
- package/dist/setup/setup.js.map +1 -1
- package/dist/stores/oidcStore/oidcStore.d.ts +1 -1
- package/dist/utils/StandardConfigUtil/index.js +2 -2
- package/dist/utils/StandardConfigUtil/index.js.map +1 -1
- package/package.json +33 -33
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { UniqueIdentifier } from '@dnd-kit/core';
|
|
3
|
-
interface
|
|
3
|
+
export interface SortableListBaseItem {
|
|
4
4
|
id: UniqueIdentifier;
|
|
5
5
|
isSelected: boolean;
|
|
6
|
+
itemContent: ReactNode | string;
|
|
6
7
|
label: string;
|
|
7
8
|
}
|
|
8
|
-
interface Props<T extends
|
|
9
|
+
interface Props<T extends SortableListBaseItem> {
|
|
9
10
|
readonly items: T[];
|
|
10
11
|
onChange(items: T[]): void;
|
|
12
|
+
renderHeaderContent?: () => ReactNode;
|
|
11
13
|
renderItemContent(item: T): ReactNode;
|
|
12
14
|
}
|
|
13
|
-
export declare const SortableList: <T extends
|
|
15
|
+
export declare const SortableList: <T extends SortableListBaseItem>({ items, onChange, renderHeaderContent, renderItemContent, }: Props<T>) => import('react').JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SxProps, Theme } from '@mui/material';
|
|
2
|
-
import { Ref } from 'react';
|
|
2
|
+
import { ReactNode, Ref } from 'react';
|
|
3
3
|
import { ListRange } from 'react-virtuoso';
|
|
4
4
|
import { Subject } from '@gen-epix/ui-core/classes/Subject';
|
|
5
5
|
import { TableRowParams } from '../../../models/table.models';
|
|
6
|
+
import { TableColumnsEditorDialogItem } from './TableColumnsEditorDialog';
|
|
6
7
|
export type TableProps<TRowData, TDataContext = null> = {
|
|
7
8
|
readonly font?: string;
|
|
8
9
|
readonly forceHorizontalOverflow?: boolean;
|
|
@@ -19,6 +20,8 @@ export type TableProps<TRowData, TDataContext = null> = {
|
|
|
19
20
|
readonly overscanMain?: number;
|
|
20
21
|
readonly overscanReverse?: number;
|
|
21
22
|
readonly ref?: Ref<TableRef>;
|
|
23
|
+
readonly renderColumnsEditorHeaderContent?: () => ReactNode;
|
|
24
|
+
readonly renderColumnsEditorItemContent?: (item: TableColumnsEditorDialogItem<TRowData, TDataContext>) => ReactNode;
|
|
22
25
|
readonly rowHeight?: number;
|
|
23
26
|
readonly rowHighlightingSubject?: Subject<string[]>;
|
|
24
27
|
readonly sx?: SxProps<Theme>;
|
|
@@ -27,4 +30,4 @@ export interface TableRef {
|
|
|
27
30
|
scrollToIndex: (index: number, onScrolledToIndex?: () => void) => void;
|
|
28
31
|
setVerticalScrollPosition: (position: number) => void;
|
|
29
32
|
}
|
|
30
|
-
export declare const Table: <TRowData, TDataContext = null>({ font, forceHorizontalOverflow, getRowName, headerHeight, initialVisibleItemIndex, onRangeChanged, onReadableIndexClick, onRowClick, onRowMouseEnter, onRowMouseLeave, onVerticalScrollPositionChange, onVisibleItemIndexChange, overscanMain, overscanReverse, ref, rowHeight, rowHighlightingSubject, sx, }: TableProps<TRowData, TDataContext>) => import('react').JSX.Element;
|
|
33
|
+
export declare const Table: <TRowData, TDataContext = null>({ font, forceHorizontalOverflow, getRowName, headerHeight, initialVisibleItemIndex, onRangeChanged, onReadableIndexClick, onRowClick, onRowMouseEnter, onRowMouseLeave, onVerticalScrollPositionChange, onVisibleItemIndexChange, overscanMain, overscanReverse, ref, renderColumnsEditorHeaderContent, renderColumnsEditorItemContent, rowHeight, rowHighlightingSubject, sx, }: TableProps<TRowData, TDataContext>) => import('react').JSX.Element;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { WithDialogRefMethods, WithDialogRenderProps } from '@gen-epix/ui-core-components/hoc/withDialog';
|
|
2
|
-
import { HasCellDataFn } from '../../../models/table.models';
|
|
3
|
+
import { HasCellDataFn, TableColumn } from '../../../models/table.models';
|
|
4
|
+
import { SortableListBaseItem } from '../SortableList/SortableList';
|
|
5
|
+
export interface TableColumnsEditorDialogItem<TRowData, TDataContext> extends SortableListBaseItem {
|
|
6
|
+
column: TableColumn<TRowData, TDataContext>;
|
|
7
|
+
}
|
|
3
8
|
export interface TableColumnsEditorDialogOpenProps<TRowData, TDataContext> {
|
|
4
9
|
readonly hasCellData: HasCellDataFn<TRowData, TDataContext>;
|
|
5
10
|
}
|
|
6
11
|
export interface TableColumnsEditorDialogProps<TRowData, TDataContext> extends WithDialogRenderProps<TableColumnsEditorDialogOpenProps<TRowData, TDataContext>> {
|
|
12
|
+
renderHeaderContent?: () => ReactNode;
|
|
13
|
+
renderItemContent?: (item: TableColumnsEditorDialogItem<TRowData, TDataContext>) => ReactNode;
|
|
7
14
|
}
|
|
8
15
|
export type TableColumnsEditorDialogRefMethods<TRowData, TDataContext> = WithDialogRefMethods<TableColumnsEditorDialogProps<TRowData, TDataContext>, TableColumnsEditorDialogOpenProps<TRowData, TDataContext>>;
|
|
9
|
-
|
|
16
|
+
type TableColumnsEditorDialogComponent = {
|
|
17
|
+
new <TRowData, TDataContext>(props: TableColumnsEditorDialogProps<TRowData, TDataContext>): TableColumnsEditorDialogRefMethods<TRowData, TDataContext>;
|
|
18
|
+
};
|
|
19
|
+
export declare const TableColumnsEditorDialog: TableColumnsEditorDialogComponent;
|
|
20
|
+
export {};
|
|
@@ -3,6 +3,7 @@ export * from './TableActionsCell';
|
|
|
3
3
|
export * from './TableCaption';
|
|
4
4
|
export * from './TableCell';
|
|
5
5
|
export * from './TableCellAsyncContent';
|
|
6
|
+
export * from './TableColumnsEditorDialog';
|
|
6
7
|
export * from './TableFilter';
|
|
7
8
|
export * from './TableFiltersSidebarItem';
|
|
8
9
|
export * from './TableHeader';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as Table,
|
|
1
|
+
export { c as Table, u as TableActionsCell, s as TableCaption, f as TableCell, h as TableCellAsyncContent, l as TableColumnsEditorDialog, m as TableFilter, i as TableFiltersSidebarItem, a as TableFiltersSidebarItemContent, o as TableFiltersSidebarItemIcon, n as TableHeader, d as TableHeaderCell, p as TableHeaderFilter, r as TableMenu, t as TableSidebarMenu } from "../../../_chunks/Table.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "../../../_chunks/yup.js";
|
|
2
|
+
import { LogService as t } from "../../../classes/services/LogService/index.js";
|
|
3
|
+
import { NavigationHistoryService as n } from "../../../classes/services/NavigationHistoryService/index.js";
|
|
4
4
|
import { NotificationService as r } from "../../../classes/services/NotificationService/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { UserSettingsService as i } from "../../../classes/services/UserSettingsService/index.js";
|
|
6
|
+
import { AuthorizationService as a } from "../../../classes/services/AuthorizationService/index.js";
|
|
7
|
+
import { useConfig as o } from "../../../hooks/useConfig/index.js";
|
|
8
8
|
import { container as s } from "tsyringe";
|
|
9
9
|
import { Box as c, Typography as l } from "@mui/material";
|
|
10
10
|
import { useCallback as u, useEffect as d, useMemo as f } from "react";
|
|
@@ -19,20 +19,20 @@ import { withDialog as S } from "@gen-epix/ui-core-components/hoc/withDialog";
|
|
|
19
19
|
import { GenericForm as C } from "@gen-epix/ui-core-form/components/helpers/GenericForm";
|
|
20
20
|
// src/components/ui/UserFeedbackDialog/UserFeedbackDialog.tsx
|
|
21
21
|
var w = S(({ onActionsChange: S, onClose: w, onTitleChange: T }) => {
|
|
22
|
-
let { t: E } = h(), D =
|
|
22
|
+
let { t: E } = h(), D = o(), O = f(() => g().shape({
|
|
23
23
|
email: _().email().required().max(200),
|
|
24
24
|
message: _().freeFormText().required().max(5e3),
|
|
25
25
|
name: b.name
|
|
26
26
|
}), []), k = x({
|
|
27
|
-
resolver:
|
|
27
|
+
resolver: e(O),
|
|
28
28
|
values: {
|
|
29
|
-
email: s.resolve(
|
|
29
|
+
email: s.resolve(a).user?.email ?? s.resolve(a).user?.key ?? "",
|
|
30
30
|
message: "",
|
|
31
|
-
name: s.resolve(
|
|
31
|
+
name: s.resolve(a).user?.name ?? ""
|
|
32
32
|
}
|
|
33
33
|
}), { handleSubmit: A } = k;
|
|
34
34
|
d(() => {
|
|
35
|
-
s.resolve(
|
|
35
|
+
s.resolve(i).showShowUserFeedbackTooltip = !1;
|
|
36
36
|
}, []);
|
|
37
37
|
let j = f(() => [
|
|
38
38
|
{
|
|
@@ -57,15 +57,15 @@ var w = S(({ onActionsChange: S, onClose: w, onTitleChange: T }) => {
|
|
|
57
57
|
T(E`Feedback`);
|
|
58
58
|
}, [T, E]);
|
|
59
59
|
let M = u((e) => {
|
|
60
|
-
let
|
|
61
|
-
s.resolve(
|
|
60
|
+
let i = s.resolve(n).navigationHistory;
|
|
61
|
+
s.resolve(t).log([{
|
|
62
62
|
detail: {
|
|
63
63
|
...e,
|
|
64
|
-
navigationHistory:
|
|
64
|
+
navigationHistory: i.slice(i.length - 50).reverse()
|
|
65
65
|
},
|
|
66
66
|
level: "INFO",
|
|
67
67
|
topic: "USER_FEEDBACK"
|
|
68
|
-
}]), s.resolve(
|
|
68
|
+
}]), s.resolve(t).flushLog(), s.resolve(r).showNotification({
|
|
69
69
|
message: E`Thank you for sharing your feedback with us`,
|
|
70
70
|
severity: "success"
|
|
71
71
|
}), w();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
|
+
import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
|
|
3
|
+
import { t as n } from "../../_chunks/useQueryMemo.js";
|
|
4
|
+
import { AuthorizationService as r } from "../../classes/services/AuthorizationService/index.js";
|
|
5
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
|
// src/dataHooks/useIdentifierIssuerOwnOrganizationQuery/useIdentifierIssuerOwnOrganizationQuery.ts
|
|
10
|
-
var c = () =>
|
|
11
|
-
queryFn: async ({ signal:
|
|
12
|
-
let
|
|
10
|
+
var c = () => n({
|
|
11
|
+
queryFn: async ({ signal: t }) => {
|
|
12
|
+
let n = (await o.resolve(e).organizationIdentifierIssuerLinksPostQuery({
|
|
13
13
|
key: "organization_id",
|
|
14
14
|
type: "EQUALS_UUID",
|
|
15
|
-
value: o.resolve(
|
|
16
|
-
}, null, null, { signal:
|
|
17
|
-
return
|
|
15
|
+
value: o.resolve(r).user.organization_id
|
|
16
|
+
}, null, null, { signal: t })).data;
|
|
17
|
+
return n.length === 0 ? [] : (await o.resolve(e).identifierIssuersGetSome(n.map((e) => e.identifier_issuer_id).join(","), { signal: t })).data;
|
|
18
18
|
},
|
|
19
19
|
queryKey: o.resolve(i).getGenericKey(a.IDENTIFIER_ISSUERS_OWN_ORGANIZATION)
|
|
20
20
|
}), l = () => {
|
|
21
|
-
let
|
|
22
|
-
return s(() =>
|
|
21
|
+
let e = c();
|
|
22
|
+
return s(() => t.createUseOptionsDataHook(e, (e) => e.id, (e) => e.name), [e]);
|
|
23
23
|
};
|
|
24
24
|
export { l as useIdentifierIssuerOwnOrganizationOptionsQuery, c as useIdentifierIssuerOwnOrganizationQuery };
|
|
25
25
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
|
+
import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
|
|
3
3
|
import { t as n } from "../../_chunks/useQueryMemo.js";
|
|
4
4
|
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
5
|
import { COMMON_QUERY_KEY as i } from "../../constants/query.constants.js";
|
|
6
6
|
import { container as a } from "tsyringe";
|
|
7
7
|
import { useMemo as o } from "react";
|
|
8
8
|
// src/dataHooks/useIdentifierIssuerQuery/useIdentifierIssuerQuery.ts
|
|
9
|
-
var s = (
|
|
10
|
-
queryFn: async ({ signal:
|
|
9
|
+
var s = (t) => n({
|
|
10
|
+
queryFn: async ({ signal: t }) => (await a.resolve(e).identifierIssuersGetAll(null, null, { signal: t })).data,
|
|
11
11
|
queryKey: a.resolve(r).getGenericKey(i.IDENTIFIER_ISSUERS),
|
|
12
|
-
select:
|
|
13
|
-
}), c = (
|
|
14
|
-
let n = s(
|
|
15
|
-
return o(() =>
|
|
16
|
-
}, l = (
|
|
17
|
-
let n = s(
|
|
18
|
-
return o(() =>
|
|
12
|
+
select: t ? (e) => t(e) : void 0
|
|
13
|
+
}), c = (e) => {
|
|
14
|
+
let n = s(e);
|
|
15
|
+
return o(() => t.createUseMapDataHook(n, (e) => e.id), [n]);
|
|
16
|
+
}, l = (e) => {
|
|
17
|
+
let n = s(e);
|
|
18
|
+
return o(() => t.createUseOptionsDataHook(n, (e) => e.id, (e) => e.name), [n]);
|
|
19
19
|
};
|
|
20
20
|
export { c as useIdentifierIssuerMapQuery, l as useIdentifierIssuerOptionsQuery, s as useIdentifierIssuersQuery };
|
|
21
21
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t } from "../../_chunks/useQueryMemo.js";
|
|
3
|
+
import { AuthorizationService as n } from "../../classes/services/AuthorizationService/index.js";
|
|
4
4
|
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
5
|
import { COMMON_QUERY_KEY as i } from "../../constants/query.constants.js";
|
|
6
6
|
import { container as a } from "tsyringe";
|
|
7
7
|
import { CommonDbCommandName as o, CommonDbPermissionType as s } from "@gen-epix/api-commondb";
|
|
8
8
|
// src/dataHooks/useInviteUserConstraintsQuery/useInviteUserConstraintsQuery.ts
|
|
9
|
-
var c = () =>
|
|
10
|
-
queryFn: async ({ signal:
|
|
9
|
+
var c = () => t({
|
|
10
|
+
queryFn: async ({ signal: t }) => a.resolve(n).doesUserHavePermission([{
|
|
11
11
|
command_name: o.RetrieveInviteUserConstraintsCommand,
|
|
12
12
|
permission_type: s.EXECUTE
|
|
13
|
-
}]) ? (await a.resolve(e).inviteUserConstraints({ signal:
|
|
13
|
+
}]) ? (await a.resolve(e).inviteUserConstraints({ signal: t })).data : {
|
|
14
14
|
organization_ids: [],
|
|
15
15
|
roles: []
|
|
16
16
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useInviteUserConstraintsQuery","useQueryMemo","container","AuthorizationService","CommonDbCommandName","CommonDbPermissionType","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY"],"sources":["../../../src/dataHooks/useInviteUserConstraintsQuery/useInviteUserConstraintsQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { CommonDbUserInvitationConstraints } from '@gen-epix/api-commondb';\nimport {\n CommonDbCommandName,\n CommonDbPermissionType,\n} from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\n\nexport const useInviteUserConstraintsQuery = (): UseQueryResult<CommonDbUserInvitationConstraints> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n if (!container.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.RetrieveInviteUserConstraintsCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n return {\n organization_ids: [],\n roles: [],\n };\n }\n\n const response = await container.resolve(API_ORGANIZATION_TOKEN).inviteUserConstraints({ signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.INVITE_USER_CONSTRAINTS),\n });\n};\n"],"mappings":";;;;;;;;AAeA,IAAaC,UACJC,EAAa;CAClB,SAAS,OAAO,EAAE,gBACXC,EAAU,QAAQC,CAAoB,CAAC,CAAC,uBAAuB,CAClE;EAAE,cAAcC,EAAoB;EAAsC,iBAAiBC,EAAuB;CAAQ,CAC5H,CAAC,KAQM,MADgBH,EAAU,QAAQI,CAAsB,CAAC,CAAC,sBAAsB,EAAE,UAAO,CAAC,EAAA,CACjF,OAPP;EACL,kBAAkB,CAAC;EACnB,OAAO,CAAC;CACV;CAMJ,UAAUJ,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcQ,EAAiB,uBAAuB;AACxG,CAAC"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API_ABAC_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
2
|
import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as i } from "../../_chunks/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { useOrganizationMapQuery as n } from "../useOrganizationsQuery/index.js";
|
|
4
|
+
import { useUsersMapQuery as r } from "../useUsersQuery/index.js";
|
|
5
|
+
import { t as i } from "../../_chunks/useQueryMemo.js";
|
|
6
|
+
import { t as a } from "../../_chunks/QueryClientService.js";
|
|
7
|
+
import { COMMON_QUERY_KEY as o } from "../../constants/query.constants.js";
|
|
8
|
+
import { UserUtil as s } from "../../utils/UserUtil/index.js";
|
|
9
9
|
import { container as c } from "tsyringe";
|
|
10
10
|
import { useMemo as l } from "react";
|
|
11
11
|
import { useTranslation as u } from "react-i18next";
|
|
12
12
|
// src/dataHooks/useOrganizationAdminPoliciesQuery/useOrganizationAdminPoliciesQuery.ts
|
|
13
|
-
var d = () =>
|
|
14
|
-
queryFn: async ({ signal:
|
|
15
|
-
queryKey: c.resolve(
|
|
13
|
+
var d = () => i({
|
|
14
|
+
queryFn: async ({ signal: t }) => (await c.resolve(e).organizationAdminPoliciesGetAll(null, null, { signal: t })).data,
|
|
15
|
+
queryKey: c.resolve(a).getGenericKey(o.ORGANIZATION_ADMIN_POLICIES)
|
|
16
16
|
}), f = () => {
|
|
17
17
|
let e = d();
|
|
18
18
|
return l(() => t.createUseMapDataHook(e, (e) => e.id), [e]);
|
|
19
19
|
}, p = () => {
|
|
20
|
-
let { t:
|
|
21
|
-
return l(() => t.createUseNameFactoryHook((t) => `${
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
let { t: e } = u(), i = n(), a = r();
|
|
21
|
+
return l(() => t.createUseNameFactoryHook((t) => `${i.map.get(t.organization_id)?.name ?? t.organization_id} -> ${s.getUserDisplayValue(a.map.get(t.user_id), e)}`, [i, a]), [
|
|
22
|
+
i,
|
|
23
|
+
e,
|
|
24
|
+
a
|
|
25
25
|
]);
|
|
26
26
|
}, m = () => {
|
|
27
27
|
let e = d(), n = p();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
|
+
import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
|
|
3
3
|
import { t as n } from "../../_chunks/useQueryMemo.js";
|
|
4
4
|
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
5
|
import { COMMON_QUERY_KEY as i } from "../../constants/query.constants.js";
|
|
@@ -8,14 +8,14 @@ import { StringUtil as o } from "@gen-epix/ui-core/utils/StringUtil";
|
|
|
8
8
|
import { useMemo as s } from "react";
|
|
9
9
|
// src/dataHooks/useOrganizationsQuery/useOrganizationsQuery.ts
|
|
10
10
|
var c = () => n({
|
|
11
|
-
queryFn: async ({ signal:
|
|
11
|
+
queryFn: async ({ signal: t }) => (await a.resolve(e).organizationsGetAll(null, null, { signal: t })).data,
|
|
12
12
|
queryKey: a.resolve(r).getGenericKey(i.ORGANIZATIONS)
|
|
13
13
|
}), l = () => {
|
|
14
|
-
let
|
|
15
|
-
return s(() =>
|
|
14
|
+
let e = c();
|
|
15
|
+
return s(() => t.createUseMapDataHook(e, (e) => e.id), [e]);
|
|
16
16
|
}, u = () => {
|
|
17
|
-
let
|
|
18
|
-
return s(() =>
|
|
17
|
+
let e = c();
|
|
18
|
+
return s(() => t.createUseOptionsDataHook(e, (e) => e.id, (e) => e.name, [], (e, t) => o.advancedSortComperator(e.name, t.name)), [e]);
|
|
19
19
|
};
|
|
20
20
|
export { l as useOrganizationMapQuery, u as useOrganizationOptionsQuery, c as useOrganizationsQuery };
|
|
21
21
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API_ORGANIZATION_TOKEN as e } from "../../constants/api.constants.js";
|
|
2
2
|
import { DataHookUtil as t } from "../../utils/DataHookUtil/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { t as r } from "../../_chunks/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { t as n } from "../../_chunks/useQueryMemo.js";
|
|
4
|
+
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
|
+
import { COMMON_QUERY_KEY as i } from "../../constants/query.constants.js";
|
|
6
|
+
import { UserUtil as a } from "../../utils/UserUtil/index.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
10
|
// src/dataHooks/useUsersQuery/useUsersQuery.ts
|
|
11
|
-
var l = () =>
|
|
12
|
-
queryFn: async ({ signal:
|
|
13
|
-
queryKey: o.resolve(
|
|
11
|
+
var l = () => n({
|
|
12
|
+
queryFn: async ({ signal: t }) => (await o.resolve(e).usersGetAll(null, null, { signal: t })).data,
|
|
13
|
+
queryKey: o.resolve(r).getGenericKey(i.USERS)
|
|
14
14
|
}), u = () => {
|
|
15
15
|
let e = l();
|
|
16
16
|
return s(() => t.createUseMapDataHook(e, (e) => e.id), [e]);
|
|
17
17
|
}, d = () => {
|
|
18
|
-
let
|
|
19
|
-
return s(() => t.createUseOptionsDataHook(
|
|
18
|
+
let e = l(), { t: n } = c();
|
|
19
|
+
return s(() => t.createUseOptionsDataHook(e, (e) => e.id, (e) => a.getUserDisplayValue(e, n)), [n, e]);
|
|
20
20
|
};
|
|
21
21
|
export { d as useUserOptionsQuery, u as useUsersMapQuery, l as useUsersQuery };
|
|
22
22
|
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "../../_chunks/useMutation.js";
|
|
2
|
+
import { NotificationService as t } from "../../classes/services/NotificationService/index.js";
|
|
3
|
+
import { NotificationUtil as n } from "../../utils/NotificationUtil/index.js";
|
|
4
|
+
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
5
|
import { container as i } from "tsyringe";
|
|
6
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
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 = i.resolve(
|
|
11
|
+
let g = i.resolve(r).queryClient, _ = e({
|
|
12
12
|
mutationFn: async (e) => m(s.deepNullifyEmptyStrings(e)),
|
|
13
|
-
onError: async (
|
|
14
|
-
h && g.setQueryData(h, (e) => Array.isArray(e) ? [...e.filter((e) => e?.id !== o.temporaryId)] : e), await i.resolve(
|
|
13
|
+
onError: async (e, a, o) => {
|
|
14
|
+
h && g.setQueryData(h, (e) => Array.isArray(e) ? [...e.filter((e) => e?.id !== o.temporaryId)] : e), await i.resolve(r).invalidateQueryKeys(c), f && await f(e, a, o), i.resolve(t).fulfillNotification(o.notificationKey, n.wrapErrorNotificationMessage(l(a, e), e), "error");
|
|
15
15
|
},
|
|
16
16
|
onMutate: async (e) => {
|
|
17
|
-
let
|
|
17
|
+
let n = i.resolve(t).showNotification({
|
|
18
18
|
isLoading: !0,
|
|
19
19
|
message: u(e),
|
|
20
20
|
severity: "info"
|
|
21
21
|
});
|
|
22
22
|
if (h) {
|
|
23
23
|
await g.cancelQueries({ queryKey: h });
|
|
24
|
-
let
|
|
25
|
-
if (Array.isArray(
|
|
24
|
+
let t = g.getQueryData(h);
|
|
25
|
+
if (Array.isArray(t)) {
|
|
26
26
|
let r = a.createUuid();
|
|
27
27
|
return g.setQueryData(h, (t) => [{
|
|
28
28
|
...e,
|
|
29
29
|
id: r
|
|
30
30
|
}, ...t]), {
|
|
31
|
-
notificationKey:
|
|
32
|
-
previousData:
|
|
31
|
+
notificationKey: n,
|
|
32
|
+
previousData: t,
|
|
33
33
|
temporaryId: r
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return { notificationKey:
|
|
37
|
+
return { notificationKey: n };
|
|
38
38
|
},
|
|
39
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(
|
|
40
|
+
h && Array.isArray(a?.previousData) && !Array.isArray(e) && g.setQueryData(h, (t) => [e, ...t.filter((e) => e.id !== a.temporaryId)]), await i.resolve(r).invalidateQueryKeys(c), p && await p(e, n, a), i.resolve(t).fulfillNotification(a.notificationKey, d(e, a), "success");
|
|
41
41
|
}
|
|
42
42
|
}), v = o(() => _.mutate, [_.mutate]), y = o(() => _.isPending, [_.isPending]);
|
|
43
43
|
return o(() => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useMutation","useCreateMutation","queryClient","container","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useMutation","QueryClientService","useCreateMutation","queryClient","container","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,IAAaE,KAAoF,EAC/F,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BAC+C;CAC/C,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,IAAiBL,EAAoE;EACzF,YAAY,OAAO,MACVM,EAAQC,EAAW,wBAAwBC,CAAI,CAAC;EAEzD,SAAS,OAAO,GAAO,GAAW,MAAY;GAa5C,AAZIC,KACFN,EAAY,aAAsBM,IAAmB,MAC9C,MAAM,QAAQC,CAAQ,IAGpB,CAAC,GAAGA,EAAS,QAAO,MAASF,GAAsB,OAAOG,EAAQ,WAAW,CAAC,IAF5ED,CAGV,GAEH,MAAMN,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBW,CAAoB,GAChFC,KACF,MAAMA,EAAQC,GAAOC,GAAWJ,CAAO,GAEzCP,EAAU,QAAQY,CAAmB,CAAC,CAAC,oBAAoBL,EAAQ,iBAAiBM,EAAiB,6BAA6BC,EAA4BH,GAAWD,CAAK,GAAGA,CAAK,GAAG,OAAO;EAClM;EACA,UAAU,OAAO,MAAc;GAC7B,IAAMK,IAAkBf,EAAU,QAAQY,CAAmB,CAAC,CAAC,iBAAiB;IAC9E,WAAW;IACX,SAASI,EAA+BL,CAAS;IACjD,UAAU;GACZ,CAAC;GACD,IAAIN,GAAkB;IACpB,MAAMN,EAAY,cAAc,EAAE,UAAUM,EAAiB,CAAC;IAC9D,IAAMY,IAAelB,EAAY,aAAsBM,CAAgB;IACvE,IAAI,MAAM,QAAQY,CAAY,GAAG;KAC/B,IAAMC,IAAcC,EAAW,WAAW;KAU1C,OATApB,EAAY,aAAsBM,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,KACjFL,EAAY,aAA4BM,IAAmB,MAClD,CACLD,GACA,GAAGE,EAAS,QAAO,MAAKc,EAAE,OAAOb,EAAQ,WAAW,CACtD,CACD,GAEH,MAAMP,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBW,CAAoB,GAChFa,KACF,MAAMA,EAAUjB,GAAMO,GAAWJ,CAAO,GAE1CP,EAAU,QAAQY,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,41 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "../../_chunks/useMutation.js";
|
|
2
|
+
import { NotificationService as t } from "../../classes/services/NotificationService/index.js";
|
|
3
|
+
import { NotificationUtil as n } from "../../utils/NotificationUtil/index.js";
|
|
4
|
+
import { t as r } from "../../_chunks/QueryClientService.js";
|
|
5
5
|
import { container as i } from "tsyringe";
|
|
6
6
|
import { useMemo as a } from "react";
|
|
7
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(
|
|
9
|
+
let m = i.resolve(r).queryClient, h = e({
|
|
10
10
|
mutationFn: async (e) => {
|
|
11
11
|
if (!f) throw Error("Delete mutation queryFn is required");
|
|
12
12
|
return f(e);
|
|
13
13
|
},
|
|
14
|
-
onError: async (
|
|
15
|
-
p && Array.isArray(c.previousData) && m.setQueryData(p, c.previousData), o && await i.resolve(
|
|
16
|
-
let l = s?.(a,
|
|
17
|
-
i.resolve(
|
|
14
|
+
onError: async (e, a, c) => {
|
|
15
|
+
p && Array.isArray(c.previousData) && m.setQueryData(p, c.previousData), o && await i.resolve(r).invalidateQueryKeys(o), u && await u(e, a, c);
|
|
16
|
+
let l = s?.(a, e) ?? String(e);
|
|
17
|
+
i.resolve(t).fulfillNotification(c.notificationKey, n.wrapErrorNotificationMessage(l, e), "error");
|
|
18
18
|
},
|
|
19
19
|
onMutate: async (e) => {
|
|
20
|
-
let
|
|
20
|
+
let n = i.resolve(t).showNotification({
|
|
21
21
|
isLoading: !0,
|
|
22
22
|
message: c(e),
|
|
23
23
|
severity: "info"
|
|
24
24
|
});
|
|
25
25
|
if (p) {
|
|
26
26
|
await m.cancelQueries({ queryKey: p });
|
|
27
|
-
let
|
|
28
|
-
if (Array.isArray(
|
|
29
|
-
notificationKey:
|
|
30
|
-
previousData:
|
|
27
|
+
let t = m.getQueryData(p);
|
|
28
|
+
if (Array.isArray(t) && !Array.isArray(e)) return m.setQueryData(p, (t) => t.filter((t) => t.id !== e.id)), {
|
|
29
|
+
notificationKey: n,
|
|
30
|
+
previousData: t
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return { notificationKey:
|
|
33
|
+
return { notificationKey: n };
|
|
34
34
|
},
|
|
35
35
|
onSuccess: async (e, n, a) => {
|
|
36
|
-
o && await i.resolve(
|
|
36
|
+
o && await i.resolve(r).invalidateQueryKeys(o), d && await d(n, a);
|
|
37
37
|
let s = l?.(n, a) ?? "Deleted successfully";
|
|
38
|
-
i.resolve(
|
|
38
|
+
i.resolve(t).fulfillNotification(a.notificationKey, s, "success");
|
|
39
39
|
}
|
|
40
40
|
}), g = a(() => h.mutate, [h.mutate]), _ = a(() => h.isPending, [h.isPending]);
|
|
41
41
|
return a(() => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useMutation","useDeleteMutation","queryClient","container","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useMutation","QueryClientService","useDeleteMutation","queryClient","container","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,IAAaE,KAAgE,EAC3E,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BACmC;CACnC,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,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,KACxDN,EAAY,aAAsBK,GAAkBC,EAAQ,YAAY,GAEtEC,KACF,MAAMN,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBS,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,IAAkBb,EAAU,QAAQW,CAAmB,CAAC,CAAC,iBAAiB;IAC9E,WAAW;IACX,SAASG,EAA+BX,CAAI;IAC5C,UAAU;GACZ,CAAC;GACD,IAAIC,GAAkB;IACpB,MAAML,EAAY,cAAc,EAAE,UAAUK,EAAiB,CAAC;IAC9D,IAAMW,IAAehB,EAAY,aAAsBK,CAAgB;IAEvE,IAAI,MAAM,QAAQW,CAAY,KAAK,CAAC,MAAM,QAAQZ,CAAI,GAIpD,OAHAJ,EAAY,aAA4BK,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,MAAMN,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBS,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"}
|