mario-education 2.4.538-feedback → 2.4.539-feedback

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.
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface RestApiProgressProps {
3
3
  restApiInfo?: object;
4
+ importInfo: string[];
4
5
  }
5
6
  declare const RestApiProgress: React.FC<RestApiProgressProps>;
6
7
  export default RestApiProgress;
@@ -3,6 +3,7 @@ import { VERA_CROSS_CONFIG } from "../configs/types";
3
3
  interface Props {
4
4
  veraCrossConfig: VERA_CROSS_CONFIG;
5
5
  updateData: Function;
6
+ labelTime?: string;
6
7
  }
7
8
  declare const VeraCrossConfigForm: FC<Props>;
8
9
  export default VeraCrossConfigForm;
@@ -11,3 +11,4 @@ export declare const DEFAULT_PAGE_SIZE: {
11
11
  };
12
12
  export declare const DEFAULT_FILTER: UserRosterFilter;
13
13
  export declare const IMPORT_VERA_CROSS_NAME: string[];
14
+ export declare const IMPORT_OPEN_APPLY_NAME: string[];
@@ -0,0 +1,9 @@
1
+ import { VERA_CROSS_CONFIG } from "../configs/types";
2
+ declare const userOpenApply: () => {
3
+ openApplyConfig: VERA_CROSS_CONFIG;
4
+ errorImportRest: string | null;
5
+ updateData: (values: any) => Promise<void>;
6
+ restApiInfo: object | undefined;
7
+ handleImportFromRestfulApi: () => Promise<void>;
8
+ };
9
+ export default userOpenApply;
@@ -0,0 +1,2 @@
1
+ declare const OpenApplyImport: () => JSX.Element;
2
+ export default OpenApplyImport;
package/dist/index.js CHANGED
@@ -42046,6 +42046,8 @@ var ONE_ROSTER_USER_URL = marioCore.BASE_URL + "/api/usersOneRoster";
42046
42046
  var EDU_ROSTER_USER_URL = marioCore.BASE_URL + "/api/User/roster-users";
42047
42047
  var VERA_CROSS_URL = marioCore.BASE_URL + "/api/veraCross";
42048
42048
  var IMPORT_RESTFUL_API_VERA_CROSS_URL = marioCore.BASE_URL + "/api/ImportRestApiVeraCross/rest";
42049
+ var OPEN_APPLY_URL = marioCore.BASE_URL + "/api/openApply";
42050
+ var IMPORT_RESTFUL_API_OPEN_APPLY_URL = marioCore.BASE_URL + "/api/ImportRestApiOpenApply/rest";
42049
42051
  var getRosterConfig = function getRosterConfig() {
42050
42052
  return marioCore.api.get(ROSTER_URL);
42051
42053
  };
