awing-library 2.1.159-dev → 2.1.161-dev

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.
@@ -43,17 +43,15 @@ var Preview = function (props) {
43
43
  var _a;
44
44
  var classes = useStyles();
45
45
  var t = (0, react_i18next_1.useTranslation)().t;
46
- var validStatus = props.validStatus, pagePath = props.pagePath, templateDatas = props.templateDatas,
47
- // domainId,
48
- configs = props.configs;
46
+ var validStatus = props.validStatus, pagePath = props.pagePath, templateDatas = props.templateDatas, domainId = props.domainId, configs = props.configs;
49
47
  var viewIndex = ((_a = templateDatas[0]) === null || _a === void 0 ? void 0 : _a.viewNumber) || -1;
50
48
  var formRef = react_1.default.useRef(null);
51
49
  var iframeSrc = (0, react_1.useMemo)(function () {
52
- var result = "".concat(configs.CAPTIVE_DOMAIN, "/").concat(configs.TEMPLATE_PREVIEW);
50
+ var result = "".concat(configs.CAPTIVE_DOMAIN, "/").concat(configs.TEMPLATE_PREVIEW, "?domainId=").concat(domainId);
53
51
  if (result.startsWith("http://"))
54
52
  result = result.replace("http://", "https://");
55
53
  return result;
56
- }, [configs.CAPTIVE_DOMAIN, configs.TEMPLATE_PREVIEW]);
54
+ }, [configs.CAPTIVE_DOMAIN, configs.TEMPLATE_PREVIEW, domainId]);
57
55
  (0, react_1.useEffect)(function () {
58
56
  var handleFormdata = function (_a) {
59
57
  var formData = _a.formData;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { IWizardTemplate } from '../Types';
2
+ import { Directory, TemplateType, IWizardTemplate } from '../Types';
3
3
  interface PropsPageTemplate {
4
4
  pageCodeValue: number;
5
+ directories: Directory[];
6
+ templateTypes: TemplateType[];
5
7
  wizardTemplates: IWizardTemplate[];
6
8
  onConfirmExit: () => void;
7
9
  onChange: (wizardNew: object) => void;
@@ -19,55 +19,45 @@ var react_1 = require("react");
19
19
  var react_i18next_1 = require("react-i18next");
20
20
  var Add_1 = __importDefault(require("@mui/icons-material/Add"));
21
21
  var material_1 = require("@mui/material");
22
- var Hooks_1 = __importDefault(require("../Hooks"));
23
22
  var RowTemplate_1 = __importDefault(require("./RowTemplate"));
24
23
  var AWING_1 = require("../../../AWING");
25
24
  var enums_1 = require("../../../ACM-AXN/Page/enums");
26
25
  var Utils_1 = require("../Utils");
27
26
  function PageTemplate(props) {
28
- var pageCodeValue = props.pageCodeValue, wizardTemplates = props.wizardTemplates, onChange = props.onChange, onConfirmExit = props.onConfirmExit, _a = props.onUpdateWizardLogin, onUpdateWizardLogin = _a === void 0 ? function () { return null; } : _a;
27
+ var pageCodeValue = props.pageCodeValue, wizardTemplates = props.wizardTemplates, templateTypes = props.templateTypes, directories = props.directories, onChange = props.onChange, onConfirmExit = props.onConfirmExit, _a = props.onUpdateWizardLogin, onUpdateWizardLogin = _a === void 0 ? function () { return null; } : _a;
29
28
  var t = (0, react_i18next_1.useTranslation)().t;
30
- var service = (0, Hooks_1.default)().service;
31
29
  var isPageCodeLogin = pageCodeValue === enums_1.PageCode.Lgn;
32
30
  var pageCode = pageCodeValue === enums_1.PageCode.Lgn ? Utils_1.CPageCode.LGN : Utils_1.CPageCode.WLC;
33
31
  var _b = (0, react_1.useState)(true), loadingDirectory = _b[0], setLoadingDirectories = _b[1];
34
32
  var _c = (0, react_1.useState)(true), loadingtemplateTypes = _c[0], setLoadingTemplateTypes = _c[1];
35
33
  // DATA => Tên Thư Mục
36
- var _d = (0, react_1.useState)([]), directories = _d[0], setDirectories = _d[1];
34
+ var _d = (0, react_1.useState)([]), pageDirectories = _d[0], setPageDirectories = _d[1];
37
35
  // DATA => Kiểu template
38
- var _e = (0, react_1.useState)([]), templateTypes = _e[0], setTemplateTypes = _e[1];
39
- (0, react_1.useEffect)(function () {
40
- service
41
- .templatesGetDirectories()
42
- .then(function (directories_) {
36
+ var _e = (0, react_1.useState)([]), pageTemplateTypes = _e[0], setPageTemplateTypes = _e[1];
37
+ (0, react_1.useLayoutEffect)(function () {
38
+ if (directories.length > 0) {
43
39
  // CALL API => DATA => Tên Thư Mục
44
- var systemDirectoryIndex = directories_ === null || directories_ === void 0 ? void 0 : directories_.findIndex(function (directory) {
40
+ var systemDirectoryIndex = directories === null || directories === void 0 ? void 0 : directories.findIndex(function (directory) {
45
41
  return directory.parentDirectoryId ===
46
42
  Utils_1.ROOT_DIRECTORY.SYSTEM_DIRECTORY.toString();
47
43
  });
48
44
  if (systemDirectoryIndex !== -1) {
49
- directories_[systemDirectoryIndex].name = 'SYSTEM TEMPLATE';
45
+ directories[systemDirectoryIndex].name = 'SYSTEM TEMPLATE';
50
46
  }
51
- setDirectories(directories_);
52
- })
53
- .finally(function () {
54
- setLoadingDirectories(false);
55
- });
47
+ setPageDirectories(directories);
48
+ loadingDirectory && setLoadingDirectories(false);
49
+ }
56
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
57
- }, []);
58
- (0, react_1.useEffect)(function () {
59
- service
60
- .templateTypesGet()
61
- .then(function (templateTypes_) {
62
- setTemplateTypes(templateTypes_.filter(function (itemTemplate) {
51
+ }, [directories.length]);
52
+ (0, react_1.useLayoutEffect)(function () {
53
+ if (templateTypes.length > 0) {
54
+ setPageTemplateTypes(templateTypes.filter(function (itemTemplate) {
63
55
  return itemTemplate.templateTypeCode === pageCode;
64
56
  }));
65
- })
66
- .finally(function () {
67
- setLoadingTemplateTypes(false);
68
- });
57
+ loadingtemplateTypes && setLoadingTemplateTypes(false);
58
+ }
69
59
  // eslint-disable-next-line react-hooks/exhaustive-deps
70
- }, [pageCodeValue]);
60
+ }, [templateTypes.length]);
71
61
  var handleChangeRowTemplate = function (fieldValue, sortOrder) {
72
62
  var _a;
73
63
  onConfirmExit();
@@ -93,6 +83,6 @@ function PageTemplate(props) {
93
83
  ? t('Wizard.LoginTemplate')
94
84
  : t('Wizard.WelcomeTemplate') }), isPageCodeLogin && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", "aria-label": "button-add", title: t('Common.Add'), "data-testid": "button-add", onClick: function () {
95
85
  return onUpdateWizardLogin(Utils_1.TYPE_LOGIN_TEMPLATE.ADD);
96
- }, children: (0, jsx_runtime_1.jsx)(Add_1.default, {}) }))] }), loadingDirectory || loadingtemplateTypes ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: wizardTemplates.map(function (template, idx) { return ((0, jsx_runtime_1.jsx)(RowTemplate_1.default, { template: template, pageCode: pageCode, directories: directories, templateTypes: templateTypes, onChangeRow: handleChangeRowTemplate, onUpdateWizardLogin: onUpdateWizardLogin, disabledIconDelete: wizardTemplates.length === 1 }, idx)); }) }))] }));
86
+ }, children: (0, jsx_runtime_1.jsx)(Add_1.default, {}) }))] }), loadingDirectory || loadingtemplateTypes ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: wizardTemplates.map(function (template, idx) { return ((0, jsx_runtime_1.jsx)(RowTemplate_1.default, { template: template, pageCode: pageCode, directories: pageDirectories, templateTypes: pageTemplateTypes, onChangeRow: handleChangeRowTemplate, onUpdateWizardLogin: onUpdateWizardLogin, disabledIconDelete: wizardTemplates.length === 1 }, idx)); }) }))] }));
97
87
  }
