mario-core 2.10.6-release → 2.10.7-release

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/dist/index.js CHANGED
@@ -22208,93 +22208,6 @@ const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.it
22208
22208
 
22209
22209
  const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
22210
22210
 
22211
- // Asynchronously implement a generic for loop
22212
- function _for(test, update, body) {
22213
- var stage;
22214
- for (;;) {
22215
- var shouldContinue = test();
22216
- if (_isSettledPact(shouldContinue)) {
22217
- shouldContinue = shouldContinue.v;
22218
- }
22219
- if (!shouldContinue) {
22220
- return result;
22221
- }
22222
- if (shouldContinue.then) {
22223
- stage = 0;
22224
- break;
22225
- }
22226
- var result = body();
22227
- if (result && result.then) {
22228
- if (_isSettledPact(result)) {
22229
- result = result.s;
22230
- } else {
22231
- stage = 1;
22232
- break;
22233
- }
22234
- }
22235
- if (update) {
22236
- var updateValue = update();
22237
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
22238
- stage = 2;
22239
- break;
22240
- }
22241
- }
22242
- }
22243
- var pact = new _Pact();
22244
- var reject = _settle.bind(null, pact, 2);
22245
- (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
22246
- return pact;
22247
- function _resumeAfterBody(value) {
22248
- result = value;
22249
- do {
22250
- if (update) {
22251
- updateValue = update();
22252
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
22253
- updateValue.then(_resumeAfterUpdate).then(void 0, reject);
22254
- return;
22255
- }
22256
- }
22257
- shouldContinue = test();
22258
- if (!shouldContinue || (_isSettledPact(shouldContinue) && !shouldContinue.v)) {
22259
- _settle(pact, 1, result);
22260
- return;
22261
- }
22262
- if (shouldContinue.then) {
22263
- shouldContinue.then(_resumeAfterTest).then(void 0, reject);
22264
- return;
22265
- }
22266
- result = body();
22267
- if (_isSettledPact(result)) {
22268
- result = result.v;
22269
- }
22270
- } while (!result || !result.then);
22271
- result.then(_resumeAfterBody).then(void 0, reject);
22272
- }
22273
- function _resumeAfterTest(shouldContinue) {
22274
- if (shouldContinue) {
22275
- result = body();
22276
- if (result && result.then) {
22277
- result.then(_resumeAfterBody).then(void 0, reject);
22278
- } else {
22279
- _resumeAfterBody(result);
22280
- }
22281
- } else {
22282
- _settle(pact, 1, result);
22283
- }
22284
- }
22285
- function _resumeAfterUpdate() {
22286
- if (shouldContinue = test()) {
22287
- if (shouldContinue.then) {
22288
- shouldContinue.then(_resumeAfterTest).then(void 0, reject);
22289
- } else {
22290
- _resumeAfterTest(shouldContinue);
22291
- }
22292
- } else {
22293
- _settle(pact, 1, result);
22294
- }
22295
- }
22296
- }
22297
-
22298
22211
  // Asynchronously call a function and send errors to recovery continuation