@@ -42058,6 +42060,15 @@ var updateVeraCrossConfig = function updateVeraCrossConfig(data) {
42058
42060
  var updateRosterConfig = function updateRosterConfig(data) {
42059
42061
  return marioCore.api.put("" + ROSTER_URL, data);
42060
42062
  };
42063
+ var getOpenApplyConfig = function getOpenApplyConfig() {
42064
+ return marioCore.api.get(OPEN_APPLY_URL);
42065
+ };
42066
+ var updateOpenApplyConfig = function updateOpenApplyConfig(data) {
42067
+ return marioCore.api.put("" + OPEN_APPLY_URL, data);
42068
+ };
42069
+ var importOpenApplyFromRestfulApi = function importOpenApplyFromRestfulApi(fileName) {
42070
+ return marioCore.api.post(IMPORT_RESTFUL_API_OPEN_APPLY_URL + "?name=" + fileName);
42071
+ };
42061
42072
  var importVeraCrossFromRestfulApi = function importVeraCrossFromRestfulApi(fileName) {
42062
42073
  return marioCore.api.post(IMPORT_RESTFUL_API_VERA_CROSS_URL + "?name=" + fileName);
42063
42074
  };
@@ -42093,6 +42104,7 @@ var DEFAULT_FILTER$1 = {
42093
42104
  isCreated: false
42094
42105
  };
42095
42106
  var IMPORT_VERA_CROSS_NAME = ["students", "faculties"];
42107
+ var IMPORT_OPEN_APPLY_NAME = ["students", "parents"];
42096
42108
 
42097
42109
  var useImportOneRoster = function useImportOneRoster(_ref) {
42098
42110
  var errorImportRest = _ref.errorImportRest;
@@ -50444,7 +50456,9 @@ var OneRosterUserList = function OneRosterUserList() {
50444
50456
 
50445
50457
  var VeraCrossConfigForm = function VeraCrossConfigForm(_ref) {
50446
50458
  var veraCrossConfig = _ref.veraCrossConfig,
50447
- updateData = _ref.updateData;
50459
+ updateData = _ref.updateData,
50460
+ _ref$labelTime = _ref.labelTime,
50461
+ labelTime = _ref$labelTime === void 0 ? "time_vera_cross_sync_hh" : _ref$labelTime;
50448
50462
 
50449
50463
  var _useTranslation = marioCore.useTranslation(),
50450
50464
  t = _useTranslation.t;
@@ -50469,9 +50483,9 @@ var VeraCrossConfigForm = function VeraCrossConfigForm(_ref) {
50469
50483
  className: "my-4 mt-2"
50470
50484
  }, React__default.createElement(reactstrap.Label, {
50471
50485
  className: "font-weight-bold"
50472
- }, t("time_vera_cross_sync_hh")), React__default.createElement(reactstrap.Input, {
50486
+ }, t(labelTime)), React__default.createElement(reactstrap.Input, {
50473
50487
  name: "cronjobTime",
50474
- placeholder: t("time_vera_cross_sync_hh"),
50488
+ placeholder: t(labelTime),
50475
50489
  value: values.cronjobTime,
50476
50490
  onChange: function onChange(e) {
50477
50491
  handleChange(e);
@@ -50676,9 +50690,10 @@ var userVeraCross = function userVeraCross() {
50676
50690
  };
50677
50691
 
50678
50692
  var RestApiProgress = function RestApiProgress(_ref) {
50679
- var restApiInfo = _ref.restApiInfo;
50693
+ var restApiInfo = _ref.restApiInfo,
50694
+ importInfo = _ref.importInfo;
50680
50695
  if (!restApiInfo) return null;
50681
- var info = IMPORT_VERA_CROSS_NAME.map(function (fileName) {
50696
+ var info = importInfo.map(function (fileName) {
50682
50697
  return {
50683
50698
  name: fileName,
50684
50699
  status: restApiInfo[fileName]
@@ -50743,7 +50758,200 @@ var VeracrossImport = function VeracrossImport() {
50743
50758
  }, t("import_from_restful_api")), React__default.createElement("div", {
50744
50759
  className: "mt-2"
50745
50760
  }, React__default.createElement(RestApiProgress, {
50746
- restApiInfo: restApiInfo
50761
+ restApiInfo: restApiInfo,
50762
+ importInfo: IMPORT_VERA_CROSS_NAME
50763
+ })))))));
50764
+ };
50765
+
50766
+ var initValue$t = {
50767
+ cronjobTime: "",
50768
+ clientId: "",
50769
+ clientSecret: "",
50770
+ endPointUrl: ""
50771
+ };
50772
+
50773
+ var userOpenApply = function userOpenApply() {
50774
+ var dispatch = reactRedux.useDispatch();
50775
+
50776
+ var _useState = React.useState(),
50777
+ restApiInfo = _useState[0],
50778
+ setRestApiInfo = _useState[1];
50779
+
50780
+ var _useState2 = React.useState(initValue$t),
50781
+ openApplyConfig = _useState2[0],
50782
+ setOpenApplyConfig = _useState2[1];
50783
+
50784
+ var getData = React.useCallback(function (loading) {
50785
+ if (loading === void 0) {
50786
+ loading = true;
50787
+ }
50788
+
50789
+ try {
50790
+ var _temp3 = function _temp3() {
50791
+ if (loading) dispatch(marioCore.setLoading(false));
50792
+ };
50793
+
50794
+ if (loading) dispatch(marioCore.setLoading(true));
50795
+
50796
+ var _temp4 = _catch(function () {
50797
+ return Promise.resolve(getOpenApplyConfig()).then(function (res) {
50798
+ setOpenApplyConfig(res.data);
50799
+ });
50800
+ }, function (err) {
50801
+ var _err$response, _err$response$data;
50802
+
50803
+ if (loading) dispatch(marioCore.setAlert({
50804
+ type: "danger",
50805
+ message: ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : _err$response$data.title) || err.message
50806
+ }));
50807
+ });
50808
+
50809
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
50810
+ } catch (e) {
50811
+ return Promise.reject(e);
50812
+ }
50813
+ }, []);
50814
+ var updateData = React.useCallback(function (values) {
50815
+ try {
50816
+ var _temp7 = function _temp7() {
50817
+ dispatch(marioCore.setLoading(false));
50818
+ };
50819
+
50820
+ dispatch(marioCore.setLoading(true));
50821
+
50822
+ var _temp8 = _catch(function () {
50823
+ return Promise.resolve(updateOpenApplyConfig(values)).then(function (res) {
50824
+ setOpenApplyConfig(res.data);
50825
+ return Promise.resolve(getData(false)).then(function () {
50826
+ dispatch(marioCore.setAlert({
50827
+ type: "success",
50828
+ message: "Update vera cross config successfully"
50829
+ }));
50830
+ });
50831
+ });
50832
+ }, function (err) {
50833
+ var _err$response2, _err$response2$data;
50834
+
50835
+ dispatch(marioCore.setAlert({
50836
+ type: "danger",
50837
+ message: ((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : (_err$response2$data = _err$response2.data) === null || _err$response2$data === void 0 ? void 0 : _err$response2$data.title) || err.message
50838
+ }));
50839
+ });
50840
+
50841
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
50842
+ } catch (e) {
50843
+ return Promise.reject(e);
50844
+ }
50845
+ }, []);
50846
+ var errorImportRest = React.useMemo(function () {
50847
+ if (!openApplyConfig.clientId.trim().length && !openApplyConfig.clientSecret.trim().length && !openApplyConfig.endPointUrl.trim().length) return "Client Id and Client Secret are required";
50848
+ if (!openApplyConfig.endPointUrl.trim().length) return "End Point URL is required";
50849
+ if (!openApplyConfig.clientId.trim().length) return "Client Id is required";
50850
+ if (!openApplyConfig.clientSecret.trim().length) return "Client Secret is required";
50851
+ return null;
50852
+ }, [JSON.stringify(openApplyConfig)]);
50853
+ var importRosterRestApi = React.useCallback(function (fileName) {
50854
+ try {
50855
+ var _temp10 = _catch(function () {
50856
+ return Promise.resolve(importOpenApplyFromRestfulApi(fileName)).then(function () {
50857
+ setRestApiInfo(function (state) {
50858
+ var _extends2;
50859
+
50860
+ return _extends({}, state, (_extends2 = {}, _extends2[fileName] = true, _extends2));
50861
+ });
50862
+ });
50863
+ }, function (err) {
50864
+ var _err$response3, _err$response3$data, _err$response3$data$t, _err$response3$data$t2;
50865
+
50866
+ var title = (_err$response3 = err.response) === null || _err$response3 === void 0 ? void 0 : (_err$response3$data = _err$response3.data) === null || _err$response3$data === void 0 ? void 0 : (_err$response3$data$t = _err$response3$data.title) === null || _err$response3$data$t === void 0 ? void 0 : (_err$response3$data$t2 = _err$response3$data$t.replaceAll) === null || _err$response3$data$t2 === void 0 ? void 0 : _err$response3$data$t2.call(_err$response3$data$t, '"', "");
50867
+ setRestApiInfo(function (state) {
50868
+ var _extends3;
50869
+
50870
+ return _extends({}, state, (_extends3 = {}, _extends3[fileName] = title || err.message, _extends3));
50871
+ });
50872
+ });
50873
+
50874
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
50875
+ } catch (e) {
50876
+ return Promise.reject(e);
50877
+ }
50878
+ }, [JSON.stringify(restApiInfo)]);
50879
+ var handleImportFromRestfulApi = React.useCallback(function () {
50880
+ try {
50881
+ if (errorImportRest) {
50882
+ dispatch(marioCore.setAlert({
50883
+ type: "danger",
50884
+ message: errorImportRest + " (Please make sure your changes are saved)"
50885
+ }));
50886
+ return Promise.resolve();
50887
+ }
50888
+
50889
+ setRestApiInfo({});
50890
+ dispatch(marioCore.setLoading(true));
50891
+ return Promise.resolve(Promise.all(IMPORT_OPEN_APPLY_NAME.map(function (fileName) {
50892
+ return importRosterRestApi(fileName);
50893
+ }))).then(function () {
50894
+ dispatch(marioCore.setLoading(false));
50895
+ });
50896
+ } catch (e) {
50897
+ return Promise.reject(e);
50898
+ }
50899
+ }, [errorImportRest]);
50900
+ React.useEffect(function () {
50901
+ document.title = "Open Apply | Settings";
50902
+ getData();
50903
+ }, []);
50904
+ return {
50905
+ openApplyConfig: openApplyConfig,
50906
+ errorImportRest: errorImportRest,
50907
+ updateData: updateData,
50908
+ restApiInfo: restApiInfo,
50909
+ handleImportFromRestfulApi: handleImportFromRestfulApi
50910
+ };
50911
+ };
50912
+
50913
+ var OpenApplyImport = function OpenApplyImport() {
50914
+ var _userOpenApply = userOpenApply(),
50915
+ openApplyConfig = _userOpenApply.openApplyConfig,
50916
+ updateData = _userOpenApply.updateData,
50917
+ restApiInfo = _userOpenApply.restApiInfo,
50918
+ handleImportFromRestfulApi = _userOpenApply.handleImportFromRestfulApi;
50919
+
50920
+ var _useTranslation = marioCore.useTranslation(),
50921
+ t = _useTranslation.t;
50922
+
50923
+ return React__default.createElement("div", {
50924
+ className: "fadeIn animated"
50925
+ }, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
50926
+ md: 7
50927
+ }, React__default.createElement(VeraCrossConfigForm, {
50928
+ veraCrossConfig: openApplyConfig,
50929
+ updateData: updateData,
50930
+ labelTime: "time_open_apply_sync_hh"
50931
+ })), React__default.createElement(reactstrap.Col, {
50932
+ md: 5
50933
+ }), React__default.createElement(reactstrap.Col, {
50934
+ md: 7
50935
+ }, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
50936
+ md: 12
50937
+ }, React__default.createElement("h5", {
50938
+ className: "mt-4",
50939
+ style: {
50940
+ fontWeight: 700
50941
+ }
50942
+ }, t("import_open_apply"))), React__default.createElement(reactstrap.Col, {
50943
+ md: 6
50944
+ }), React__default.createElement(reactstrap.Col, {
50945
+ md: 6
50946
+ }, React__default.createElement(reactstrap.Button, {
50947
+ color: "primary",
50948
+ className: "w-100 mt-4 mb-1",
50949
+ onClick: handleImportFromRestfulApi
50950
+ }, t("import_from_restful_api")), React__default.createElement("div", {
50951
+ className: "mt-2"
50952
+ }, React__default.createElement(RestApiProgress, {
50953
+ restApiInfo: restApiInfo,
50954
+ importInfo: IMPORT_OPEN_APPLY_NAME
50747
50955
  })))))));
50748
50956
  };
