code7-leia 0.1.91 → 0.1.93

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.
@@ -428,7 +428,8 @@ var defaultLanguage = {
428
428
  modal: {
429
429
  descriptionUpload: 'Drag and drop files here or',
430
430
  chooseFile: 'Choose a file',
431
- uploadFile: 'Upload a file'
431
+ uploadFile: 'Upload a file',
432
+ deleteFile: 'Important! By deleting this file, you will lose all its information and will not be able to recover it.'
432
433
  }
433
434
  },
434
435
  buttons: {
@@ -466,7 +467,8 @@ var getLanguage = function getLanguage(language) {
466
467
  modal: _extends({}, defaultLanguage.fileArea.modal, {
467
468
  descriptionUpload: 'Arraste e solte os arquivos aqui ou',
468
469
  chooseFile: 'Escolha um arquivo',
469
- uploadFile: 'Enviar um arquivo'
470
+ uploadFile: 'Enviar um arquivo',
471
+ deleteFile: 'Importante! Ao deletar esse arquivo você perderá todas as informações dele e não terá como recuperá-las.'
470
472
  })
471
473
  }),
472
474
  buttons: _extends({}, defaultLanguage.buttons, {
@@ -500,7 +502,8 @@ var getLanguage = function getLanguage(language) {
500
502
  }),
501
503
  modal: _extends({}, defaultLanguage.fileArea.modal, {
502
504
  descriptionUpload: 'Arrastre y suelte los archivos aquí o',
503
- chooseFile: 'Elegir un archivo'
505
+ chooseFile: 'Elegir un archivo',
506
+ deleteFile: '¡Importante! Al borrar este archivo perderás toda la información contenida en él y no podrás recuperarla.'
504
507
  })
505
508
  }),