22299
22212
  function _catch(body, recover) {
22300
22213
  try {
@@ -49671,8 +49584,8 @@ var importClassReflectionCSV$1 = function importClassReflectionCSV(formData) {
49671
49584
  var importStudentByTeacher$1 = function importStudentByTeacher(teacherId, formData) {
49672
49585
  return apiUpload.post(CSV_FILE_TEACHER$1 + "/adminImportStudentByTeacherId/" + teacherId, formData);
49673
49586
  };
49674
- var importUsersCSV$1 = function importUsersCSV(formData) {
49675
- return apiUpload.post(CSV_FILE_TEACHER$1 + "/adminImport", formData);
49587
+ var importChunkFileUsers = function importChunkFileUsers(data) {
49588
+ return api.post(CSV_FILE_TEACHER$1 + "/adminImportChunkUser", data);
49676
49589
  };
49677
49590
  var downloadTemplateFileUser$1 = function downloadTemplateFileUser() {
49678
49591
  return api.get(CSV_FILE_TEACHER$1 + "/download-template-file-user");
@@ -49695,11 +49608,6 @@ var isbButtons = [{
49695
49608
  backgroundColor: "#0abde3",
49696
49609
  type: CSVType$1.AllUser
49697
49610
  }];
49698
- var othersButtons = [{
49699
- text: "import_class_reflection",
49700
- backgroundColor: "#e74c3c",
49701
- type: CSVType$1.ClassReflection
49702
- }];
49703
49611
  var title$5 = "CSV Import";
49704
49612
  var id$1 = "csvupload";
49705
49613
  var initClassReflect$1 = {
@@ -49735,8 +49643,7 @@ var useCSVImportTab = function useCSVImportTab() {
49735
49643
  studentDataFile = _useState5[0],
49736
49644
  setStudentDataFile = _useState5[1];
49737
49645
 
49738
- var domainName = window.location.hostname;
49739
- var isCheckDomainIBS = domainName.includes('isb') || domainName.includes('stage');
49646
+ var isCheckDomainIBS = true;
49740
49647
 
49741
49648
  var _useState6 = React.useState(0),
49742
49649
  defaultTeacher = _useState6[0],
@@ -49749,7 +49656,7 @@ var useCSVImportTab = function useCSVImportTab() {
49749
49656
  React.useEffect(function () {
49750
49657
  document.title = title$5;
49751
49658
  }, []);
49752
- var buttons = isCheckDomainIBS ? isbButtons : othersButtons;
49659
+ var buttons = isbButtons ;
49753
49660
 
49754
49661
  var downloadTemplateUser = function downloadTemplateUser() {
49755
49662
  try {
@@ -49787,56 +49694,12 @@ var useCSVImportTab = function useCSVImportTab() {
49787
49694
  }
49788
49695
  };
49789
49696
 
49790
- var safeImport = function safeImport(importUsersCSV, formData, chunkIndex) {
49791
- try {
49792
- var _exit3 = false;
49793
- var _retry = 0;
49794
- return Promise.resolve(_for(function () {
49795
- return !_exit3 && _retry < 2;
49796
- }, function () {
49797
- return _retry++;
49798
- }, function () {
49799
- return _catch(function () {
49800
- _exit3 = true;
49801
- return Promise.resolve(importUsersCSV(formData));
49802
- }, function (err) {
49803
- var _exit2 = false;
49804
-
49805
- function _temp6(_result) {
49806
- if (_exit2) return _result;
49807
- throw err;
49808
- }
49809
-
49810
- if (err.response) {
49811
- throw err;
49812
- }
49813
-
49814
- console.warn("\u26A0\uFE0F Chunk " + chunkIndex + " network error, retry " + (_retry + 1) + "/2...");
49815
-
49816
- var _temp5 = function () {
49817
- if (_retry < 1) {
49818
- return Promise.resolve(new Promise(function (res) {
49819
- return setTimeout(res, 500);
49820
- })).then(function () {});
49821
- } else {
49822
- throw err;
49823
- }
49824
- }();
49825
-
49826
- return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
49827
- });
49828
- }));
49829
- } catch (e) {
49830
- return Promise.reject(e);
49831
- }
49832
- };
49833
-
49834
49697
  var upload = React.useCallback(function (file) {
49835
49698
  try {
49836
- var _exit5 = false;
49699
+ var _exit2 = false;
49837
49700
 
49838
- var _temp14 = function _temp14(_result4) {
49839
- if (_exit5) return _result4;
49701
+ var _temp12 = function _temp12(_result2) {
49702
+ if (_exit2) return _result2;
49840
49703
  dispatch(setLoading(false));
49841
49704
  var inputId = document.getElementById(id$1);
49842
49705
  var input = document.getElementById('import-student');
@@ -49849,9 +49712,9 @@ var useCSVImportTab = function useCSVImportTab() {
49849
49712
  if (!type || !file) return Promise.resolve();
49850
49713
  dispatch(setLoading(true));
49851
49714
 
49852
- var _temp15 = _catch(function () {
49853
- function _temp11(_result3) {
49854
- if (_exit5) return _result3;
49715
+ var _temp13 = _catch(function () {
49716
+ function _temp9(_result) {
49717
+ if (_exit2) return _result;
49855
49718
  dispatch(setAlert({
49856
49719
  type: "success",
49857
49720
  message: "Import CSV successfully"
@@ -49861,7 +49724,7 @@ var useCSVImportTab = function useCSVImportTab() {
49861
49724
  var formData = new FormData();
49862
49725
  formData.append("file", file, file.name);
49863
49726
 
49864
- var _temp10 = function () {
49727
+ var _temp8 = function () {
49865
49728
  if (type == CSVType$1.AllUser) {
49866
49729
  return Promise.resolve(file.text()).then(function (fileTextRaw) {
49867
49730
  var fileText = fileTextRaw.trim();
@@ -49888,48 +49751,67 @@ var useCSVImportTab = function useCSVImportTab() {
49888
49751
 
49889
49752
  for (var _i = 0; _i < dataRows.length; _i += chunkSize) {
49890
49753
  var chunkData = dataRows.slice(_i, _i + chunkSize);
49891
- var csvChunk = Papa.unparse({
49892
- fields: header != null ? header : [],
49893
- data: chunkData
49754
+ var valuesOnly = chunkData.map(function (row) {
49755
+ return Object.values(row).map(function (v) {
49756
+ return (v != null ? v : "").toString().trim();
49757
+ });
49758
+ });
49759
+ console.log({
49760
+ valuesOnly: valuesOnly
49761
+ });
49762
+ console.log({
49763
+ chunkData: chunkData
49894
49764
  });
49895
- chunks.push(csvChunk);
49896
- }
49897
49765
 
49898
- var _temp7 = _forTo(chunks, function (i) {
49899
- var blob = new Blob([chunks[i]], {
49900
- type: "text/csv"
49766
+ if (header) {
49767
+ valuesOnly.unshift(header);
49768
+ }
49769
+
49770
+ console.log({
49771
+ valuesOnly: valuesOnly
49901
49772
  });
49902
- var formData = new FormData();
49903
- formData.append("file", blob, "students_chunk" + (i + 1) + ".csv");
49904
- return Promise.resolve(safeImport(importUsersCSV$1, formData, i + 1)).then(function () {
49773
+ chunks.push(valuesOnly);
49774
+ }
49775
+
49776
+ console.log({
49777
+ chunks: chunks
49778
+ });
49779
+ console.log({
49780
+ header: header
49781
+ });
49782
+
49783
+ var _temp5 = _forTo(chunks, function (i) {
49784
+ return Promise.resolve(importChunkFileUsers({
49785
+ chunks: chunks[i]
49786
+ })).then(function () {
49905
49787
  return Promise.resolve(new Promise(function (res) {
49906
49788
  return setTimeout(res, 500);
49907
49789
  })).then(function () {});
49908
49790
  });
49909
49791
  });
49910
49792
 
49911
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
49793
+ if (_temp5 && _temp5.then) return _temp5.then(function () {});
49912
49794
  });
49913
49795
  } else {
49914
- var _temp16 = function () {
49796
+ var _temp14 = function () {
49915
49797
  if (isCheckDomainIBS) {
49916
- var _temp17 = function () {
49798
+ var _temp15 = function () {
49917
49799
  if (type == CSVType$1.ClassReflection) {
49918
49800
  return Promise.resolve(importClassReflectionCSV$1(formData)).then(function () {});
49919
49801
  }
49920
49802
  }();
49921
49803
 
49922
- if (_temp17 && _temp17.then) return _temp17.then(function () {});
49804
+ if (_temp15 && _temp15.then) return _temp15.then(function () {});
49923
49805
  } else {
49924
49806
  return Promise.resolve(importCSV$1(formData, type.toString())).then(function () {});
49925
49807
  }
49926
49808
  }();
49927
49809
 
49928
- if (_temp16 && _temp16.then) return _temp16.then(function () {});
49810
+ if (_temp14 && _temp14.then) return _temp14.then(function () {});
49929
49811
  }
49930
49812
  }();
49931
49813
 
49932
- return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
49814
+ return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
49933
49815
  }, function (err) {
49934
49816
  var _err$response, _err$response$data;
49935
49817
 
@@ -49940,7 +49822,7 @@ var useCSVImportTab = function useCSVImportTab() {
49940
49822
  }));
49941
49823
  });
49942
49824
 
49943
- return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(_temp14) : _temp14(_temp15));
49825
+ return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
49944
49826
  } catch (e) {
49945
49827
  return Promise.reject(e);
49946
49828
  }
@@ -49948,7 +49830,7 @@ var useCSVImportTab = function useCSVImportTab() {
49948
49830
 
49949
49831
  var uploadByTeacherId = function uploadByTeacherId(file) {
49950
49832
  try {
49951
- var _temp20 = function _temp20() {
49833
+ var _temp18 = function _temp18() {
49952
49834
  dispatch(setLoading(false));
49953
49835
  var input = document.getElementById('teacherSelector');
49954
49836
  input && (input.value = "");
@@ -49965,7 +49847,7 @@ var useCSVImportTab = function useCSVImportTab() {
49965
49847
  if (!type || !file) return Promise.resolve();
49966
49848
  dispatch(setLoading(true));
49967
49849
 
49968
- var _temp21 = _catch(function () {
49850
+ var _temp19 = _catch(function () {
49969
49851
  var formData = new FormData();
49970
49852
  formData.append("file", file, file.name);
49971
49853
  return Promise.resolve(importStudentByTeacher$1(defaultTeacher, formData)).then(function () {
@@ -49983,7 +49865,7 @@ var useCSVImportTab = function useCSVImportTab() {
49983
49865
  }));
49984
49866
  });
49985
49867
 
49986
- return Promise.resolve(_temp21 && _temp21.then ? _temp21.then(_temp20) : _temp20(_temp21));
49868
+ return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19));
49987
49869
  } catch (e) {
49988
49870
  return Promise.reject(e);
49989
49871
  }
@@ -49991,7 +49873,7 @@ var useCSVImportTab = function useCSVImportTab() {
49991
49873
 
49992
49874
  var onConfirm = function onConfirm(values) {
49993
49875
  try {
49994
- var _temp24 = function _temp24() {
49876
+ var _temp22 = function _temp22() {
49995
49877
  dispatch(setLoading(false));
49996
49878
  var input = document.getElementById(id$1);
49997
49879
  input && (input.value = "");
@@ -50000,7 +49882,7 @@ var useCSVImportTab = function useCSVImportTab() {
50000
49882
  if (!dataFile || !dataFile) return Promise.resolve();
50001
49883
  dispatch(setLoading(true));
50002
49884
 
50003
- var _temp25 = _catch(function () {
49885
+ var _temp23 = _catch(function () {
50004
49886
  var formData = new FormData();
50005
49887
  formData.append("file", dataFile, dataFile.name);
50006
49888
  formData.append("teacherName", values.teacherName);
@@ -50024,7 +49906,7 @@ var useCSVImportTab = function useCSVImportTab() {
50024
49906
  }));
50025
49907
  });
50026
49908
 
50027
- return Promise.resolve(_temp25 && _temp25.then ? _temp25.then(_temp24) : _temp24(_temp25));
49909
+ return Promise.resolve(_temp23 && _temp23.then ? _temp23.then(_temp22) : _temp22(_temp23));
50028
49910
  } catch (e) {
50029
49911
  return Promise.reject(e);
50030
49912
  }
@@ -50111,7 +49993,6 @@ var CSVImport = function CSVImport() {
50111
49993
  setArrStudent = _useCSVImportTab.setArrStudent,
50112
49994
  buttons = _useCSVImportTab.buttons,
50113
49995
  upload = _useCSVImportTab.upload,
50114
- isCheckDomainIBS = _useCSVImportTab.isCheckDomainIBS,
50115
49996
  downloadTemplateUser = _useCSVImportTab.downloadTemplateUser;
50116
49997
 
50117
49998
  var _useTranslation = reactI18next.useTranslation(),
@@ -50119,7 +50000,7 @@ var CSVImport = function CSVImport() {
50119
50000
 
50120
50001
  return React__default.createElement("div", {
50121
50002
  className: "animated fadeIn pt-3"
50122
- }, isCheckDomainIBS ? React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Input, {
50003
+ }, React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Input, {
50123
50004
  className: "d-none",
50124
50005
  type: "file",
50125
50006
  id: "import-user",
@@ -50227,67 +50108,7 @@ var CSVImport = function CSVImport() {
50227
50108
  }
50228
50109
  });
50229
50110
  })))));
50230
- }))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
50231
- md: 12,
50232
- className: "mt-2 mb-2 text-left"
50233
- }, React__default.createElement(reactstrap.Button, {
50234
- role: "button",
50235
- color: "primary",
50236
- onClick: function onClick() {
50237
- return downloadTemplateUser();
50238
- }
50239
- }, React__default.createElement("p", {
50240
- className: "d-flex align-items-center mb-0"
50241
- }, t("download_template"), " ", React__default.createElement(ai.AiOutlineDownload, {
50242
- size: 20,
50243
- className: "ml-2"
50244
- })))), React__default.createElement(reactstrap.Col, {
50245
- md: 6,
50246
- className: "mb-3"
50247
- }, React__default.createElement(reactstrap.Input, {
50248
- id: "import-user",
50249
- className: "d-none",
50250
- type: "file",
50251
- onChange: function onChange(e) {
50252
- return upload(e.target.files[0]);
50253
- },
50254
- accept: "text/csv"
50255
- }), React__default.createElement(RequiredLabel$1, {
50256
- text: t("import_users")
50257
- }), React__default.createElement(UploadCSVButton, {
50258
- key: "import-users",
50259
- htmlFor: 'import-user',
50260
- text: t("import_users"),
50261
- isDisabled: isLoading,
50262
- backgroundColor: "#0abde3",
50263
- onClick: function onClick() {
50264
- setType(CSVType.AllUser);
50265
- }
50266
- })), React__default.createElement(reactstrap.Col, {
50267
- md: 6,
50268
- className: "mb-3"
50269
- }, React__default.createElement(reactstrap.Input, {
50270
- className: "d-none",
50271
- type: "file",
50272
- id: id,
50273
- onChange: function onChange(e) {
50274
- return upload(e.target.files[0]);
50275
- },
50276
- accept: "text/csv"
50277
- }), buttons.map(function (button) {
50278
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(RequiredLabel$1, {
50279
- text: t(button.text)
50280
- }), React__default.createElement(UploadCSVButton, {
50281
- key: button.text,
50282
- htmlFor: id,
50283
- text: t(button.text),
50284
- isDisabled: isLoading,
50285
- backgroundColor: button.backgroundColor,
50286
- onClick: function onClick() {
50287
- return setType(button.type);
50288
- }
50289
- }));
50290
- })))));
50111
+ }))) );
50291
50112
  };
50292
50113
 
50293
50114
  var tabs = [{