@antscorp/antsomi-ui 1.3.5-beta.69 → 1.3.5-beta.70

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.
@@ -14,6 +14,7 @@ var __rest = (this && this.__rest) || function (s, e) {
14
14
  // Libraries
15
15
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
16
16
  import { omit, isEmpty, flatMapDeep, set, get, isNaN } from 'lodash';
17
+ import { useQueryClient } from '@tanstack/react-query';
17
18
  // Hooks
18
19
  import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
19
20
  // Components
@@ -27,7 +28,6 @@ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
27
28
  import { useGetDynamicContentAttr, useGetListPromotionPool, useGetListEventAttr, useGetListPromotionCodeAttr, useGetListBO, useGetListAllEvents, useGetListSourceByEvent, useGetListAttributeBO, useGetCustomFunction, useAddSavedCSFunction, useUpdateCSFunction, } from '@antscorp/antsomi-ui/es/queries';
28
29
  import { useGetEventTrackingAttributes } from '@antscorp/antsomi-ui/es/queries/ThirdParty';
29
30
  // Queries config
30
- import { queryClientAntsomiUI } from '@antscorp/antsomi-ui/es/queries/configs';
31
31
  import { QUERY_KEYS } from '@antscorp/antsomi-ui/es/constants/queries';
32
32
  import { dateExample } from './components/FormatDatetime';
33
33
  import DisplayFormat from './components/DisplayFormat';
@@ -126,6 +126,7 @@ export const AddDynamicContent = props => {
126
126
  const [attrDFOptions, setAttrDFOptions] = useState([]);
127
127
  // Template Custom
128
128
  const [templateId, settemplateId] = useState();
129
+ const queryClient = useQueryClient();
129
130
  const { data: listBoAttributes = [], isFetching: isFetchingListBoAttr, isError: isErrorBoAttr, } = useGetListAttributeBO({
130
131
  url,
131
132
  itemTypeIds: itemTypeId ? [itemTypeId] : [],
@@ -911,7 +912,7 @@ export const AddDynamicContent = props => {
911
912
  break;
912
913
  setItemTypeId(Number(selectedItemTypeId));
913
914
  const key = [QUERY_KEYS.GET_EVENT_ATTRIBUTE_BO, [selectedItemTypeId]];
914
- const listAttBOByItemTypeId = serilizeBOAttr(queryClientAntsomiUI.getQueryData(key));
915
+ const listAttBOByItemTypeId = serilizeBOAttr(queryClient.getQueryData(key));
915
916
  if (listAttBOByItemTypeId.length) {
916
917
  form.setFieldsValue({
917
918
  [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: listAttBOByItemTypeId[0],
@@ -8,46 +8,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  // Libraries
11
- import { useMutation, useQuery } from '@tanstack/react-query';
11
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
12
12
  // Services
13
13
  import { getListingTemplateCustomFunction, createSavedCustomFunction, updateSavedCustomFunction, } from '../../services/MediaTemplateDesign/CustomFunction';
14
14
  // Constants
15
15
  import { QUERY_KEYS } from '../../constants/queries';
16
- // Query client
17
- import { queryClientAntsomiUI } from '../configs';
18
16
  export const useGetCustomFunction = (apiConfig, infos, queryOptions) => useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_LIST_CUSTOM], queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
19
17
  const data = yield getListingTemplateCustomFunction({ url: apiConfig.url }, infos);
20
18
  return data;
21
19
  }) }, queryOptions));
22
- export const useAddSavedCSFunction = () => useMutation(createSavedCustomFunction, {
23
- onMutate: (_payload) => {
24
- const previousSavedBlock = queryClientAntsomiUI.getQueryData([
25
- QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION,
26
- ]);
27
- return { previousSavedBlock };
28
- },
29
- onError: (_error, _payload, context) => {
30
- queryClientAntsomiUI.setQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], context === null || context === void 0 ? void 0 : context.previousSavedBlock);
31
- },
32
- onSettled: () => {
33
- queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], {
34
- exact: true,
35
- });
36
- },
37
- });
38
- export const useUpdateCSFunction = () => useMutation(updateSavedCustomFunction, {
39
- onMutate: (_payload) => {
40
- const previousSavedBlock = queryClientAntsomiUI.getQueryData([
41
- QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION,
42
- ]);
43
- return { previousSavedBlock };
44
- },
45
- onError: (_error, _payload, context) => {
46
- queryClientAntsomiUI.setQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], context === null || context === void 0 ? void 0 : context.previousSavedBlock);
47
- },
48
- onSettled: () => {
49
- queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], {
50
- exact: true,
51
- });
52
- },
53
- });
20
+ export const useAddSavedCSFunction = () => {
21
+ const queryClient = useQueryClient();
22
+ return useMutation(createSavedCustomFunction, {
23
+ onMutate: (_payload) => {
24
+ const previousSavedBlock = queryClient.getQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION]);
25
+ return { previousSavedBlock };
26
+ },
27
+ onError: (_error, _payload, context) => {
28
+ queryClient.setQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], context === null || context === void 0 ? void 0 : context.previousSavedBlock);
29
+ },
30
+ onSettled: () => {
31
+ queryClient.invalidateQueries([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], {
32
+ exact: true,
33
+ });
34
+ },
35
+ });
36
+ };
37
+ export const useUpdateCSFunction = () => {
38
+ const queryClient = useQueryClient();
39
+ return useMutation(updateSavedCustomFunction, {
40
+ onMutate: (_payload) => {
41
+ const previousSavedBlock = queryClient.getQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION]);
42
+ return { previousSavedBlock };
43
+ },
44
+ onError: (_error, _payload, context) => {
45
+ queryClient.setQueryData([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], context === null || context === void 0 ? void 0 : context.previousSavedBlock);
46
+ },
47
+ onSettled: () => {
48
+ queryClient.invalidateQueries([QUERY_KEYS.GET_SAVE_CUSTOM_FUNCTION], {
49
+ exact: true,
50
+ });
51
+ },
52
+ });
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.69",
3
+ "version": "1.3.5-beta.70",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",