50749
50957
 
@@ -50755,6 +50963,10 @@ var tabs$9 = [{
50755
50963
  path: "/admin/one-rosters/veracross-settings",
50756
50964
  title: "veracross_setting",
50757
50965
  component: VeracrossImport
50966
+ }, {
50967
+ path: "/admin/one-rosters/open-apply",
50968
+ title: "open_apply_setting",
50969
+ component: OpenApplyImport
50758
50970
  }, {
50759
50971
  path: "/admin/one-rosters/users",
50760
50972
  title: "users",
@@ -74803,7 +75015,7 @@ var WeeklyQuest = function WeeklyQuest() {
74803
75015
  }))));
74804
75016
  };
74805
75017
 
74806
- var initValue$t = {
75018
+ var initValue$u = {
74807
75019
  challenge: "",
74808
75020
  id: 0,
74809
75021
  order: 0,
@@ -74817,7 +75029,7 @@ var useWeeklyQuestDetail = function useWeeklyQuestDetail(id) {
74817
75029
  var dispatch = reactRedux.useDispatch();
74818
75030
  var history = reactRouterDom.useHistory();
74819
75031
 
74820
- var _useState = React.useState(initValue$t),
75032
+ var _useState = React.useState(initValue$u),
74821
75033
  dataDetail = _useState[0],
74822
75034
  setDataDetail = _useState[1];
74823
75035
 
@@ -74839,7 +75051,7 @@ var useWeeklyQuestDetail = function useWeeklyQuestDetail(id) {
74839
75051
  }, [dataDetail]);
74840
75052
  React.useEffect(function () {
74841
75053
  id && getData();
74842
- return setDataDetail(initValue$t);
75054
+ return setDataDetail(initValue$u);
74843
75055
  }, [id]);
74844
75056
  var getData = React.useCallback(function () {
74845
75057
  try {