506
509
  buttons: _extends({}, defaultLanguage.buttons, {
@@ -525,7 +528,7 @@ var getLanguage = function getLanguage(language) {
525
528
  };
526
529
 
527
530
  var _templateObject$1, _templateObject2$1;
528
- var Container = /*#__PURE__*/styled.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .tag {\n padding: 4px 8px 4px 8px;\n background: #C7F9ED;\n border-radius: 4px;\n }\n\n .tags {\n display: flex;\n justify-content: left;\n gap: 4px;\n }\n\n .divDelete {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n }\n\n .buttonDelete {\n color: #5b0a1f;\n background: #fae0d2;\n padding: 12px 20px;\n border-radius: 4px;\n }\n\n .buttonDelete:hover {\n background: #f5bba7;\n }\n\n .button {\n padding: 8px 16px 8px 16px;\n border-radius: 4px;\n gap: 10px;\n }\n\n .cancel {\n background: #F3F5F9;\n color: #5A5D68;\n }\n\n .send {\n background: #102693;\n color: white;\n }\n\n .presset {\n padding-top: 10px;\n display: flex;\n flex-direction: column;\n }\n"])));
531
+ var Container = /*#__PURE__*/styled.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .tag {\n padding: 4px 8px 4px 8px;\n background: #C7F9ED;\n border-radius: 4px;\n }\n\n .tags {\n display: flex;\n justify-content: left;\n gap: 4px;\n }\n\n .divDelete {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n }\n\n .buttonDelete {\n color: #5b0a1f;\n background: #fae0d2;\n padding: 12px 20px;\n border-radius: 4px;\n }\n\n .buttonDelete:hover {\n background: #f5bba7;\n }\n\n .button {\n padding: 8px 16px 8px 16px;\n border-radius: 4px;\n gap: 10px;\n }\n\n .cancel {\n background: #F3F5F9;\n color: #5A5D68;\n }\n\n .send {\n background: #102693;\n color: white;\n }\n\n .presset {\n padding-top: 10px;\n display: flex;\n flex-direction: column;\n }\n\n #warning {\n padding: 10px;\n background: #FAE0D2;\n color: #871821;\n }\n"])));
529
532
  var Header = /*#__PURE__*/styled.div(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n\n .infos {\n display: flex;\n flex-direction: column;\n padding: 14px 0;\n\n h2 {\n font-size: 20px\n }\n\n p {\n font-size: 14px\n }\n }\n\n .actions {\n display: flex;\n justify-content: space-between;\n padding-bottom: 14px;\n\n button {\n background: #102693;\n padding: 10px 20px;\n color: white;\n border-radius: 4px;\n }\n }\n\n"])));
530
533
 
531
534
  var _templateObject$2, _templateObject2$2, _templateObject3;
@@ -981,7 +984,9 @@ var SharedPropsProvider = function SharedPropsProvider(_ref) {
981
984
 
982
985
  var Types = {
983
986
  GET_FILES_REQUEST: '@files/GET_FILES_REQUEST',
984
- GET_FILES_SUCCESS: '@files/GET_FILES_SUCCESS'
987
+ GET_FILES_SUCCESS: '@files/GET_FILES_SUCCESS',
988
+ DELETE_FILES_REQUEST: '@files/DELETE_FILES_REQUEST',
989
+ DELETE_FILES_SUCCESS: '@files/DELETE_FILES_SUCCESS'
985
990
  };
986
991
 
987
992
  var getFilesAction = function getFilesAction(id) {
@@ -1001,6 +1006,24 @@ var getFilesActionSuccess = function getFilesActionSuccess(_ref) {
1001
1006
  }
1002
1007
  };
1003
1008
  };
1009
+ var deleteFilesAction = function deleteFilesAction(name, id) {
1010
+ return {
1011
+ type: Types.DELETE_FILES_REQUEST,
1012
+ payload: {
1013
+ name: name,
1014
+ id: id
1015
+ }
1016
+ };
1017
+ };
1018
+ var deleteFilesActionSuccess = function deleteFilesActionSuccess(_ref2) {
1019
+ var files = _ref2.files;
1020
+ return {
1021
+ type: Types.DELETE_FILES_SUCCESS,
1022
+ payload: {
1023
+ files: files
1024
+ }
1025
+ };
1026
+ };
1004
1027
 
1005
1028
  var FileArea = function FileArea() {
1006
1029
  var _useState = useState([]),
@@ -1015,25 +1038,29 @@ var FileArea = function FileArea() {
1015
1038
  var _useState4 = useState(false),
1016
1039
  modal = _useState4[0],
1017
1040
  setModal = _useState4[1];
1041
+ var _useState5 = useState(false),
1042
+ modalDelete = _useState5[0],
1043
+ setModalDelete = _useState5[1];
1044
+ var _useState6 = useState(''),
1045
+ fileDelete = _useState6[0],
1046
+ setFileDelete = _useState6[1];
1018
1047
  var _useSharedProps = useSharedProps(),
1019
1048
  id = _useSharedProps.id,
1020
1049
  language = _useSharedProps.language;
1021
- console.log('-----language----->', language);
1022
1050
  var t = getLanguage(language);
1023
- console.log('-----t----->', t);
1024
1051
  var dispatch = useDispatch();
1025
1052
  var initFiles = useSelector(function (state) {
1026
1053
  return state.files;
1027
1054
  });
1028
1055
  var tags = ["pae", "boteria", "vr", "code7", "vidalink"];
1029
1056
  useEffect(function () {
1030
- console.log('useEffect, []');
1031
1057
  dispatch(getFilesAction(id));
1032
1058
  }, []);
1033
1059
  useEffect(function () {
1034
- console.log('----------initFiles------------>', initFiles);
1035
- console.log('----------!!initFiles------------>', !!initFiles);
1036
- setInitialFiles([]);
1060
+ if (!!initFiles) {
1061
+ setFiles(initFiles);
1062
+ setInitialFiles(initFiles);
1063
+ }
1037
1064
  }, [initFiles]);
1038
1065
  var optionsPresset = tags.map(function (tag) {
1039
1066
  return {
@@ -1052,6 +1079,13 @@ var FileArea = function FileArea() {
1052
1079
  var handleOpenModal = function handleOpenModal() {
1053
1080
  setModal(!modal);
1054
1081
  };
1082
+ var handleOpenModalDelete = function handleOpenModalDelete(name) {
1083
+ setFileDelete(name);
1084
+ setModalDelete(!modalDelete);
1085
+ };
1086
+ var deleteFile = function deleteFile() {
1087
+ dispatch(deleteFilesAction(fileDelete, id));
1088
+ };
1055
1089
  var handleSelect = function handleSelect(value) {
1056
1090
  console.log(value);
1057
1091
  console.log(uploadFile);
@@ -1095,7 +1129,10 @@ var FileArea = function FileArea() {
1095
1129
  }), React.createElement("td", null, React.createElement("div", {
1096
1130
  className: 'divDelete'
1097
1131
  }, React.createElement("button", {
1098
- className: 'buttonDelete'
1132
+ className: 'buttonDelete',
1133
+ onClick: function onClick() {
1134
+ return handleOpenModalDelete(object.name);
1135
+ }
1099
1136
  }, t.buttons["delete"]))));
1100
1137
  }))), React.createElement(Modal$1, {
1101
1138
  isOpen: modal,
@@ -1120,7 +1157,25 @@ var FileArea = function FileArea() {
1120
1157
  className: 'button send',
1121
1158
  type: "submit",
1122
1159
  form: "form-tts"
1123
- }, t.buttons.send))));
1160
+ }, t.buttons.send))), React.createElement(Modal$1, {
1161
+ isOpen: modal,
1162
+ maxWidth: "600px",
1163
+ maxHeight: "max-content",
1164
+ onClose: handleOpenModal,
1165
+ title: t.fileArea.modal.uploadFile
1166
+ }, React.createElement(ModalContent, null, React.createElement("p", {
1167
+ id: 'warning'
1168
+ }, t.fileArea.modal.deleteFile)), React.createElement(ModalFooter, null, React.createElement("button", {
1169
+ className: 'button cancel',
1170
+ onClick: function onClick() {
1171
+ return handleOpenModalDelete('');
1172
+ }
1173
+ }, t.buttons.cancel), React.createElement("button", {
1174
+ className: 'button send',
1175
+ type: "submit",
1176
+ form: "form-tts",
1177
+ onClick: deleteFile
1178
+ }, t.buttons["delete"]))));
1124
1179
  };
