code7-leia 0.1.113 → 0.1.115

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.
@@ -3,7 +3,7 @@ import React, { forwardRef, useRef, useCallback, useEffect, useState, createCont
3
3
  import { useRouteMatch, useLocation, useHistory, Switch, Route } from 'react-router-dom';
4
4
  import PropTypes from 'prop-types';
5
5
  import cc from 'classcat';
6
- import styled from 'styled-components';
6
+ import styled, { css } from 'styled-components';
7
7
  import { FaSearch, FaUpload, FaList, FaPlus, FaMicrophone } from 'react-icons/fa';
8
8
  import unorm from 'unorm';
9
9
  import { MdClose, MdPerson2 } from 'react-icons/md';
@@ -14,6 +14,8 @@ import { createStore, applyMiddleware } from 'redux';
14
14
  import createSagaMiddleware from 'redux-saga';
15
15
  import { produce } from 'immer';
16
16
  import { all, takeLatest, put, call } from 'redux-saga/effects';
17
+ import { toast as toast$1 } from 'react-toastify';
18
+ import 'react-toastify/dist/ReactToastify.css';
17
19
 
18
20
  function _regeneratorRuntime() {
19
21
  _regeneratorRuntime = function () {
@@ -478,6 +480,34 @@ var defaultLanguage = {
478
480
  title: 'No data for analysis',
479
481
  description: 'Do a search, click the "Test" button.'
480
482
  }
483
+ },
484
+ toast: {
485
+ deleteFile: {
486
+ success: {
487
+ title: 'Success',
488
+ description: 'File deleted successfully!'
489
+ },
490
+ fail: {
491
+ title: 'Failure',
492
+ description: 'Error deleting the file!'
493
+ }
494
+ },
495
+ uploadFile: {
496
+ success: {
497
+ title: 'Success',
498
+ description: 'File uploaded successfully!'
499
+ },
500
+ fail: {
501
+ title: 'Failure',
502
+ description: 'Error uploading the file!'
503
+ }
504
+ },
505
+ Test: {
506
+ fail: {
507
+ title: 'Failure',
508
+ description: 'Error testing Le-IA'
509
+ }
510
+ }
481
511
  }
482
512
  };
483
513
  var getLanguage = function getLanguage(language) {
@@ -518,7 +548,35 @@ var getLanguage = function getLanguage(language) {
518
548
  title: 'Sem dados para análise',
519
549
  description: 'Faça uma pesquisa, clique no botão "Teste".'
520
550
  })
521
- })
551
+ }),
552
+ toast: {
553
+ deleteFile: {
554
+ success: {
555
+ title: 'Sucesso',
556
+ description: 'Arquivo deletado com sucesso!'
557
+ },
558
+ fail: {
559
+ title: 'Falha',
560
+ description: 'Erro ao deletar o arquivo!'
561
+ }
562
+ },
563
+ uploadFile: {
564
+ success: {
565
+ title: 'Sucesso',
566
+ description: 'Arquivo enviado com sucesso!'
567
+ },
568
+ fail: {
569
+ title: 'Falha',
570
+ description: 'Erro ao enviar o arquivo!'
571
+ }
572
+ },
573
+ Test: {
574
+ fail: {
575
+ title: 'Falha',
576
+ description: 'Erro ao testar a Le-IA'
577
+ }
578
+ }
579
+ }
522
580
  },
