code7-leia 0.1.49 → 0.1.52
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 +401 -33
- 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 +403 -35
- package/dist/code7-leia.esm.js.map +1 -1
- package/dist/contexts/SharedPropsProvider.d.ts +9 -0
- package/dist/service/Api.d.ts +3 -0
- package/dist/service/Files/Files.d.ts +2 -0
- package/dist/store/Files/Files.actions.d.ts +4 -0
- package/dist/store/Files/Files.reducer.d.ts +1 -0
- package/dist/store/store.d.ts +4 -0
- package/package.json +8 -2
- package/src/Leia.tsx +21 -20
- package/src/components/FileArea/components/AreaUpload/styles.tsx +8 -0
- package/src/components/FileArea/index.tsx +15 -44
- package/src/contexts/SharedPropsProvider.tsx +29 -0
- package/src/service/Api.ts +9 -0
- package/src/service/Files/Files.ts +8 -0
- package/src/store/Files/Files.actions.ts +8 -0
- package/src/store/Files/Files.reducer.ts +8 -0
- package/src/store/store.ts +12 -0
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState} from 'react';
|
|
2
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
2
3
|
|
|
3
4
|
import { FaUpload, FaList, FaPlus } from 'react-icons/fa';
|
|
4
5
|
|
|
5
|
-
// import { formatAxios } from '../../utils/formatAxios'
|
|
6
|
-
|
|
7
|
-
import { useLocation } from 'react-router-dom';
|
|
8
|
-
|
|
9
6
|
import type { FileData } from '../../interface/FileData'
|
|
10
7
|
|
|
11
8
|
import { getLanguage } from '../../utils/getLanguage'
|
|
@@ -19,15 +16,18 @@ import ModalContent from './components/Modal/ModalContent'
|
|
|
19
16
|
import EmptyState from '../EmptyState';
|
|
20
17
|
import Select from '../Select'
|
|
21
18
|
import AreaUpload from './components/AreaUpload';
|
|
19
|
+
import { useSharedProps } from '../../contexts/SharedPropsProvider';
|
|
20
|
+
import { getFilesAction } from '../../store/Files/Files.actions';
|
|
22
21
|
|
|
23
22
|
export const FileArea = () => {
|
|
24
23
|
const [files, setFiles] = useState<FileData[]>([]);
|
|
25
24
|
const [initialFiles, setInitialFiles] = useState<FileData[]>([]);
|
|
26
25
|
const [uploadFile, setUploadFile] = useState<{ content: ArrayBuffer | string; properties: File }>();
|
|
27
|
-
const { pathname } = useLocation();
|
|
28
26
|
const [modal, setModal] = useState(false)
|
|
29
|
-
const id =
|
|
30
|
-
const t = getLanguage(
|
|
27
|
+
const { id, language } = useSharedProps();
|
|
28
|
+
const t = getLanguage(language)
|
|
29
|
+
const dispatch = useDispatch();
|
|
30
|
+
const initFiles = useSelector((state: any) => state.initFiles);
|
|
31
31
|
const tags = [
|
|
32
32
|
"pae",
|
|
33
33
|
"boteria",
|
|
@@ -37,45 +37,16 @@ export const FileArea = () => {
|
|
|
37
37
|
]
|
|
38
38
|
|
|
39
39
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
"name": "Documentação conceitual Code7_v3",
|
|
43
|
-
"tags": "boteria, code7"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"name": "PAE_Programa_Apoio_ao_Empregado",
|
|
47
|
-
"tags": "pae, vr"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"name": "Vidalink",
|
|
51
|
-
"tags": "vidalink, vr"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
|
|
55
|
-
"tags": "ebook, code7"
|
|
56
|
-
}
|
|
57
|
-
])
|
|
58
|
-
|
|
59
|
-
setInitialFiles([
|
|
60
|
-
{
|
|
61
|
-
"name": "Documentação conceitual Code7_v3",
|
|
62
|
-
"tags": "boteria, code7"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"name": "PAE_Programa_Apoio_ao_Empregado",
|
|
66
|
-
"tags": "pae, vr"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"name": "Vidalink",
|
|
70
|
-
"tags": "vidalink, vr"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
|
|
74
|
-
"tags": "ebook, code7"
|
|
75
|
-
}
|
|
76
|
-
])
|
|
40
|
+
dispatch(getFilesAction(id))
|
|
77
41
|
}, [])
|
|
78
42
|
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setFiles(initFiles)
|
|
45
|
+
setInitialFiles(initFiles)
|
|
46
|
+
}, [initFiles])
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
79
50
|
useEffect(() => {
|
|
80
51
|
console.log('files, id, t: ', files, id, t)
|
|
81
52
|
}, [files])
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
id: string;
|
|
5
|
+
language: "en" | "pt-br" | "es";
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SharedPropsContextType {
|
|
10
|
+
props: Props;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const SharedPropsContext = createContext<SharedPropsContextType | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
export const useSharedProps = () => {
|
|
16
|
+
const context = useContext(SharedPropsContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error('useSharedProps deve ser usado dentro de um SharedPropsProvider');
|
|
19
|
+
}
|
|
20
|
+
return context.props;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const SharedPropsProvider: React.FC<Props> = ({ children, ...props }) => {
|
|
24
|
+
return (
|
|
25
|
+
<SharedPropsContext.Provider value={{ props }}>
|
|
26
|
+
{children}
|
|
27
|
+
</SharedPropsContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createStore, combineReducers, applyMiddleware } from 'redux';
|
|
2
|
+
import reduxPromise from 'redux-promise';
|
|
3
|
+
import FilesReducer from './Files/Files.reducer';
|
|
4
|
+
import { FileData } from '../interface/FileData'
|
|
5
|
+
|
|
6
|
+
const rootReducer = combineReducers({
|
|
7
|
+
files: FilesReducer as unknown as [FileData],
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const store = createStore(rootReducer, applyMiddleware(reduxPromise));
|
|
11
|
+
|
|
12
|
+
export default store;
|