1125
1180
  return React.createElement(Container, null, renderFiles());
1126
1181
  };
@@ -1279,6 +1334,9 @@ function filesReducer(state, action) {
1279
1334
  case Types.GET_FILES_SUCCESS:
1280
1335
  draft.files = action.payload.files;
1281
1336
  break;
1337
+ case Types.DELETE_FILES_SUCCESS:
1338
+ draft.files = action.payload.files;
1339
+ break;
1282
1340
  default:
1283
1341
  return action.payload;
1284
1342
  }
@@ -1290,7 +1348,8 @@ axios.defaults.baseURL = "" + url;
1290
1348
  var api = /*#__PURE__*/axios.create();
1291
1349
 
1292
1350
  var _marked = /*#__PURE__*/_regeneratorRuntime().mark(getFilesSaga),
1293
- _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(filesSagas);
1351
+ _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(deleteFilesSaga),
1352
+ _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(filesSagas);
1294
1353
  function getFilesSaga(action) {
1295
1354
  var id, _yield$call, data;
1296
1355
  return _regeneratorRuntime().wrap(function getFilesSaga$(_context) {
@@ -1320,17 +1379,49 @@ function getFilesSaga(action) {
1320
1379
  }
1321
1380
  }, _marked, null, [[0, 10]]);
1322
1381
  }
1323
- function filesSagas() {
1324
- return _regeneratorRuntime().wrap(function filesSagas$(_context2) {
1382
+ function deleteFilesSaga(action) {
1383
+ var _action$payload, id, name, _yield$call2, data;
1384
+ return _regeneratorRuntime().wrap(function deleteFilesSaga$(_context2) {
1325
1385
  while (1) switch (_context2.prev = _context2.next) {
1326
1386
  case 0:
1327
- _context2.next = 2;
1328
- return all([takeLatest(Types.GET_FILES_REQUEST, getFilesSaga)]);
1329
- case 2:
1387
+ _context2.prev = 0;
1388
+ _action$payload = action.payload, id = _action$payload.id, name = _action$payload.name;
1389
+ _context2.next = 4;
1390
+ return call(api["delete"], "/delete/" + id + "/" + name);
1391
+ case 4:
1392
+ _context2.next = 6;
1393
+ return call(api.get, "/files/" + id);
1394
+ case 6:
1395
+ _yield$call2 = _context2.sent;
1396
+ data = _yield$call2.data;
1397
+ _context2.next = 10;
1398
+ return put(deleteFilesActionSuccess({
1399
+ files: data.files
1400
+ }));
1401
+ case 10:
1402
+ _context2.next = 15;
1403
+ break;
1404
+ case 12:
1405
+ _context2.prev = 12;
1406
+ _context2.t0 = _context2["catch"](0);
1407
+ console.log('-----------getFiles.error------------------->', _context2.t0);
1408
+ case 15:
1330
1409
  case "end":
1331
1410
  return _context2.stop();
1332
1411
  }
1333
- }, _marked2);
1412
+ }, _marked2, null, [[0, 12]]);
1413
+ }
1414
+ function filesSagas() {
1415
+ return _regeneratorRuntime().wrap(function filesSagas$(_context3) {
1416
+ while (1) switch (_context3.prev = _context3.next) {
1417
+ case 0:
1418
+ _context3.next = 2;
1419
+ return all([takeLatest(Types.GET_FILES_REQUEST, getFilesSaga), takeLatest(Types.DELETE_FILES_REQUEST, deleteFilesSaga)]);
1420
+ case 2:
1421
+ case "end":
1422
+ return _context3.stop();
1423
+ }
1424
+ }, _marked3);
1334
1425
  }
1335
1426
 
1336
1427
  var sagaMiddleware = /*#__PURE__*/createSagaMiddleware();