523
581
  es: _extends({}, defaultLanguage, {
524
582
  files: 'Archivos',
@@ -554,20 +612,50 @@ var getLanguage = function getLanguage(language) {
554
612
  title: 'Sin datos para el análisis',
555
613
  description: 'Realiza una búsqueda, haz clic en el botón "Prueba".'
556
614
  })
557
- })
615
+ }),
616
+ toast: {
617
+ deleteFile: {
618
+ success: {
619
+ title: 'Éxito',
620
+ description: '¡Archivo eliminado correctamente!'
621
+ },
622
+ fail: {
623
+ title: 'Fallo',
624
+ description: 'Error al eliminar el archivo!'
625
+ }
626
+ },
627
+ uploadFile: {
628
+ success: {
629
+ title: 'Éxito',
630
+ description: '¡Archivo subido correctamente!'
631
+ },
632
+ fail: {
633
+ title: 'Fallo',
634
+ description: 'Error al subir el archivo!'
635
+ }
636
+ },
637
+ Test: {
638
+ fail: {
639
+ title: 'Fallo',
640
+ description: 'Error al probar Le-IA'
641
+ }
642
+ }
643
+ }
558
644
  })
559
645
  };
560
646
  return languages[language] || defaultLanguage;
561
647
  };
562
648
 
