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.
- package/dist/code7-leia.cjs.development.js +93 -22
- package/dist/code7-leia.cjs.development.js.map +1 -1
- package/dist/code7-leia.cjs.production.min.js +1 -1
- package/dist/code7-leia.cjs.production.min.js.map +1 -1
- package/dist/code7-leia.esm.js +93 -22
- package/dist/code7-leia.esm.js.map +1 -1
- package/dist/components/FileArea/components/AreaUpload/index.d.ts +1 -0
- package/dist/interface/Language.d.ts +1 -0
- package/dist/store/modules/actions.d.ts +14 -0
- package/dist/store/modules/sagas.d.ts +8 -0
- package/dist/store/modules/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/FileArea/components/AreaUpload/index.tsx +7 -1
- package/src/components/FileArea/index.tsx +13 -12
- package/src/components/FileArea/styles.tsx +5 -0
- package/src/components/TestArea/styles.tsx +1 -0
- package/src/interface/Language.ts +1 -0
- package/src/store/modules/actions.ts +14 -0
- package/src/store/modules/sagas.ts +25 -1
- package/src/store/modules/types.ts +2 -0
- package/src/utils/getLanguage.tsx +3 -0
|
@@ -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
|
|
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
|
|
76
|
-
console.log(
|
|
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:
|
|
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={
|
|
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={
|
|
167
|
-
title={t.fileArea.modal.
|
|
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
|
|
177
|
+
<button className='button delete' type="submit" form="form-tts" onClick={deleteFile}>
|
|
177
178
|
{t.buttons.delete}
|
|
178
179
|
</button>
|
|
179
180
|
</ModalFooter>
|
|
@@ -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
|
},
|