@antscorp/antsomi-ui 1.3.5-beta.2 → 1.3.5-beta.21
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/es/assets/css/main.scss +0 -2
- package/es/assets/images/background/skeleton-background.png +0 -0
- package/es/assets/images/skeleton_bg.png +0 -0
- package/es/assets/svg/mobile-frame.svg +3 -0
- package/es/components/atoms/Spin/Spin.js +2 -2
- package/es/components/common/ConfigProvider/ConfigProvider.js +8 -4
- package/es/components/common/ConfigProvider/GlobalStyle.js +85 -16
- package/es/components/molecules/CalendarSelection/CalendarSelection.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/CalendarSelection.js +45 -0
- package/es/components/molecules/CalendarSelection/actions.d.ts +55 -0
- package/es/components/molecules/CalendarSelection/actions.js +39 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.d.ts +7 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.js +24 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.js +10 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +96 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.d.ts +6 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +152 -0
- package/es/components/molecules/CalendarSelection/components/CustomPicker/types.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/Footer.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/Footer/Footer.js +11 -0
- package/es/components/molecules/CalendarSelection/components/Footer/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/Footer/styled.js +6 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.js +4 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +13 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.js +23 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.js +41 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.d.ts +11 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +40 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.js +29 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js +2 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.js +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.js +34 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.js +1 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +8 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +49 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.js +2 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +70 -0
- package/es/components/molecules/CalendarSelection/components/index.d.ts +5 -0
- package/es/components/molecules/CalendarSelection/components/index.js +5 -0
- package/es/components/molecules/CalendarSelection/constants.d.ts +97 -0
- package/es/components/molecules/CalendarSelection/constants.js +183 -0
- package/es/components/molecules/CalendarSelection/context.d.ts +4 -0
- package/es/components/molecules/CalendarSelection/context.js +6 -0
- package/es/components/molecules/CalendarSelection/hooks/index.d.ts +2 -0
- package/es/components/molecules/CalendarSelection/hooks/index.js +2 -0
- package/es/components/molecules/CalendarSelection/hooks/useStateContext.d.ts +4 -0
- package/es/components/molecules/CalendarSelection/hooks/useStateContext.js +13 -0
- package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.d.ts +9 -0
- package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.js +19 -0
- package/es/components/molecules/CalendarSelection/index.d.ts +25 -0
- package/es/components/molecules/CalendarSelection/index.js +6 -0
- package/es/components/molecules/CalendarSelection/reducer.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/reducer.js +121 -0
- package/es/components/molecules/CalendarSelection/styled.d.ts +6 -0
- package/es/components/molecules/CalendarSelection/styled.js +13 -0
- package/es/components/molecules/CalendarSelection/types.d.ts +97 -0
- package/es/components/molecules/CalendarSelection/types.js +1 -0
- package/es/components/molecules/CalendarSelection/utils.d.ts +52 -0
- package/es/components/molecules/CalendarSelection/utils.js +304 -0
- package/es/components/molecules/ColorPicker/CustomPicker/index.js +3 -3
- package/es/components/molecules/ColorPicker/index.d.ts +1 -0
- package/es/components/molecules/ColorPicker/index.js +3 -2
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +24 -16
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +5 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +31 -1
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +1 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +3 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +5 -4
- package/es/components/molecules/ModalV2/styled.js +4 -0
- package/es/components/molecules/ResizeGrid/ResizeGrid.js +10 -2
- package/es/components/molecules/ResizeGrid/types.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +2 -2
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +2 -2
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +2 -2
- package/es/components/molecules/ShareAccess/index.d.ts +2 -3
- package/es/components/molecules/ShareAccess/index.js +2 -3
- package/es/components/molecules/ShareAccess/types.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +52 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +144 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.d.ts +10 -0
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +38 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.d.ts +15 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +68 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.js +1 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.d.ts +5 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +175 -0
- package/es/components/molecules/TemplateSaveAs/components/index.d.ts +1 -0
- package/es/components/molecules/TemplateSaveAs/components/index.js +1 -0
- package/es/components/molecules/TemplateSaveAs/index.d.ts +3 -0
- package/es/components/molecules/TemplateSaveAs/index.js +2 -0
- package/es/components/molecules/TemplateSaveAs/styled.d.ts +4 -0
- package/es/components/molecules/TemplateSaveAs/styled.js +70 -0
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.d.ts +3 -0
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +72 -0
- package/es/components/molecules/ThumbnailCard/constants.d.ts +3 -0
- package/es/components/molecules/ThumbnailCard/constants.js +3 -0
- package/es/components/molecules/ThumbnailCard/index.d.ts +2 -0
- package/es/components/molecules/ThumbnailCard/index.js +2 -0
- package/es/components/molecules/ThumbnailCard/styled.d.ts +1 -0
- package/es/components/{template/TemplateListing/components/TemplateItem → molecules/ThumbnailCard}/styled.js +14 -7
- package/es/components/molecules/ThumbnailCard/types.d.ts +21 -0
- package/es/components/molecules/ThumbnailCard/types.js +1 -0
- package/es/components/molecules/UploadImage/index.js +1 -1
- package/es/components/molecules/index.d.ts +5 -0
- package/es/components/molecules/index.js +3 -0
- package/es/components/organism/Help/Help.js +23 -1
- package/es/components/organism/Menu/Menu.d.ts +2 -0
- package/es/components/organism/Menu/Menu.js +3 -0
- package/es/components/organism/Menu/index.d.ts +1 -0
- package/es/components/organism/Menu/index.js +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/index.js +12 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +91 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/index.js +29 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/styled.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/components/Information/styled.js +41 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +29 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.js +12 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.d.ts +6 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +77 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +62 -0
- package/es/components/organism/PreviewTemplateModal/components/index.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/components/index.js +4 -0
- package/es/components/organism/PreviewTemplateModal/constants/dataSample.d.ts +2 -0
- package/es/components/organism/PreviewTemplateModal/constants/dataSample.js +9 -0
- package/es/components/organism/PreviewTemplateModal/constants/defaultProps.d.ts +8 -0
- package/es/components/organism/PreviewTemplateModal/constants/defaultProps.js +11 -0
- package/es/components/organism/PreviewTemplateModal/constants/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/constants/index.js +3 -0
- package/es/components/organism/PreviewTemplateModal/constants/variables.d.ts +12 -0
- package/es/components/organism/PreviewTemplateModal/constants/variables.js +12 -0
- package/es/components/organism/PreviewTemplateModal/index.d.ts +3 -0
- package/es/components/organism/PreviewTemplateModal/index.js +34 -0
- package/es/components/organism/PreviewTemplateModal/styled.d.ts +4 -0
- package/es/components/organism/PreviewTemplateModal/styled.js +26 -0
- package/es/components/organism/PreviewTemplateModal/types.d.ts +39 -0
- package/es/components/organism/PreviewTemplateModal/types.js +1 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +6 -0
- package/es/components/template/TemplateListing/Loadable.js +7 -0
- package/es/components/template/TemplateListing/components/BlankTemplate/index.js +9 -7
- package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/index.js +19 -10
- package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +2 -0
- package/es/components/template/TemplateListing/components/CategoryListing/styled.js +44 -7
- package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +2 -1
- package/es/components/template/TemplateListing/components/Empty/index.d.ts +3 -0
- package/es/components/template/TemplateListing/components/Empty/index.js +18 -0
- package/es/components/template/TemplateListing/components/Empty/styled.d.ts +3 -0
- package/es/components/template/TemplateListing/components/Empty/styled.js +35 -0
- package/es/components/template/TemplateListing/components/index.d.ts +1 -1
- package/es/components/template/TemplateListing/components/index.js +1 -1
- package/es/components/template/TemplateListing/constants/defaultProps.d.ts +8 -4
- package/es/components/template/TemplateListing/constants/defaultProps.js +9 -6
- package/es/components/template/TemplateListing/hooks/index.d.ts +1 -0
- package/es/components/template/TemplateListing/hooks/index.js +1 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +62 -0
- package/es/components/template/TemplateListing/hooks/useTemplateListing.js +206 -0
- package/es/components/template/TemplateListing/index.js +77 -13
- package/es/components/template/TemplateListing/styled/index.d.ts +2 -0
- package/es/components/template/TemplateListing/styled/index.js +29 -5
- package/es/components/template/TemplateListing/types/BlankTemplate.d.ts +3 -2
- package/es/components/template/TemplateListing/types/CategoryListing.d.ts +5 -2
- package/es/components/template/TemplateListing/types/Empty.d.ts +5 -0
- package/es/components/template/TemplateListing/types/Empty.js +1 -0
- package/es/components/template/TemplateListing/types/TemplateListing.d.ts +20 -9
- package/es/components/template/TemplateListing/types/index.d.ts +0 -1
- package/es/components/template/TemplateListing/types/index.js +0 -1
- package/es/components/template/index.d.ts +2 -1
- package/es/components/template/index.js +5 -1
- package/es/constants/datetime.d.ts +8 -0
- package/es/constants/datetime.js +1594 -0
- package/es/constants/index.d.ts +4 -1
- package/es/constants/index.js +4 -1
- package/es/constants/queries.d.ts +3 -0
- package/es/constants/queries.js +4 -0
- package/es/constants/templateListing.d.ts +58 -0
- package/es/constants/templateListing.js +58 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useEffectOnlyOnce.d.ts +2 -0
- package/es/hooks/useEffectOnlyOnce.js +12 -0
- package/es/hooks/useForceUpdate.d.ts +1 -0
- package/es/hooks/useForceUpdate.js +5 -0
- package/es/hooks/useIntersectionObserver.d.ts +57 -0
- package/es/hooks/useIntersectionObserver.js +97 -0
- package/es/hooks/useListingItemResize.d.ts +12 -0
- package/es/hooks/useListingItemResize.js +58 -0
- package/es/hooks/useScrollToEnd.d.ts +1 -0
- package/es/hooks/useScrollToEnd.js +30 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/locales/en/translation.json +11 -3
- package/es/locales/i18n.d.ts +16 -0
- package/es/locales/translations.d.ts +8 -0
- package/es/locales/vi/translation.json +9 -1
- package/es/models/ObjectTemplate.d.ts +53 -0
- package/es/models/ObjectTemplate.js +80 -0
- package/es/models/TemplateCategory.d.ts +13 -0
- package/es/models/TemplateCategory.js +28 -0
- package/es/queries/TemplateListing/index.d.ts +47 -0
- package/es/queries/TemplateListing/index.js +93 -0
- package/es/queries/index.d.ts +1 -0
- package/es/queries/index.js +1 -0
- package/es/services/TemplateListing/index.d.ts +64 -0
- package/es/services/TemplateListing/index.js +149 -0
- package/es/test.js +62 -11
- package/es/types/index.d.ts +4 -0
- package/es/types/index.js +2 -0
- package/es/types/service.d.ts +22 -0
- package/es/types/service.js +1 -0
- package/es/types/templateListing.d.ts +11 -0
- package/es/types/templateListing.js +1 -0
- package/es/utils/common.d.ts +2 -0
- package/es/utils/common.js +12 -0
- package/package.json +6 -1
- package/es/components/template/TemplateListing/components/TemplateItem/index.d.ts +0 -3
- package/es/components/template/TemplateListing/components/TemplateItem/index.js +0 -53
- package/es/components/template/TemplateListing/components/TemplateItem/styled.d.ts +0 -1
- package/es/components/template/TemplateListing/types/TemplateItem.d.ts +0 -14
- /package/es/components/{template/TemplateListing/types/TemplateItem.js → molecules/CalendarSelection/components/CustomPicker/types.js} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
// Models
|
|
4
|
+
import { Model } from './model';
|
|
5
|
+
// Constants
|
|
6
|
+
import { LAYOUT_TEMPLATE } from '../constants/templateListing';
|
|
7
|
+
import { DATE_TIME_FORMAT } from '../constants';
|
|
8
|
+
export class ObjectTemplate extends Model {
|
|
9
|
+
get id() {
|
|
10
|
+
return this.model.template_id || '';
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
return this.model.template_name || '';
|
|
14
|
+
}
|
|
15
|
+
get type() {
|
|
16
|
+
return +(this.model.template_type || '');
|
|
17
|
+
}
|
|
18
|
+
get typeLabel() {
|
|
19
|
+
const templateType = Object.values(LAYOUT_TEMPLATE).find(({ id }) => id === this.type);
|
|
20
|
+
return templateType ? templateType.label : '';
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return this.model.description || '';
|
|
24
|
+
}
|
|
25
|
+
get templateSettings() {
|
|
26
|
+
return this.model.template_setting || {};
|
|
27
|
+
}
|
|
28
|
+
get settings() {
|
|
29
|
+
return this.model.properties || {};
|
|
30
|
+
}
|
|
31
|
+
get status() {
|
|
32
|
+
return this.model.status || '';
|
|
33
|
+
}
|
|
34
|
+
get userId() {
|
|
35
|
+
return this.model.c_user_id || '';
|
|
36
|
+
}
|
|
37
|
+
get createdAt() {
|
|
38
|
+
return dayjs(this.model.ctime).isValid()
|
|
39
|
+
? dayjs(this.model.ctime, DATE_TIME_FORMAT.DATE_TIME)
|
|
40
|
+
: '-';
|
|
41
|
+
}
|
|
42
|
+
get updatedAt() {
|
|
43
|
+
return dayjs(this.model.utime).isValid()
|
|
44
|
+
? dayjs(this.model.utime, DATE_TIME_FORMAT.DATE_TIME)
|
|
45
|
+
: '-';
|
|
46
|
+
}
|
|
47
|
+
get objectiveTypes() {
|
|
48
|
+
return this.model.goal || [];
|
|
49
|
+
}
|
|
50
|
+
get networkId() {
|
|
51
|
+
return this.model.network_id;
|
|
52
|
+
}
|
|
53
|
+
get thumbnail() {
|
|
54
|
+
return this.model.thumbnail || '';
|
|
55
|
+
}
|
|
56
|
+
get objectType() {
|
|
57
|
+
return this.model.object_type;
|
|
58
|
+
}
|
|
59
|
+
get config() {
|
|
60
|
+
return this.model.config;
|
|
61
|
+
}
|
|
62
|
+
get configObject() {
|
|
63
|
+
return this.model.config_object;
|
|
64
|
+
}
|
|
65
|
+
get seasonality() {
|
|
66
|
+
return this.model.seasonality;
|
|
67
|
+
}
|
|
68
|
+
get industry() {
|
|
69
|
+
return this.model.industry;
|
|
70
|
+
}
|
|
71
|
+
get lifecycleStage() {
|
|
72
|
+
return this.model.lifecycle_stage;
|
|
73
|
+
}
|
|
74
|
+
get journeyType() {
|
|
75
|
+
return this.model.journey_type;
|
|
76
|
+
}
|
|
77
|
+
get goal() {
|
|
78
|
+
return this.model.goal;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TObjectType } from '../types/templateListing';
|
|
2
|
+
export type TTemplateCategory = {};
|
|
3
|
+
export interface TemplateCategory {
|
|
4
|
+
categoryId: number;
|
|
5
|
+
categoryCode: string;
|
|
6
|
+
parentCategoryCode: string;
|
|
7
|
+
categoryName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
objectTypes: TObjectType[];
|
|
10
|
+
filterOperator?: string;
|
|
11
|
+
children: TemplateCategory[];
|
|
12
|
+
total?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// export class TemplateCategory extends Model<TTemplateCategory> {
|
|
3
|
+
// get id() {
|
|
4
|
+
// return this.model.media_id || '';
|
|
5
|
+
// }
|
|
6
|
+
// get name() {
|
|
7
|
+
// return this.model.name || '';
|
|
8
|
+
// }
|
|
9
|
+
// get url() {
|
|
10
|
+
// return this.model.properties?.url || '';
|
|
11
|
+
// }
|
|
12
|
+
// get thumbnail() {
|
|
13
|
+
// return this.model.properties?.thumbnail || '';
|
|
14
|
+
// }
|
|
15
|
+
// get createdAt() {
|
|
16
|
+
// return moment(this.model.ctime, true).isValid() ? moment(this.model.ctime) : null;
|
|
17
|
+
// }
|
|
18
|
+
// get size() {
|
|
19
|
+
// return +(this.model.properties?.size || 0);
|
|
20
|
+
// }
|
|
21
|
+
// get sizeString() {
|
|
22
|
+
// const { properties } = this.model;
|
|
23
|
+
// const dimensionsFile = properties?.dimensions_file;
|
|
24
|
+
// return `${Math.round(10 * ((properties?.size || 0) / 1024)) / 10} KB, ${
|
|
25
|
+
// dimensionsFile?.width
|
|
26
|
+
// } x ${dimensionsFile?.height} `;
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TemplateCategory } from '@antscorp/antsomi-ui/es/models/TemplateCategory';
|
|
3
|
+
import { TBulkUpdateObjectTemplateArgs, TGetCategoryListArgs, TGetObjectTemplateDetailArgs, TGetObjectTemplateListArgs, TUpdateObjectTemplateArgs, TValidateObjectTemplateNameArgs } from '@antscorp/antsomi-ui/es/services/TemplateListing';
|
|
4
|
+
import { ResponseCheckNameExist, ResponseListing } from '../../types';
|
|
5
|
+
import { ObjectTemplate } from '../../models/ObjectTemplate';
|
|
6
|
+
import { TCreateObjectTemplateArgs } from '../../services/TemplateListing';
|
|
7
|
+
export type TGetTemplateCategoryList = {
|
|
8
|
+
args: TGetCategoryListArgs;
|
|
9
|
+
options?: UseQueryOptions<any, any, TemplateCategory[], any[]>;
|
|
10
|
+
};
|
|
11
|
+
export type TGetObjectTEmplateList = {
|
|
12
|
+
args: TGetObjectTemplateListArgs;
|
|
13
|
+
options?: UseInfiniteQueryOptions<any, any, ResponseListing<ObjectTemplate>, (string | number)[]>;
|
|
14
|
+
};
|
|
15
|
+
export type TGetObjectTemplateDetail = {
|
|
16
|
+
args: TGetObjectTemplateDetailArgs;
|
|
17
|
+
options?: UseQueryOptions<ObjectTemplate, any, ObjectTemplate, any[]>;
|
|
18
|
+
};
|
|
19
|
+
export type TBulkUpdateTemplate = {
|
|
20
|
+
options?: UseMutationOptions<any, any, TBulkUpdateObjectTemplateArgs, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export type TUseCreateTemplate = {
|
|
23
|
+
options?: UseMutationOptions<any, any, TCreateObjectTemplateArgs, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export type TUseUpdateTemplate = {
|
|
26
|
+
options?: UseMutationOptions<any, any, TUpdateObjectTemplateArgs, unknown>;
|
|
27
|
+
};
|
|
28
|
+
export type TUseValidateTemplateName = {
|
|
29
|
+
options?: UseMutationOptions<ResponseCheckNameExist, any, TValidateObjectTemplateNameArgs, unknown>;
|
|
30
|
+
};
|
|
31
|
+
export type TUsePersistTemplate = {
|
|
32
|
+
options?: UseMutationOptions<ObjectTemplate, any, {
|
|
33
|
+
persistType: 'create' | 'update';
|
|
34
|
+
params: TUpdateObjectTemplateArgs;
|
|
35
|
+
}, unknown>;
|
|
36
|
+
};
|
|
37
|
+
export declare const useGetTemplateCategoryList: (params: TGetTemplateCategoryList) => import("@tanstack/react-query").UseQueryResult<TemplateCategory[], any>;
|
|
38
|
+
export declare const useGetObjectTemplateList: (params: TGetObjectTEmplateList) => import("@tanstack/react-query").UseInfiniteQueryResult<ResponseListing<ObjectTemplate>, any>;
|
|
39
|
+
export declare const useGetObjectTemplateDetail: (params: TGetObjectTemplateDetail) => import("@tanstack/react-query").UseQueryResult<ObjectTemplate, any>;
|
|
40
|
+
export declare const useValidateTemplateName: (params: TUseValidateTemplateName) => import("@tanstack/react-query").UseMutationResult<ResponseCheckNameExist, any, TValidateObjectTemplateNameArgs, unknown>;
|
|
41
|
+
export declare const useBulkUpdateTemplate: (params: TBulkUpdateTemplate) => import("@tanstack/react-query").UseMutationResult<any, any, TBulkUpdateObjectTemplateArgs, unknown>;
|
|
42
|
+
export declare const useCreateTemplate: (params: TUseCreateTemplate) => import("@tanstack/react-query").UseMutationResult<any, any, TCreateObjectTemplateArgs, unknown>;
|
|
43
|
+
export declare const useUpdateTemplate: (params: TUseUpdateTemplate) => import("@tanstack/react-query").UseMutationResult<any, any, TUpdateObjectTemplateArgs, unknown>;
|
|
44
|
+
export declare const usePersistTemplate: (params: TUsePersistTemplate) => import("@tanstack/react-query").UseMutationResult<ObjectTemplate, any, {
|
|
45
|
+
persistType: 'create' | 'update';
|
|
46
|
+
params: TUpdateObjectTemplateArgs;
|
|
47
|
+
}, unknown>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
// Libraries
|
|
11
|
+
import { useInfiniteQuery, useMutation, useQuery, } from '@tanstack/react-query';
|
|
12
|
+
// Services
|
|
13
|
+
import { templateListingServices, } from '@antscorp/antsomi-ui/es/services/TemplateListing';
|
|
14
|
+
// Constants
|
|
15
|
+
import { QUERY_KEYS } from '../../constants/queries';
|
|
16
|
+
import { queryClientAntsomiUI } from '../configs';
|
|
17
|
+
const { category, objectTemplate } = templateListingServices;
|
|
18
|
+
export const useGetTemplateCategoryList = (params) => {
|
|
19
|
+
const { options, args } = params;
|
|
20
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST, args.params], queryFn: () => category.getList(params.args), onSuccess() { } }, options));
|
|
21
|
+
};
|
|
22
|
+
export const useGetObjectTemplateList = (params) => {
|
|
23
|
+
const { options, args } = params;
|
|
24
|
+
return useInfiniteQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST, args.params], queryFn: ({ pageParam = 1 }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const res = yield objectTemplate.getList(Object.assign(Object.assign({}, args), { params: Object.assign(Object.assign({}, args.params), { page: pageParam }) }));
|
|
26
|
+
return res;
|
|
27
|
+
}), getNextPageParam: lastPage => {
|
|
28
|
+
const { meta } = lastPage;
|
|
29
|
+
const { currentPage, totalPages } = meta;
|
|
30
|
+
return +currentPage < +totalPages ? Number(lastPage.meta.currentPage) + 1 : undefined;
|
|
31
|
+
} }, options));
|
|
32
|
+
};
|
|
33
|
+
export const useGetObjectTemplateDetail = (params) => {
|
|
34
|
+
const { args, options } = params;
|
|
35
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL, args.params], queryFn: () => objectTemplate.getDetail(args), enabled: !!args.params.template_id }, options));
|
|
36
|
+
};
|
|
37
|
+
export const useValidateTemplateName = (params) => {
|
|
38
|
+
const { options } = params;
|
|
39
|
+
return useMutation(Object.assign({ mutationFn: objectTemplate.validateName }, options));
|
|
40
|
+
};
|
|
41
|
+
export const useBulkUpdateTemplate = (params) => {
|
|
42
|
+
const { options } = params;
|
|
43
|
+
return useMutation(Object.assign({ mutationFn: objectTemplate.bulkUpdate, onSettled() {
|
|
44
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
|
|
45
|
+
exact: false,
|
|
46
|
+
});
|
|
47
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST], {
|
|
48
|
+
exact: false,
|
|
49
|
+
});
|
|
50
|
+
} }, options));
|
|
51
|
+
};
|
|
52
|
+
export const useCreateTemplate = (params) => {
|
|
53
|
+
const { options } = params;
|
|
54
|
+
return useMutation(Object.assign({ mutationFn: objectTemplate.create, onSettled() {
|
|
55
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
|
|
56
|
+
exact: false,
|
|
57
|
+
});
|
|
58
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST], {
|
|
59
|
+
exact: false,
|
|
60
|
+
});
|
|
61
|
+
} }, options));
|
|
62
|
+
};
|
|
63
|
+
export const useUpdateTemplate = (params) => {
|
|
64
|
+
const { options } = params;
|
|
65
|
+
return useMutation(Object.assign({ mutationFn: objectTemplate.update, onSettled() {
|
|
66
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
|
|
67
|
+
exact: false,
|
|
68
|
+
});
|
|
69
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST], {
|
|
70
|
+
exact: false,
|
|
71
|
+
});
|
|
72
|
+
} }, options));
|
|
73
|
+
};
|
|
74
|
+
export const usePersistTemplate = (params) => {
|
|
75
|
+
const { options } = params;
|
|
76
|
+
return useMutation(Object.assign({ mutationFn: (args) => {
|
|
77
|
+
const { persistType, params } = args;
|
|
78
|
+
switch (persistType) {
|
|
79
|
+
case 'update':
|
|
80
|
+
return objectTemplate.update(params);
|
|
81
|
+
case 'create':
|
|
82
|
+
default:
|
|
83
|
+
return objectTemplate.create(params);
|
|
84
|
+
}
|
|
85
|
+
}, onSettled() {
|
|
86
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
|
|
87
|
+
exact: false,
|
|
88
|
+
});
|
|
89
|
+
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST], {
|
|
90
|
+
exact: false,
|
|
91
|
+
});
|
|
92
|
+
} }, options));
|
|
93
|
+
};
|
package/es/queries/index.d.ts
CHANGED
package/es/queries/index.js
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PaginationRequest, PayloadInfo, ResponseCheckNameExist, ResponseListing, TServiceAuth } from '../../types';
|
|
2
|
+
import { TObjectType, TPublicLevel } from '../../types/templateListing';
|
|
3
|
+
import { TThumbnailCardId } from '../../components/molecules/ThumbnailCard';
|
|
4
|
+
import { TemplateCategory } from '../../models/TemplateCategory';
|
|
5
|
+
import { ObjectTemplate, TObjectTemplate } from '../../models/ObjectTemplate';
|
|
6
|
+
export type TGetCategoryListArgs = {
|
|
7
|
+
params: {
|
|
8
|
+
objectTypes: TObjectType[];
|
|
9
|
+
categoryCodes?: string[];
|
|
10
|
+
publicLevel?: TPublicLevel;
|
|
11
|
+
};
|
|
12
|
+
auth: PayloadInfo;
|
|
13
|
+
};
|
|
14
|
+
export type TGetObjectTemplateDetailArgs = {
|
|
15
|
+
params: {
|
|
16
|
+
template_id: TThumbnailCardId;
|
|
17
|
+
object_type: TObjectType;
|
|
18
|
+
public_level: TPublicLevel;
|
|
19
|
+
};
|
|
20
|
+
auth: PayloadInfo;
|
|
21
|
+
};
|
|
22
|
+
export type TGetObjectTemplateListArgs = {
|
|
23
|
+
params: {
|
|
24
|
+
object_type: TObjectType;
|
|
25
|
+
public_level: TPublicLevel;
|
|
26
|
+
} & PaginationRequest;
|
|
27
|
+
auth: TServiceAuth;
|
|
28
|
+
};
|
|
29
|
+
export type TBulkUpdateObjectTemplateArgs = {
|
|
30
|
+
params: {
|
|
31
|
+
template_ids: number[];
|
|
32
|
+
data: Partial<TObjectTemplate>;
|
|
33
|
+
};
|
|
34
|
+
auth: TServiceAuth;
|
|
35
|
+
};
|
|
36
|
+
export type TUpdateObjectTemplateArgs = {
|
|
37
|
+
data: Partial<TObjectTemplate>;
|
|
38
|
+
auth: TServiceAuth;
|
|
39
|
+
};
|
|
40
|
+
export type TCreateObjectTemplateArgs = {
|
|
41
|
+
data: Partial<TObjectTemplate>;
|
|
42
|
+
auth: TServiceAuth;
|
|
43
|
+
};
|
|
44
|
+
export type TValidateObjectTemplateNameArgs = {
|
|
45
|
+
params: {
|
|
46
|
+
template_name: string;
|
|
47
|
+
object_type: TObjectType;
|
|
48
|
+
public_level: TPublicLevel;
|
|
49
|
+
};
|
|
50
|
+
auth: TServiceAuth;
|
|
51
|
+
};
|
|
52
|
+
export declare const templateListingServices: {
|
|
53
|
+
category: {
|
|
54
|
+
getList: ({ params, auth }: TGetCategoryListArgs) => Promise<TemplateCategory[]>;
|
|
55
|
+
};
|
|
56
|
+
objectTemplate: {
|
|
57
|
+
getList: ({ params, auth, }: TGetObjectTemplateListArgs) => Promise<ResponseListing<ObjectTemplate>>;
|
|
58
|
+
getDetail: ({ params, auth }: TGetObjectTemplateDetailArgs) => Promise<ObjectTemplate>;
|
|
59
|
+
create: ({ data, auth }: TCreateObjectTemplateArgs) => Promise<ObjectTemplate>;
|
|
60
|
+
update: ({ data, auth }: TUpdateObjectTemplateArgs) => Promise<ObjectTemplate>;
|
|
61
|
+
bulkUpdate: ({ params, auth }: TBulkUpdateObjectTemplateArgs) => Promise<any>;
|
|
62
|
+
validateName: ({ params, auth, }: TValidateObjectTemplateNameArgs) => Promise<ResponseCheckNameExist>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
// Libraries
|
|
22
|
+
import { get } from 'lodash';
|
|
23
|
+
import isEmpty from 'lodash/isEmpty';
|
|
24
|
+
// Services
|
|
25
|
+
// Types
|
|
26
|
+
import axios from 'axios';
|
|
27
|
+
import { ObjectTemplate } from '../../models/ObjectTemplate';
|
|
28
|
+
const TEMPLATE_CATEGORY_ROUTE = 'template-category/index';
|
|
29
|
+
const OBJECT_TEMPLATE_ROUTE = 'object_template';
|
|
30
|
+
export const templateListingServices = {
|
|
31
|
+
category: {
|
|
32
|
+
getList: ({ params, auth }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
try {
|
|
34
|
+
const { objectTypes = [], categoryCodes, publicLevel } = params;
|
|
35
|
+
const response = yield axios({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
url: `${auth.url}/${TEMPLATE_CATEGORY_ROUTE}`,
|
|
38
|
+
params: Object.assign({ _token: auth.token, _user_id: auth.userId, _account_id: auth.accountId, objectTypes: objectTypes.join(','), publicLevel: publicLevel !== null && publicLevel !== void 0 ? publicLevel : 0 }, (!isEmpty(categoryCodes) ? { categoryCodes: categoryCodes === null || categoryCodes === void 0 ? void 0 : categoryCodes.join(',') } : {})),
|
|
39
|
+
});
|
|
40
|
+
return get(response, 'data.data', []);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return Promise.reject(error);
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
objectTemplate: {
|
|
48
|
+
getList: ({ params, auth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const response = yield axios({
|
|
51
|
+
method: 'GET',
|
|
52
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}`,
|
|
53
|
+
params: Object.assign({ _token: auth.token, _user_id: auth.userId, _account_id: auth.accountId }, params),
|
|
54
|
+
});
|
|
55
|
+
const { entities, meta } = get(response, 'data.data', {});
|
|
56
|
+
return {
|
|
57
|
+
entities: entities.map(entity => new ObjectTemplate(entity)),
|
|
58
|
+
meta,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return Promise.reject(error);
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
getDetail: ({ params, auth }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
const { template_id } = params, restOfPrams = __rest(params, ["template_id"]);
|
|
68
|
+
const response = yield axios({
|
|
69
|
+
method: 'GET',
|
|
70
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/${template_id}`,
|
|
71
|
+
params: Object.assign({ _token: auth.token, _user_id: auth.userId, _account_id: auth.accountId }, restOfPrams),
|
|
72
|
+
});
|
|
73
|
+
return new ObjectTemplate(get(response, 'data.data', {}));
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return Promise.reject(error);
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
create: ({ data, auth }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const response = yield axios({
|
|
82
|
+
method: 'POST',
|
|
83
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}`,
|
|
84
|
+
params: {
|
|
85
|
+
_token: auth.token,
|
|
86
|
+
_user_id: auth.userId,
|
|
87
|
+
_account_id: auth.accountId,
|
|
88
|
+
},
|
|
89
|
+
data,
|
|
90
|
+
});
|
|
91
|
+
return new ObjectTemplate(get(response, 'data.data', {}));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return Promise.reject(error);
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
update: ({ data, auth }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
const { template_id } = data, restOfData = __rest(data, ["template_id"]);
|
|
100
|
+
const response = yield axios({
|
|
101
|
+
method: 'PUT',
|
|
102
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/${template_id}`,
|
|
103
|
+
params: {
|
|
104
|
+
_token: auth.token,
|
|
105
|
+
_user_id: auth.userId,
|
|
106
|
+
_account_id: auth.accountId,
|
|
107
|
+
},
|
|
108
|
+
data: restOfData,
|
|
109
|
+
});
|
|
110
|
+
return new ObjectTemplate(get(response, 'data.data', {}));
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return Promise.reject(error);
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
bulkUpdate: ({ params, auth }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
try {
|
|
118
|
+
const response = yield axios({
|
|
119
|
+
method: 'POST',
|
|
120
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/bulk-update`,
|
|
121
|
+
params: {
|
|
122
|
+
_token: auth.token,
|
|
123
|
+
_user_id: auth.userId,
|
|
124
|
+
_account_id: auth.accountId,
|
|
125
|
+
template_ids: (params.template_ids || []).join(','),
|
|
126
|
+
},
|
|
127
|
+
data: params.data,
|
|
128
|
+
});
|
|
129
|
+
return get(response, 'data.data', {});
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
return Promise.reject(error);
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
validateName: ({ params, auth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
try {
|
|
137
|
+
const response = yield axios({
|
|
138
|
+
method: 'POST',
|
|
139
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/validate-name`,
|
|
140
|
+
params: Object.assign({ _token: auth.token, _user_id: auth.userId, _account_id: auth.accountId }, params),
|
|
141
|
+
});
|
|
142
|
+
return get(response, 'data.data', {});
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return Promise.reject(error);
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
};
|
package/es/test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import '@antscorp/icons/main.css';
|
|
5
|
-
import { ConfigProvider, InputDynamic, SettingWrapper, UploadImage,
|
|
5
|
+
import { ConfigProvider, InputDynamic, SettingWrapper, UploadImage, useTemplateListing, } from './components';
|
|
6
6
|
// Queries configs
|
|
7
7
|
import { queryClientAntsomiUI, QueryClientProviderAntsomiUI } from './queries';
|
|
8
8
|
export const BACKGROUND_COLOR_STYLE = {
|
|
@@ -66,7 +66,23 @@ export const App = () => {
|
|
|
66
66
|
const [sliderValue, setSliderValue] = useState(10);
|
|
67
67
|
const [edge, setEdge] = useState(['auto', 'auto', 700, 700]);
|
|
68
68
|
const [icon, setIcon] = useState('');
|
|
69
|
-
|
|
69
|
+
const { categoryItems, templateItems, checkedCategories, openCategoryKeys, isLoadingCategoryList, isLoadingTemplateList, onLoadMore: onLoadMoreTemplates, onChangeOpenCategoryKeys, onChangeCheckedCategories, onRemoveObjectTemplate, } = useTemplateListing({
|
|
70
|
+
serviceAuth: {
|
|
71
|
+
url: 'https://sandbox-media-template.antsomi.com/cdp/api/v1',
|
|
72
|
+
token: '5474r2x214z254a4u2a4y444m4j5p27444c4h4h4n5t5',
|
|
73
|
+
userId: '1600080515',
|
|
74
|
+
accountId: '1600080515',
|
|
75
|
+
},
|
|
76
|
+
config: {
|
|
77
|
+
objectType: 1,
|
|
78
|
+
publicLevel: 0,
|
|
79
|
+
limitListPerPage: 10,
|
|
80
|
+
},
|
|
81
|
+
checkedCategoriesDefault: {
|
|
82
|
+
device_type: [1, 2],
|
|
83
|
+
template_type: [1, 2, 3, 4, 5],
|
|
84
|
+
},
|
|
85
|
+
});
|
|
70
86
|
const callbackColorSetting = (key, dataIn) => {
|
|
71
87
|
switch (key) {
|
|
72
88
|
case 'ON_ADD_NEW_PRESET':
|
|
@@ -100,15 +116,20 @@ export const App = () => {
|
|
|
100
116
|
console.log({ type, data });
|
|
101
117
|
};
|
|
102
118
|
// --------------------------- Test SlideBar start -------------------------------------------
|
|
103
|
-
return (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
// return (
|
|
120
|
+
// <div
|
|
121
|
+
// style={{
|
|
122
|
+
// width: 500,
|
|
123
|
+
// height: 500,
|
|
124
|
+
// border: '1px solid black',
|
|
125
|
+
// margin: '0 auto',
|
|
126
|
+
// padding: 12,
|
|
127
|
+
// borderRadius: '10px',
|
|
128
|
+
// }}
|
|
129
|
+
// >
|
|
130
|
+
// <SlideBar {...stateSlideBar} callback={callbackSlideBar} />
|
|
131
|
+
// </div>
|
|
132
|
+
// );
|
|
112
133
|
// --------------------------- Test SlideBar end -------------------------------------------
|
|
113
134
|
// ---------------------------- Test Input Dynamic start ------------------------------
|
|
114
135
|
// return (
|
|
@@ -317,6 +338,36 @@ export const App = () => {
|
|
|
317
338
|
// </div>
|
|
318
339
|
// </ConfigProvider>
|
|
319
340
|
// );
|
|
341
|
+
// const [time, setTime] = useState<string[]>([]);
|
|
342
|
+
// const [times, setTimes] = useState<Value>({
|
|
343
|
+
// rangeInfo: { type: 'last_14_days' },
|
|
344
|
+
// rangeValue: [{ start: null, end: null }],
|
|
345
|
+
// });
|
|
346
|
+
// return (
|
|
347
|
+
// <ConfigProvider>
|
|
348
|
+
// <div
|
|
349
|
+
// style={{
|
|
350
|
+
// width: 500,
|
|
351
|
+
// height: 1000,
|
|
352
|
+
// border: '1px solid black',
|
|
353
|
+
// margin: '0 auto',
|
|
354
|
+
// padding: 12,
|
|
355
|
+
// borderRadius: '10px',
|
|
356
|
+
// marginTop: 12,
|
|
357
|
+
// }}
|
|
358
|
+
// >
|
|
359
|
+
// <h2 style={{ textAlign: 'center' }}>Test component of media template</h2>
|
|
360
|
+
// <CalendarSelection
|
|
361
|
+
// value={times}
|
|
362
|
+
// onChange={(value, info) => {
|
|
363
|
+
// console.log({ info, value });
|
|
364
|
+
// // setTime([value.rangeValue[0].start, value.rangeValue[0].end]);
|
|
365
|
+
// setTimes(value);
|
|
366
|
+
// }}
|
|
367
|
+
// />
|
|
368
|
+
// </div>
|
|
369
|
+
// </ConfigProvider>
|
|
370
|
+
// );
|
|
320
371
|
// ------------------------ Media template components test end -------------------------
|
|
321
372
|
// return (
|
|
322
373
|
// <div style={{ width: '500px', margin: '32px' }}>
|
package/es/types/index.d.ts
CHANGED
|
@@ -16,8 +16,12 @@ export type TConfigErrorInfo = {
|
|
|
16
16
|
};
|
|
17
17
|
export * from './richMenu';
|
|
18
18
|
export * from './variables';
|
|
19
|
+
export * from './service';
|
|
20
|
+
export * from './templateListing';
|
|
19
21
|
export type PayloadInfo = {
|
|
22
|
+
url?: string;
|
|
20
23
|
userId?: string;
|
|
21
24
|
token?: string;
|
|
22
25
|
accountId?: string;
|
|
23
26
|
};
|
|
27
|
+
export type TServiceAuth = PayloadInfo;
|
package/es/types/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type TFilter = Record<string, Record<string, any>>;
|
|
2
|
+
export interface PaginationRequest {
|
|
3
|
+
limit?: number;
|
|
4
|
+
page?: number;
|
|
5
|
+
filter?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResponseListing<T> {
|
|
8
|
+
entities: T[];
|
|
9
|
+
meta: {
|
|
10
|
+
itemsPerPage: number;
|
|
11
|
+
totalItems: number;
|
|
12
|
+
currentPage: string;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
sortBy: any[][];
|
|
15
|
+
filter: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ResponseCheckNameExist {
|
|
19
|
+
name: 'Vĩ test dynamic settings';
|
|
20
|
+
existed: boolean;
|
|
21
|
+
existedId: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TEMPLATE_CATEGORY_KEYS, OBJECT_TYPES, PUBLIC_LEVEL, TEMPLATE_STATUS } from '../constants/templateListing';
|
|
2
|
+
export type TObjectType = (typeof OBJECT_TYPES)[keyof typeof OBJECT_TYPES];
|
|
3
|
+
export type TPublicLevel = (typeof PUBLIC_LEVEL)[keyof typeof PUBLIC_LEVEL];
|
|
4
|
+
export type TTemplateStatus = (typeof TEMPLATE_STATUS)[keyof typeof TEMPLATE_STATUS];
|
|
5
|
+
export type TObjectTemplateCategory = (typeof TEMPLATE_CATEGORY_KEYS)[keyof typeof TEMPLATE_CATEGORY_KEYS];
|
|
6
|
+
export type TTemplateListingConfig = {
|
|
7
|
+
objectType: TObjectType;
|
|
8
|
+
publicLevel: TPublicLevel;
|
|
9
|
+
categoryCodes?: string[];
|
|
10
|
+
limitListPerPage?: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/utils/common.d.ts
CHANGED
|
@@ -55,3 +55,5 @@ export declare const isEmail: (email: string) => boolean;
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function mapNumberToOrdinalText(num: number): string;
|
|
57
57
|
export declare const searchParamsToObject: (searchParams?: string) => Record<string, unknown>;
|
|
58
|
+
export declare function asssertCannotReach(x: never): void;
|
|
59
|
+
export declare const getShuffleArray: <T>(array: T[]) => T[];
|