563
- var _templateObject$1, _templateObject2$1;
564
- 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 .delete {\n background: #871821;\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"])));
565
- 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"])));
649
+ var _templateObject$1, _templateObject2$1, _templateObject3;
650
+ var Container = /*#__PURE__*/styled.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n\n\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 .delete {\n background: #871821;\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"])), function (props) {
651
+ return props.isLoading && css(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n #loading {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: #979aa5;\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n }\n\n #loading::after {\n content: \"\";\n border: 4px solid #f3f3f3; /* Cor do s\xEDmbolo de carregamento */\n border-top: 4px solid #3498db; /* Cor do s\xEDmbolo de carregamento */\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "])));
652
+ });
653
+ var Header = /*#__PURE__*/styled.div(_templateObject3 || (_templateObject3 = /*#__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"])));
566
654
 
567
- var _templateObject$2, _templateObject2$2, _templateObject3;
655
+ var _templateObject$2, _templateObject2$2, _templateObject3$1;
568
656
  var TableWrapper = /*#__PURE__*/styled.div(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n height: max-content;\n min-height: 50px;\n position: relative;\n"])));
569
657
  var Table = /*#__PURE__*/styled.table(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 14px;\n line-height: 143%;\n color: black;\n width: 100%;\n border-collapse: collapse;\n border-radius: 4px;\n\n th {\n font-weight: 600;\n font-size: 14px;\n line-height: 143%;\n letter-spacing: 0.018em;\n color: #5A5D68;\n text-align: left;\n padding: 8px;\n border-radius: 4px;\n }\n\n thead tr {\n background: #dadce3;\n }\n\n tbody tr {\n border: 1px solid #dadce3;\n }\n\n &.small td {\n padding: 4px;\n }\n\n &.medium td {\n padding: 8px;\n }\n\n &.large td {\n padding: 16px;\n }\n"])));
570
- var TableLoadingWrapper = /*#__PURE__*/styled.div(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #f3f5f961;\n"])));
658
+ var TableLoadingWrapper = /*#__PURE__*/styled.div(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #f3f5f961;\n"])));
571
659
 
572
660
  var _templateObject$3;
573
661
  var SpinnerWrapper = /*#__PURE__*/styled.span(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-block;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n\n &.spinner--sm {\n width: 24px;\n height: 24px;\n }\n\n &.spinner--md {\n width: 32px;\n height: 32px;\n }\n\n &.spinner--lg {\n width: 60px;\n height: 60px;\n }\n\n span {\n box-sizing: border-box;\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n margin: 8px;\n border: 4px solid #fff;\n border-radius: 50%;\n animation: rotateSpinner 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n border-color: ", " transparent transparent\n transparent;\n }\n\n & span:nth-child(1) {\n animation-delay: -0.45s;\n }\n\n & span:nth-child(2) {\n animation-delay: -0.3s;\n }\n\n & span:nth-child(3) {\n animation-delay: -0.15s;\n }\n\n @keyframes rotateSpinner {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"])), function (props) {
@@ -651,7 +739,7 @@ var SearchInput = function SearchInput(_ref) {
651
739
  }, React.createElement(FaSearch, null)));
652
740
  };
653
741
 
654
- var _templateObject$4, _templateObject2$3, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
742
+ var _templateObject$4, _templateObject2$3, _templateObject3$2, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
655
743
  var FullScreen = /*#__PURE__*/styled.div(_templateObject$4 || (_templateObject$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n cursor: ", ";\n\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n justify-content: center;\n align-items: center;\n z-index: ", ";\n animation: fadeIn 380ms ease-in-out 1;\n background-color: #2f3845b8;\n backdrop-filter: blur(2px);\n\n @keyframes fadeIn {\n from {\n background-color: #2f384521;\n }\n to {\n background-color: #2f3845b8;\n }\n }\n"])), function (_ref) {
656
744
  var isOpen = _ref.isOpen;
657
745
  return isOpen === 1 ? 'flex' : 'none';
@@ -666,7 +754,7 @@ var Modal = /*#__PURE__*/styled.div(_templateObject2$3 || (_templateObject2$3 =
666
754
  var maxWidth = _ref4.maxWidth;
667
755
  return maxWidth;
668
756
  });
669
- var ModalContainer = /*#__PURE__*/styled.div(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n overflow-y: auto;\n max-height: ", ";\n"])), function (_ref5) {
757
+ var ModalContainer = /*#__PURE__*/styled.div(_templateObject3$2 || (_templateObject3$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n overflow-y: auto;\n max-height: ", ";\n"])), function (_ref5) {
670
758
  var maxHeight = _ref5.maxHeight;
671
759
  return maxHeight;
672
760
  });
@@ -1114,7 +1202,13 @@ var Types = {
1114
1202
  UPLOAD_FILES_REQUEST: 'UPLOAD_FILES_REQUEST',
1115
1203
  UPLOAD_FILES_SUCCESS: 'UPLOAD_FILES_SUCCESS',
1116
1204
  TEST_REQUEST: 'TEST_REQUEST',
1117
- TEST_SUCCESS: 'TEST_SUCCESS'
1205
+ TEST_SUCCESS: 'TEST_SUCCESS',
1206
+ LOADING_START: 'LOADING_START',
1207
+ LOADING_FINISH: 'LOADING_FINISH',
1208
+ CHANGING_START: 'CHANGING_START',
1209
+ CHANGING_FINISH: 'CHANGING_FINISH',
1210
+ NETWORK_ONLINE: 'NETWORK_ONLINE',
1211
+ NETWORK_OFFLINE: 'NETWORK_OFFLINE'
1118
1212
  };
1119
1213
 
1120
1214
  var getFilesAction = function getFilesAction(id) {
@@ -1134,12 +1228,13 @@ var getFilesActionSuccess = function getFilesActionSuccess(_ref) {
1134
1228
  }
1135
1229
  };
1136
1230
  };
1137
- var deleteFilesAction = function deleteFilesAction(name, id) {
1231
+ var deleteFilesAction = function deleteFilesAction(name, id, language) {
1138
1232
  return {
1139
1233
  type: Types.DELETE_FILES_REQUEST,
1140
1234
  payload: {
1141
1235
  name: name,
1142
- id: id
1236
+ id: id,
1237
+ language: language
1143
1238
  }
1144
1239
  };
1145
1240
  };
@@ -1152,13 +1247,14 @@ var deleteFilesActionSuccess = function deleteFilesActionSuccess(_ref2) {
1152
1247
  }
1153
1248
  };
1154
1249
  };
1155
- var uploadFilesAction = function uploadFilesAction(file, id, pressets) {
1250
+ var uploadFilesAction = function uploadFilesAction(file, id, pressets, language) {
1156
1251
  return {
1157
1252
  type: Types.UPLOAD_FILES_REQUEST,
1158
1253
  payload: {
1159
1254
  file: file,
1160
1255
  id: id,
1161
- pressets: pressets
1256
+ pressets: pressets,
1257
+ language: language
1162
1258
  }
1163
1259
  };
1164
1260
  };
@@ -1191,6 +1287,16 @@ var testActionSuccess = function testActionSuccess(_ref4) {
1191
1287
  }
1192
1288
  };
1193
1289
  };
1290
+ var commonLoadingStart = function commonLoadingStart() {
1291
+ return {
1292
+ type: Types.LOADING_START
1293
+ };
1294
+ };
1295
+ var commonLoadingFinish = function commonLoadingFinish() {
1296
+ return {
1297
+ type: Types.LOADING_FINISH
1298
+ };
1299
+ };
1194
1300
 
1195
1301
  var FileArea = function FileArea() {
1196
1302
  var _useSharedProps = useSharedProps(),
@@ -1224,6 +1330,9 @@ var FileArea = function FileArea() {
1224
1330
  var initFiles = useSelector(function (state) {
1225
1331
  return state.files;
1226
1332
  });
1333
+ var isLoading = useSelector(function (state) {
1334
+ return state.isLoading;
1335
+ });
1227
1336
  var tags = propTags ? propTags.tags : [];
1228
1337
  useEffect(function () {
1229
1338
  dispatch(getFilesAction(id));
@@ -1232,6 +1341,8 @@ var FileArea = function FileArea() {
1232
1341
  if (!!initFiles) {
1233
1342
  setFiles(initFiles);
1234
1343
  setInitialFiles(initFiles);
1344
+ setModal(false);
1345
+ setModalDelete(false);
1235
1346
  }
1236
1347
  }, [initFiles]);
1237
1348
  var optionsPresset = tags.map(function (tag) {
@@ -1256,13 +1367,17 @@ var FileArea = function FileArea() {
1256
1367
  setModalDelete(!modalDelete);
1257
1368
  };
1258
1369
  var deleteFile = function deleteFile() {
1259
- dispatch(deleteFilesAction(fileDelete, id));
1370
+ dispatch(deleteFilesAction(fileDelete, id, language));
1260
1371
  };
1261
1372
  var handleUploadFile = function handleUploadFile() {
1262
- dispatch(uploadFilesAction(uploadFile, id, [presset]));
1373
+ dispatch(uploadFilesAction(uploadFile, id, [presset], language));
1263
1374
  };
1264
1375
  var renderFiles = function renderFiles() {
1265
- return React.createElement(Container, null, React.createElement(Header, null, React.createElement("div", {
1376
+ return React.createElement(Container, {
1377
+ isLoading: isLoading
1378
+ }, React.createElement("div", {
1379
+ id: 'loading'
1380
+ }), React.createElement(Header, null, React.createElement("div", {
1266
1381
  className: 'infos'
1267
1382
  }, React.createElement("h2", null, t.files), React.createElement("p", null, t.fileArea.description)), React.createElement("div", {
1268
1383
  className: 'actions'
@@ -1364,16 +1479,16 @@ var FileArea = function FileArea() {
1364
1479
  }, React.createElement(Container, null, renderFiles()));
1365
1480
  };
1366
1481
 
1367
- var _templateObject$8, _templateObject2$4, _templateObject3$2, _templateObject4$1;
1482
+ var _templateObject$8, _templateObject2$4, _templateObject3$3, _templateObject4$1;
1368
1483
  var Container$4 = /*#__PURE__*/styled.div(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\n"])));
1369
1484
  var Header$1 = /*#__PURE__*/styled.div(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\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"])));
1370
- var Inputs = /*#__PURE__*/styled.div(_templateObject3$2 || (_templateObject3$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n\n button {\n background: #102693;\n padding: 10px 20px;\n color: white;\n border-radius: 4px;\n width: 190px;\n height: 40px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: 23px;\n height: 23px;\n }\n }\n"])));
1485
+ var Inputs = /*#__PURE__*/styled.div(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n\n button {\n background: #102693;\n padding: 10px 20px;\n color: white;\n border-radius: 4px;\n width: 190px;\n height: 40px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: 23px;\n height: 23px;\n }\n }\n"])));
1371
1486
  var Result = /*#__PURE__*/styled.div(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: left;\n background: #F3F5F9;\n padding: 15px;\n border-radius: 5px;\n margin-top: 15px;\n\n .text{\n margin-left: 5px;\n font-size: 14px;\n line-height: 1.5;\n }\n\n .icon {\n display: flex;\n justify-content: center;\n align-items: center;\n margin-right: 5px;\n\n svg {\n width: 35px;\n height: 35px;\n }\n }\n\n"])));
1372
1487
 
1373
- var _templateObject$9, _templateObject2$5, _templateObject3$3, _templateObject4$2;
1488
+ var _templateObject$9, _templateObject2$5, _templateObject3$4, _templateObject4$2;
1374
1489
  var Container$5 = /*#__PURE__*/styled.div(_templateObject$9 || (_templateObject$9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 100%;\n margin-right: 5px;\n"])));
1375
1490
  var StyledInput = /*#__PURE__*/styled.input(_templateObject2$5 || (_templateObject2$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding-left: 10px;\n padding-right: 40px;\n border-radius: 5px;\n border: 1px solid #ccc;\n height: 40px;\n width: 100%;\n\n &:focus {\n outline: none;\n box-shadow: 0 0 0 3px #6690ff;\n }\n"])));
1376
- var RecordAudioButton = /*#__PURE__*/styled.div(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 10px;\n right: 10px;\n cursor: pointer;\n"])));
1491
+ var RecordAudioButton = /*#__PURE__*/styled.div(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 10px;\n right: 10px;\n cursor: pointer;\n"])));
1377
1492
  var StyledMicrophoneIcon = /*#__PURE__*/styled(FaMicrophone)(_templateObject4$2 || (_templateObject4$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n pointer-events: none;\n"])));
1378
1493
 
1379
1494
  var InputTest = function InputTest(_ref) {
@@ -1517,7 +1632,10 @@ var Leia = function Leia(props) {
1517
1632
 
1518
1633
  var INITIAL_STATE = {
1519
1634
  files: [],
1520
- message: ''
1635
+ message: '',
1636
+ isLoading: false,
1637
+ isChanging: false,
1638
+ isOffline: true
1521
1639
  };
1522
1640
  function filesReducer(state, action) {
1523
1641
  if (state === void 0) {
@@ -1534,12 +1652,76 @@ function filesReducer(state, action) {
1534
1652
  case Types.TEST_SUCCESS:
1535
1653
  draft.message = action.payload.message;
1536
1654
  break;
1655
+ case Types.LOADING_START:
1656
+ draft.isLoading = true;
1657
+ break;
1658
+ case Types.LOADING_FINISH:
1659
+ draft.isLoading = false;
1660
+ break;
1661
+ case Types.CHANGING_START:
1662
+ draft.isChanging = true;
1663
+ break;
1664
+ case Types.CHANGING_FINISH:
1665
+ draft.isChanging = false;
1666
+ break;
1667
+ case Types.NETWORK_ONLINE:
1668
+ draft.isOffline = false;
1669
+ break;
1670
+ case Types.NETWORK_OFFLINE:
1671
+ draft.isOffline = true;
1672
+ break;
1537
1673
  default:
1538
1674
  return action.payload;
1539
1675
  }
1540
1676
  });
1541
1677
  }
1542
1678
 
1679
+ var CustomToastContent = function CustomToastContent(_ref) {
1680
+ var title = _ref.title,
1681
+ description = _ref.description;
1682
+ return React.createElement(React.Fragment, null, React.createElement("div", {
1683
+ className: "custom-toastify-content"
1684
+ }, React.createElement("strong", {
1685
+ className: "custom-toastify-title"
1686
+ }, title), description && React.createElement("p", {
1687
+ className: "custom-toastify-description"
1688
+ }, description)));
1689
+ };
1690
+ var toast = {
1691
+ "default": function _default(_ref2) {
1692
+ var title = _ref2.title,
1693
+ description = _ref2.description;
1694
+ return toast$1(React.createElement(CustomToastContent, {
1695
+ title: title,
1696
+ description: description
1697
+ }));
1698
+ },
1699
+ success: function success(_ref3) {
1700
+ var title = _ref3.title,
1701
+ description = _ref3.description;
1702
+ return toast$1.success(React.createElement(CustomToastContent, {
1703
+ title: title,
1704
+ description: description
1705
+ }));
1706
+ },
1707
+ error: function error(_ref4) {
1708
+ var title = _ref4.title,
1709
+ description = _ref4.description;
1710
+ return toast$1.error(React.createElement(CustomToastContent, {
1711
+ title: title,
1712
+ description: description
1713
+ }));
1714
+ },
1715
+ warn: function warn(_ref5) {
1716
+ var title = _ref5.title,
1717
+ description = _ref5.description;
1718
+ return toast$1.warn(React.createElement(CustomToastContent, {
1719
+ title: title,
1720
+ description: description
1721
+ }));
1722
+ }
1723
+ };
1724
+
1543
1725
  var _marked = /*#__PURE__*/_regeneratorRuntime().mark(getFilesSaga),
1544
1726
  _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(deleteFilesSaga),
1545
1727
  _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(testSaga),
@@ -1575,36 +1757,51 @@ function getFilesSaga(action) {
1575
1757
  }, _marked, null, [[0, 10]]);
1576
1758
  }
1577
1759
  function deleteFilesSaga(action) {
1578
- var _action$payload, id, name, _yield$call2, data;
1760
+ var t, _action$payload, id, name, _yield$call2, data;
1579
1761
  return _regeneratorRuntime().wrap(function deleteFilesSaga$(_context2) {
1580
1762
  while (1) switch (_context2.prev = _context2.next) {
1581
1763
  case 0:
1582
- _context2.prev = 0;
1583
- _action$payload = action.payload, id = _action$payload.id, name = _action$payload.name;
1764
+ t = getLanguage(action.payload.language);
1765
+ _context2.prev = 1;
1584
1766
  _context2.next = 4;
1585
- return call(api["delete"], "/delete/" + id + "/" + name);
1767
+ return put(commonLoadingStart());
1586
1768
  case 4:
1587
- _context2.next = 6;
1769
+ _action$payload = action.payload, id = _action$payload.id, name = _action$payload.name;
1770
+ _context2.next = 7;
1771
+ return call(api["delete"], "/delete/" + id + "/" + name);
1772
+ case 7:
1773
+ _context2.next = 9;
1588
1774
  return call(api.get, "/files/" + id);
1589
- case 6:
1775
+ case 9:
1590
1776
  _yield$call2 = _context2.sent;
1591
1777
  data = _yield$call2.data;
1592
- _context2.next = 10;
1778
+ _context2.next = 13;
1593
1779
  return put(deleteFilesActionSuccess({
1594
- files: data.files
1780
+ files: data.files,
1781
+ success: true
1595
1782
  }));
1596
- case 10:
1597
- _context2.next = 15;
1783
+ case 13:
1784
+ _context2.next = 19;
1598
1785
  break;
1599
- case 12:
1600
- _context2.prev = 12;
1601
- _context2.t0 = _context2["catch"](0);
1602
- console.log('-----------deleteFilesSaga.error------------------->', _context2.t0);
1603
1786
  case 15:
1787
+ _context2.prev = 15;
1788
+ _context2.t0 = _context2["catch"](1);
1789
+ toast.error({
1790
+ title: t.toast.deleteFile.fail.title,
1791
+ description: t.toast.deleteFile.fail.description
1792
+ });
1793
+ console.log('-----------deleteFilesSaga.error------------------->', _context2.t0);
1794
+ case 19:
1795
+ _context2.prev = 19;
1796
+ _context2.next = 22;
1797
+ return put(commonLoadingFinish());
1798
+ case 22:
1799
+ return _context2.finish(19);
1800
+ case 23:
1604
1801
  case "end":
1605
1802
  return _context2.stop();
1606
1803
  }
1607
- }, _marked2, null, [[0, 12]]);
1804
+ }, _marked2, null, [[1, 15, 19, 23]]);
1608
1805
  }
1609
1806
  function testSaga(action) {
1610
1807
  var _action$payload2, question, profile, presset, files_directory, _yield$call3, data;
@@ -1641,11 +1838,15 @@ function testSaga(action) {
1641
1838
  }, _marked3, null, [[0, 10]]);
1642
1839
  }
1643
1840
  function uploadFilesSaga(action) {
1644
- var _action$payload3, id, file, pressets, tags, blob, formData, queryParams, _yield$call4, data;
1841
+ var t, _action$payload3, id, file, pressets, tags, blob, formData, queryParams, _yield$call4, data;
1645
1842
  return _regeneratorRuntime().wrap(function uploadFilesSaga$(_context4) {
1646
1843
  while (1) switch (_context4.prev = _context4.next) {
1647
1844
  case 0:
1648
- _context4.prev = 0;
1845
+ t = getLanguage(action.payload.language);
1846
+ _context4.prev = 1;
1847
+ _context4.next = 4;
1848
+ return put(commonLoadingStart());
1849
+ case 4:
1649
1850
  _action$payload3 = action.payload, id = _action$payload3.id, file = _action$payload3.file, pressets = _action$payload3.pressets;
1650
1851
  tags = pressets.join(',');
1651
1852
  blob = new Blob([file.content]);
@@ -1654,34 +1855,44 @@ function uploadFilesSaga(action) {
1654
1855
  queryParams = new URLSearchParams({
1655
1856
  tags: tags
1656
1857
  }).toString();
1657
- _context4.next = 9;
1858
+ _context4.next = 12;
1658
1859
  return call(api.post, "/upload/" + id + "?" + queryParams, formData, {
1659
1860
  headers: {
1660
1861
  'Content-Type': 'multipart/form-data'
1661
1862
  }
1662
1863
  });
1663
- case 9:
1664
- _context4.next = 11;
1864
+ case 12:
1865
+ _context4.next = 14;
1665
1866
  return call(api.get, "/files/" + id);
1666
- case 11:
1867
+ case 14:
1667
1868
  _yield$call4 = _context4.sent;
1668
1869
  data = _yield$call4.data;
1669
- _context4.next = 15;
1870
+ _context4.next = 18;
1670
1871
  return put(uploadFilesActionSuccess({
1671
1872
  files: data.files
1672
1873
  }));
1673
- case 15:
1674
- _context4.next = 20;
1874
+ case 18:
1875
+ _context4.next = 24;
1675
1876
  break;
1676
- case 17:
1677
- _context4.prev = 17;
1678
- _context4.t0 = _context4["catch"](0);
1679
- console.log('-----------uploadFilesSaga.error------------------->', _context4.t0);
1680
1877
  case 20:
1878
+ _context4.prev = 20;
1879
+ _context4.t0 = _context4["catch"](1);
1880
+ toast.error({
1881
+ title: t.toast.uploadFile.fail.title,
1882
+ description: t.toast.uploadFile.fail.description
1883
+ });
1884
+ console.log('-----------uploadFilesSaga.error------------------->', _context4.t0);
1885
+ case 24:
1886
+ _context4.prev = 24;
1887
+ _context4.next = 27;
1888
+ return put(commonLoadingFinish());
1889
+ case 27:
1890
+ return _context4.finish(24);
1891
+ case 28:
1681
1892
  case "end":
1682
1893
  return _context4.stop();
1683
1894
  }
1684
- }, _marked4, null, [[0, 17]]);
1895
+ }, _marked4, null, [[1, 20, 24, 28]]);
1685
1896
  }
1686
1897
  function filesSagas() {
1687
1898
  return _regeneratorRuntime().wrap(function filesSagas$(_context5) {