code7-leia 0.1.105 → 0.1.107

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.
@@ -27,6 +27,7 @@ export const FileArea = () => {
27
27
  const [modal, setModal] = useState(false)
28
28
  const [modalDelete, setModalDelete] = useState(false)
29
29
  const [fileDelete, setFileDelete] = useState('')
30
+ const [presset, setPresset] = useState('');
30
31
  const t = getLanguage(language)
31
32
  const dispatch = useDispatch();
32
33
  const initFiles = useSelector((state: any) => state.files);
@@ -47,7 +48,7 @@ export const FileArea = () => {
47
48
  return { label: tag, value: tag }
48
49
  })
49
50
 
50
- const presset = (tags: string) => {
51
+ const pressetTag = (tags: string) => {
51
52
  const tagsSplit = tags.split(',');
52
53
  let html = '';
53
54
 
@@ -72,9 +73,8 @@ export const FileArea = () => {
72
73
  dispatch(deleteFilesAction(fileDelete, id))
73
74
  }
74
75
 
75
- const handleSelect = (value: string | number) => {
76
- console.log(value);
77
- console.log(uploadFile);
76
+ const handleUploadFile = () => {
77
+ console.log('uploadFile: ', uploadFile, 'presset: ', presset, 'id: ', id);
78
78
  };
79
79
 
80
80
  const renderFiles = () => {
@@ -120,7 +120,7 @@ export const FileArea = () => {
120
120
  {files.map((object) => (
121
121
  <tr>
122
122
  <td>{object.name}</td>
123
- <td className='tags' dangerouslySetInnerHTML={{ __html: presset(object.tags) }} />
123
+ <td className='tags' dangerouslySetInnerHTML={{ __html: pressetTag(object.tags) }} />
124
124
  <td>
125
125
  <div className='divDelete'>
126
126
  <button className='buttonDelete' onClick={() => handleOpenModalDelete(object.name)}>{t.buttons.delete}</button>
@@ -131,7 +131,7 @@ export const FileArea = () => {
131
131
  </tbody>
132
132
  </Table>
133
133
  }
134
- <Modal
134
+ <Modal
135
135
  isOpen={modal}
136
136
  maxWidth="600px"
137
137
  maxHeight="max-content"
@@ -142,29 +142,30 @@ export const FileArea = () => {
142
142
  <div className='choose-file'>
143
143
  <AreaUpload
144
144
  setFile={setUploadFile}
145
+ file={uploadFile?.properties.name}
145
146
  />
146
147
  </div>
147
148
  <div className='presset'>
148
149
  <p>Presset</p>
149
- <Select placeholder={t.testArea.selectPresset} options={optionsPresset} onSelect={handleSelect} />
150
+ <Select placeholder={t.testArea.selectPresset} options={optionsPresset} onSelect={setPresset} />
150
151
  </div>
151
152
  </ModalContent>
152
153
  <ModalFooter>
153
154
  <button className='button cancel' onClick={handleOpenModal}>
154
155
  {t.buttons.cancel}
155
156
  </button>
156
- <button className='button send' type="submit" form="form-tts">
157
+ <button onClick={() => handleUploadFile()} className='button send' type="submit" form="form-tts">
157
158
  {t.buttons.send}
158
159
  </button>
159
160
  </ModalFooter>
160
161
 
161
162
  </Modal>
162
- <Modal
163
+ <Modal
163
164
  isOpen={modalDelete}
164
165
  maxWidth="600px"
165
166
  maxHeight="max-content"
166
- onClose={handleOpenModal}
167
- title={t.fileArea.modal.uploadFile}
167
+ onClose={() => handleOpenModalDelete('')}
168
+ title={t.fileArea.modal.deleteFileTitle}
168
169
  >
169
170
  <ModalContent>
170
171
  <p id='warning'>{t.fileArea.modal.deleteFile}</p>
@@ -173,7 +174,7 @@ export const FileArea = () => {
173
174
  <button className='button cancel' onClick={() => handleOpenModalDelete('')}>
174
175
  {t.buttons.cancel}
175
176
  </button>
176
- <button className='button send' type="submit" form="form-tts" onClick={deleteFile}>
177
+ <button className='button delete' type="submit" form="form-tts" onClick={deleteFile}>
177
178
  {t.buttons.delete}
178
179
  </button>
179
180
  </ModalFooter>
@@ -47,6 +47,11 @@ export const Container = styled.div`
47
47
  color: white;
48
48
  }
49
49
 
50
+ .delete {
51
+ background: #871821;
52
+ color: white;
53
+ }
54
+
50
55
  .presset {
51
56
  padding-top: 10px;
52
57
  display: flex;
@@ -56,6 +56,7 @@ export const Result = styled.div`
56
56
  .text{
57
57
  margin-left: 5px;
58
58
  font-size: 14px;
59
+ line-height: 1.5;
59
60
  }
60
61
 
61
62
  .icon {
@@ -13,6 +13,7 @@ type FileArea = {
13
13
  descriptionUpload: string;
14
14
  chooseFile: string;
15
15
  uploadFile: string;
16
+ deleteFileTitle: string;
16
17
  deleteFile: string;
17
18
  };
18
19
  };
@@ -28,6 +28,20 @@ export const deleteFilesActionSuccess = ({ files }: any) => {
28
28
  }
29
29
  }
30
30
 
31
+ export const uploadFilesAction = (file: any, id: string, pressets: [string]) => {
32
+ return {
33
+ type: types.UPLOAD_FILES_REQUEST,
34
+ payload: { file, id, pressets }
35
+ }
36
+ }
37
+
38
+ export const uploadFilesActionSuccess = ({ files }: any) => {
39
+ return {
40
+ type: types.UPLOAD_FILES_SUCCESS,
41
+ payload: { files }
42
+ }
43
+ }
44
+
31
45
  export const testAction = (question: string, profile: string, presset: string, files_directory: string) => {
32
46
  return {
33
47
  type: types.TEST_REQUEST,
@@ -1,7 +1,7 @@
1
1
  import { takeLatest, all, put, call } from 'redux-saga/effects';
2
2
  import api from '../../service/Api'
3
3
  import Types from './types'
4
- import { getFilesActionSuccess, deleteFilesActionSuccess, testActionSuccess } from './actions'
4
+ import { getFilesActionSuccess, deleteFilesActionSuccess, testActionSuccess, uploadFilesActionSuccess } from './actions'
5
5
 
6
6
  export function* getFilesSaga(action: any) {
7
7
  try {
@@ -34,10 +34,34 @@ export function* testSaga(action: any) {
34
34
  }
35
35
  }
36
36
 
37
+ export function* uploadFilesSaga(action: any) {
38
+ try {
39
+ const { id, file, pressets } = action.payload;
40
+ const tags = pressets.join(',');
41
+
42
+ const formData = new FormData();
43
+ formData.append('file', file);
44
+
45
+ const queryParams = new URLSearchParams({ tags }).toString();
46
+
47
+ yield call(api.post, `/upload/${id}?${queryParams}`, formData, {
48
+ headers: {
49
+ 'Content-Type': 'multipart/form-data',
50
+ },
51
+ });
52
+
53
+ const { data } = yield call(api.get, `/files/${id}`);
54
+ yield put(uploadFilesActionSuccess({ files: data.files }));
55
+ } catch (error) {
56
+ console.log('-----------uploadFilesSaga.error------------------->', error);
57
+ }
58
+ }
59
+
37
60
  export default function* filesSagas() {
38
61
  yield all([
39
62
  takeLatest(Types.GET_FILES_REQUEST, getFilesSaga),
40
63
  takeLatest(Types.DELETE_FILES_REQUEST, deleteFilesSaga),
64
+ takeLatest(Types.UPLOAD_FILES_REQUEST, uploadFilesSaga),
41
65
  takeLatest(Types.TEST_REQUEST, testSaga)
42
66
  ]);
43
67
  }
@@ -3,6 +3,8 @@ const Types = {
3
3
  GET_FILES_SUCCESS: 'GET_FILES_SUCCESS',
4
4
  DELETE_FILES_REQUEST: 'DELETE_FILES_REQUEST',
5
5
  DELETE_FILES_SUCCESS: 'DELETE_FILES_SUCCESS',
6
+ UPLOAD_FILES_REQUEST: 'UPLOAD_FILES_REQUEST',
7
+ UPLOAD_FILES_SUCCESS: 'UPLOAD_FILES_SUCCESS',
6
8
  TEST_REQUEST: 'TEST_REQUEST',
7
9
  TEST_SUCCESS: 'TEST_SUCCESS'
8
10
  };
@@ -19,6 +19,7 @@ const defaultLanguage: Language = {
19
19
  descriptionUpload: 'Drag and drop files here or',
20
20
  chooseFile: 'Choose a file',
21
21
  uploadFile: 'Upload a file',
22
+ deleteFileTitle: 'Delete a file',
22
23
  deleteFile: 'Important! By deleting this file, you will lose all its information and will not be able to recover it.'
23
24
  },
24
25
  },
@@ -62,6 +63,7 @@ export const getLanguage = (language: keyof Record<'en' | 'pt-br' | 'es', Langua
62
63
  descriptionUpload: 'Arraste e solte os arquivos aqui ou',
63
64
  chooseFile: 'Escolha um arquivo',
64
65
  uploadFile: 'Enviar um arquivo',
66
+ deleteFileTitle: 'Deletar um arquivo',
65
67
  deleteFile: 'Importante! Ao deletar esse arquivo você perderá todas as informações dele e não terá como recuperá-las.'
66
68
  },
67
69
  },
@@ -104,6 +106,7 @@ export const getLanguage = (language: keyof Record<'en' | 'pt-br' | 'es', Langua
104
106
  ...defaultLanguage.fileArea.modal,
105
107
  descriptionUpload: 'Arrastre y suelte los archivos aquí o',
106
108
  chooseFile: 'Elegir un archivo',
109
+ deleteFileTitle: 'Eliminar un archivo',
107
110
  deleteFile: '¡Importante! Al borrar este archivo perderás toda la información contenida en él y no podrás recuperarla.'
108
111
  },
109
112
  },