98
88
  exports.default = (0, react_1.memo)(PageTemplate);
@@ -76,6 +76,8 @@ describe('PageTemplate component', function () {
76
76
  var mockData = {
77
77
  pageCodeValue: 1,
78
78
  wizardTemplates: [],
79
+ directories: [],
80
+ templateTypes: [],
79
81
  onConfirmExit: jest.fn(),
80
82
  onChange: jest.fn(),
81
83
  onUpdateWizardLogin: jest.fn(),
@@ -47,7 +47,7 @@ function RowTemplate(props) {
47
47
  }, [template]);
48
48
  (0, react_1.useEffect)(function () {
49
49
  if (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.directoryId) {
50
- setIsLoadingParameter(true);
50
+ !isLoadingParameter && setIsLoadingParameter(true);
51
51
  service
52
52
  .templatesGetByDirectoryId(wizardTemplate.directoryId)
53
53
  .then(function (template_) {
@@ -49,6 +49,22 @@ function CreateOrEdit() {
49
49
  }), wizardData = _c[0], setWizardData = _c[1];
50
50
  // Nhóm Wizard
51
51
  var _d = (0, react_1.useState)([]), wizardGroup = _d[0], setWizardGroup = _d[1];
52
+ // DATA => Kiểu template
53
+ var _e = (0, react_1.useState)([]), templateTypes = _e[0], setTemplateTypes = _e[1];
54
+ // DATA => Tên Thư Mục
55
+ var _f = (0, react_1.useState)([]), directories = _f[0], setDirectories = _f[1];
56
+ (0, react_1.useEffect)(function () {
57
+ if (!templateTypes.length) {
58
+ service.templateTypesGet().then(setTemplateTypes);
59
+ }
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ }, [templateTypes.length]);
62
+ (0, react_1.useEffect)(function () {
63
+ if (!directories.length) {
64
+ service.templatesGetDirectories().then(setDirectories);
65
+ }
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, [directories.length]);
52
68
  (0, react_1.useEffect)(function () {
53
69
  if (id) {
54
70
  setLoading(true);
@@ -125,7 +141,7 @@ function CreateOrEdit() {
125
141
  hasValidData((wizardData === null || wizardData === void 0 ? void 0 : wizardData.wizardWelcomeTemplates) || []));
126
142
  };
127
143
  return ((0, jsx_runtime_1.jsx)(ClassicDrawer_1.default, { title: id ? t('Common.Edit') : t('Common.Create'), onSubmit: handleSubmit, confirmExit: confirmExit, childrenWrapperStyle: { padding: 0 }, disableButtonSubmit: !(isDisable() && confirmExit), children: loading ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FormInformationBasic_1.default, { wizardData: wizardData, wizardGroup: wizardGroup, onChange: handleChange, onConfirmExit: handleConfirmExit }), TEMPLATES.map(function (value) {
128
- return ((0, jsx_runtime_1.jsx)(PageTemplate_1.default, { pageCodeValue: value, onChange: handleChange, onConfirmExit: handleConfirmExit, wizardTemplates: value === enums_1.PageCode.Lgn
144
+ return ((0, jsx_runtime_1.jsx)(PageTemplate_1.default, { pageCodeValue: value, onChange: handleChange, directories: directories, templateTypes: templateTypes, onConfirmExit: handleConfirmExit, wizardTemplates: value === enums_1.PageCode.Lgn
129
145
  ? (wizardData === null || wizardData === void 0 ? void 0 : wizardData.wizardLoginTemplates) || []
130
146
  : (wizardData === null || wizardData === void 0 ? void 0 : wizardData.wizardWelcomeTemplates) ||
131
147
  [], onUpdateWizardLogin: handleUpdateWizardLoginTemplate }, value));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.159-dev",
3
+ "version": "2.1.161-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",