@antscorp/antsomi-ui 1.3.5-beta.33 → 1.3.5-beta.34

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.
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { useState } from 'react';
12
+ import React, { useEffect, useState } from 'react';
13
13
  import { ModalV2 } from '../ModalV2';
14
14
  import { TemplateSaveAs } from './TemplateSaveAs';
15
15
  // NOTE: helper link (read more about controlled and uncontrolled component)
@@ -18,6 +18,10 @@ export const TemplateSaveAsModal = props => {
18
18
  const { open, onCancel, okText, onOk, title, templateProps, defaultValue } = props, restProps = __rest(props, ["open", "onCancel", "okText", "onOk", "title", "templateProps", "defaultValue"]);
19
19
  const { onChange: templateOnChange, value: templateValue } = templateProps, restTemplateProps = __rest(templateProps, ["onChange", "value"]);
20
20
  const [internalValue, setInternalValue] = useState(defaultValue || templateValue);
21
+ useEffect(() => {
22
+ if (defaultValue)
23
+ setInternalValue(defaultValue);
24
+ }, [defaultValue]);
21
25
  const handleOnChange = (value) => {
22
26
  if (templateOnChange) {
23
27
  templateOnChange(value);
@@ -33,6 +37,12 @@ export const TemplateSaveAsModal = props => {
33
37
  onOk(event, templateValue && templateOnChange ? templateValue : internalValue);
34
38
  }
35
39
  };
36
- return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: onCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template' }, restProps),
40
+ const handleCancel = (event) => {
41
+ if (onCancel) {
42
+ setInternalValue(defaultValue);
43
+ onCancel(event);
44
+ }
45
+ };
46
+ return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: handleCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template' }, restProps),
37
47
  React.createElement(TemplateSaveAs, Object.assign({ onChange: handleOnChange, value: templateValue || internalValue }, restTemplateProps))));
38
48
  };
@@ -1,6 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
2
  import { TTemplateStatus } from '../types/templateListing';
3
3
  import { Model } from './model';
4
+ import { TShareAccess } from '../types';
4
5
  export type TObjectTemplate = {
5
6
  template_id: number;
6
7
  template_name: string;
@@ -26,6 +27,7 @@ export type TObjectTemplate = {
26
27
  goal: number[];
27
28
  journey_type: number[];
28
29
  lifecycle_stage: number[];
30
+ share_access: TShareAccess;
29
31
  };
30
32
  export declare class ObjectTemplate extends Model<TObjectTemplate> {
31
33
  get id(): number | "";
@@ -50,4 +52,5 @@ export declare class ObjectTemplate extends Model<TObjectTemplate> {
50
52
  get lifecycleStage(): number[] | undefined;
51
53
  get journeyType(): number[] | undefined;
52
54
  get goal(): number[] | undefined;
55
+ get shareAccess(): TShareAccess | undefined;
53
56
  }
@@ -76,4 +76,7 @@ export class ObjectTemplate extends Model {
76
76
  get goal() {
77
77
  return this.model.goal;
78
78
  }
79
+ get shareAccess() {
80
+ return this.model.share_access;
81
+ }
79
82
  }
@@ -33,7 +33,7 @@ export const useGetObjectTemplateList = (params) => {
33
33
  };
34
34
  export const useGetObjectTemplateDetail = (params) => {
35
35
  const { args, options } = params;
36
- return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL, args.params], queryFn: () => objectTemplate.getDetail(args), enabled: !!args.params.template_id }, options));
36
+ return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL, args.params.template_id], queryFn: () => objectTemplate.getDetail(args), enabled: !!args.params.template_id }, options));
37
37
  };
38
38
  export const useValidateTemplateName = (params) => {
39
39
  const { options } = params;
@@ -83,7 +83,12 @@ export const usePersistTemplate = (params) => {
83
83
  default:
84
84
  return objectTemplate.create(Object.assign(Object.assign({}, params), { data: omit(params.data, ['template_id']) }));
85
85
  }
86
- }, onSettled() {
86
+ }, onSettled(data, error, variables, context) {
87
+ console.log('🚀 ~ onSettled ~ variables:', variables);
88
+ queryClientAntsomiUI.invalidateQueries([
89
+ QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL,
90
+ variables.params.data.template_id,
91
+ ]);
87
92
  queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
88
93
  exact: false,
89
94
  });
@@ -18,6 +18,7 @@ export * from './richMenu';
18
18
  export * from './variables';
19
19
  export * from './service';
20
20
  export * from './templateListing';
21
+ export * from './share-access';
21
22
  export type PayloadInfo = {
22
23
  url?: string;
23
24
  userId?: string;
package/es/types/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './richMenu';
2
2
  export * from './variables';
3
3
  export * from './service';
4
4
  export * from './templateListing';
5
+ export * from './share-access';
@@ -0,0 +1,17 @@
1
+ import { TBoolean } from './variables';
2
+ export type TUserAccess = {
3
+ allow_comment: TBoolean;
4
+ allow_edit: TBoolean;
5
+ allow_view: TBoolean;
6
+ avatar: string;
7
+ email: string;
8
+ full_name: string;
9
+ role: number;
10
+ user_id: number;
11
+ [key: string]: any;
12
+ };
13
+ export type TShareAccess = {
14
+ is_public: TBoolean;
15
+ public_role: number | null;
16
+ list_access: TUserAccess[];
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -2,3 +2,4 @@ import { GET_LIST_TYPE } from '../constants';
2
2
  export type TUnit = 'px' | '%' | any;
3
3
  export type TAlign = 'left' | 'center' | 'right';
4
4
  export type TGetListType = (typeof GET_LIST_TYPE)[keyof typeof GET_LIST_TYPE];
5
+ export type TBoolean = 1 | 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.33",
3
+ "version": "1.3.5-beta.34",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",