mario-education 2.3.1 → 2.3.2
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,2 +1,3 @@
|
|
|
1
1
|
export declare const importCSV: (formData: FormData, subFolder: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
2
|
+
export declare const importStudentCSV: (formData: FormData) => Promise<import("axios").AxiosResponse<any>>;
|
|
2
3
|
export declare const importClassReflectionCSV: (formData: FormData) => Promise<import("axios").AxiosResponse<any>>;
|
package/dist/index.js
CHANGED
|
@@ -5175,7 +5175,6 @@ var LearningSupportCategoryList = function LearningSupportCategoryList() {
|
|
|
5175
5175
|
|
|
5176
5176
|
var style = {
|
|
5177
5177
|
padding: "4px 8px",
|
|
5178
|
-
marginRight: 16,
|
|
5179
5178
|
marginBottom: 0,
|
|
5180
5179
|
borderRadius: "2px",
|
|
5181
5180
|
color: "#fff",
|
|
@@ -5209,8 +5208,9 @@ var UploadCSVButton = function UploadCSVButton(_ref) {
|
|
|
5209
5208
|
};
|
|
5210
5209
|
|
|
5211
5210
|
var CSV_FILE_URL = marioCore.BASE_URL + "/api/ImportCsv/csv";
|
|
5212
|
-
var
|
|
5213
|
-
|
|
5211
|
+
var CSV_FILE_TEACHER = marioCore.BASE_URL + "/api/Teacher";
|
|
5212
|
+
var importStudentCSV = function importStudentCSV(formData) {
|
|
5213
|
+
return marioCore.apiUpload.post(CSV_FILE_TEACHER + "/adminImportStudent", formData);
|
|
5214
5214
|
};
|
|
5215
5215
|
var importClassReflectionCSV = function importClassReflectionCSV(formData) {
|
|
5216
5216
|
return marioCore.apiUpload.post(CSV_FILE_URL + "/importClassReflection", formData);
|
|
@@ -5228,25 +5228,9 @@ var CSVType;
|
|
|
5228
5228
|
})(CSVType || (CSVType = {}));
|
|
5229
5229
|
|
|
5230
5230
|
var buttons = [{
|
|
5231
|
-
text: "Import
|
|
5232
|
-
backgroundColor: "#
|
|
5233
|
-
type: CSVType.
|
|
5234
|
-
}, {
|
|
5235
|
-
text: "Import grades",
|
|
5236
|
-
backgroundColor: "#54a0ff",
|
|
5237
|
-
type: CSVType.Grades
|
|
5238
|
-
}, {
|
|
5239
|
-
text: "Import attendances",
|
|
5240
|
-
backgroundColor: "#feca57",
|
|
5241
|
-
type: CSVType.Attendances
|
|
5242
|
-
}, {
|
|
5243
|
-
text: "Import class reflections",
|
|
5244
|
-
backgroundColor: "#e74c3c",
|
|
5245
|
-
type: CSVType.ClassReflection
|
|
5246
|
-
}, {
|
|
5247
|
-
text: "Import others",
|
|
5248
|
-
backgroundColor: "#8395a7",
|
|
5249
|
-
type: CSVType.Others
|
|
5231
|
+
text: "Import students",
|
|
5232
|
+
backgroundColor: "#0abde3",
|
|
5233
|
+
type: CSVType.Students
|
|
5250
5234
|
}];
|
|
5251
5235
|
var title = "CSV Import";
|
|
5252
5236
|
var id = "csvupload";
|
|
@@ -5286,7 +5270,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5286
5270
|
try {
|
|
5287
5271
|
var _temp3 = function _temp3() {
|
|
5288
5272
|
dispatch(marioCore.setLoading(false));
|
|
5289
|
-
var input = document.getElementById(
|
|
5273
|
+
var input = document.getElementById('import-student');
|
|
5290
5274
|
input && (input.value = "");
|
|
5291
5275
|
};
|
|
5292
5276
|
|
|
@@ -5296,7 +5280,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5296
5280
|
var _temp4 = _catch(function () {
|
|
5297
5281
|
var formData = new FormData();
|
|
5298
5282
|
formData.append("file", file, file.name);
|
|
5299
|
-
return Promise.resolve(
|
|
5283
|
+
return Promise.resolve(importStudentCSV(formData)).then(function () {
|
|
5300
5284
|
dispatch(marioCore.setAlert({
|
|
5301
5285
|
type: "success",
|
|
5302
5286
|
message: "Import CSV successfully"
|
|
@@ -5333,7 +5317,9 @@ var useCSVImport = function useCSVImport() {
|
|
|
5333
5317
|
formData.append("file", dataFile, dataFile.name);
|
|
5334
5318
|
formData.append("teacherName", values.teacherName);
|
|
5335
5319
|
formData.append("teacherEmail", values.teacherEmail);
|
|
5336
|
-
|
|
5320
|
+
values.studentIds.forEach(function (item) {
|
|
5321
|
+
formData.append("studentIds", item);
|
|
5322
|
+
});
|
|
5337
5323
|
return Promise.resolve(importClassReflectionCSV(formData)).then(function () {
|
|
5338
5324
|
dispatch(marioCore.setAlert({
|
|
5339
5325
|
type: "success",
|
|
@@ -5375,7 +5361,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5375
5361
|
|
|
5376
5362
|
var schema$4 = yup.object({
|
|
5377
5363
|
teacherName: yup.string().required(),
|
|
5378
|
-
teacherEmail: yup.string().required(),
|
|
5364
|
+
teacherEmail: yup.string().email('Invalid email').required(),
|
|
5379
5365
|
studentIds: yup.array().required().test("test students", "Please choose student", function () {
|
|
5380
5366
|
return !!this.parent.studentIds && !!this.parent.studentIds.length;
|
|
5381
5367
|
}),
|
|
@@ -5393,11 +5379,21 @@ var CSVImport = function CSVImport() {
|
|
|
5393
5379
|
dataFile = _useCSVImport.dataFile,
|
|
5394
5380
|
setDataFile = _useCSVImport.setDataFile,
|
|
5395
5381
|
setArrStudent = _useCSVImport.setArrStudent,
|
|
5396
|
-
arrStudent = _useCSVImport.arrStudent
|
|
5382
|
+
arrStudent = _useCSVImport.arrStudent,
|
|
5383
|
+
buttons = _useCSVImport.buttons,
|
|
5384
|
+
upload = _useCSVImport.upload;
|
|
5397
5385
|
|
|
5398
5386
|
return React__default.createElement("div", {
|
|
5399
5387
|
className: "animated fadeIn pt-3"
|
|
5400
|
-
}, React__default.createElement(
|
|
5388
|
+
}, React__default.createElement(reactstrap.Input, {
|
|
5389
|
+
className: "d-none",
|
|
5390
|
+
type: "file",
|
|
5391
|
+
id: "import-student",
|
|
5392
|
+
onChange: function onChange(e) {
|
|
5393
|
+
return upload(e.target.files[0]);
|
|
5394
|
+
},
|
|
5395
|
+
accept: "text/csv"
|
|
5396
|
+
}), React__default.createElement("div", {
|
|
5401
5397
|
className: "class-reflection"
|
|
5402
5398
|
}, React__default.createElement(formik.Formik, {
|
|
5403
5399
|
initialValues: initImportReflection,
|
|
@@ -5491,7 +5487,7 @@ var CSVImport = function CSVImport() {
|
|
|
5491
5487
|
}
|
|
5492
5488
|
}), !!dataFile && React__default.createElement("p", {
|
|
5493
5489
|
style: {
|
|
5494
|
-
color: '
|
|
5490
|
+
color: '#007bff',
|
|
5495
5491
|
fontStyle: 'italic',
|
|
5496
5492
|
marginTop: '5px'
|
|
5497
5493
|
}
|
|
@@ -5508,7 +5504,26 @@ var CSVImport = function CSVImport() {
|
|
|
5508
5504
|
onClick: function onClick() {
|
|
5509
5505
|
return handleSubmit();
|
|
5510
5506
|
}
|
|
5511
|
-
}, "Import"), ' ')))
|
|
5507
|
+
}, "Import"), ' '))), React__default.createElement(reactstrap.Col, {
|
|
5508
|
+
md: 6,
|
|
5509
|
+
className: "mb-2"
|
|
5510
|
+
}, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
|
|
5511
|
+
md: 12,
|
|
5512
|
+
className: "mb-2"
|
|
5513
|
+
}, React__default.createElement(marioCore.RequiredLabel, {
|
|
5514
|
+
text: "Import student"
|
|
5515
|
+
}), buttons.map(function (button) {
|
|
5516
|
+
return React__default.createElement(UploadCSVButton, {
|
|
5517
|
+
key: button.text,
|
|
5518
|
+
htmlFor: 'import-student',
|
|
5519
|
+
text: button.text,
|
|
5520
|
+
isDisabled: isLoading,
|
|
5521
|
+
backgroundColor: button.backgroundColor,
|
|
5522
|
+
onClick: function onClick() {
|
|
5523
|
+
return setType(button.type);
|
|
5524
|
+
}
|
|
5525
|
+
});
|
|
5526
|
+
})))));
|
|
5512
5527
|
})));
|
|
5513
5528
|
};
|
|
5514
5529
|
|