code7-leia 0.1.71 → 0.1.73

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.
@@ -1,12 +1,14 @@
1
- import { createStore, combineReducers, applyMiddleware } from 'redux';
2
- import reduxPromise from 'redux-promise';
1
+ import { createStore } from 'redux';
2
+ // import { configureStore } from '@reduxjs/toolkit'
3
+ import { persistStore } from 'redux-persist';
3
4
  import FilesReducer from './modules/Files/Files.reducer';
4
- import { FileData } from '../interface/FileData'
5
+ // import { FileData } from '../interface/FileData'
5
6
 
6
- const rootReducer = combineReducers({
7
- files: FilesReducer as unknown as [FileData],
8
- });
7
+ // const rootReducer = combineReducers({
8
+ // files: FilesReducer as unknown as [FileData],
9
+ // });
9
10
 
10
- const store = createStore(rootReducer, applyMiddleware(reduxPromise));
11
+ const store = createStore(FilesReducer);
12
+ const persistor = persistStore(store);
11
13
 
12
- export { store };
14
+ export { store, persistor };
@@ -6,4 +6,11 @@ export function getFilesAction (id: string) {
6
6
  type: types.GET_FILES_REQUEST,
7
7
  payload: getFiles(id)
8
8
  }
9
+ }
10
+
11
+ export function getFilesActionSuccess (data: []) {
12
+ return {
13
+ type: types.GET_FILES_SUCCESS,
14
+ payload: data
15
+ }
9
16
  }
@@ -1,14 +1,18 @@
1
+ import { produce } from 'immer';
2
+
1
3
  const initState = {
2
4
  files: []
3
5
  }
4
6
 
5
7
  export default function filesReducer(state = initState, action: any) {
6
- console.log('STATE: ', state)
7
- console.log('ACTION: ', action)
8
- switch (action.type) {
9
- case 'GET_FILES_SUCCESS':
10
- return action.payload;
11
- default:
12
- return action.payload;
13
- }
8
+ return produce(state, (draft: { files: []; }) => {
9
+ switch (action.type) {
10
+ case 'GET_FILES_SUCCESS':
11
+ console.log('PAYLOAD: ', action.payload)
12
+ draft.files = action.payload;
13
+ break;
14
+ default:
15
+ return action.payload;
16
+ }
17
+ });
14
18
  }
@@ -1,13 +1,11 @@
1
- import { takeLatest, all } from 'redux-saga/effects';
1
+ import { takeLatest, all, put, call } from 'redux-saga/effects';
2
2
  import api from '../../../service/Api'
3
3
  import Types from './Files.types'
4
- // import actions from './Files.actions'
4
+ import { getFilesActionSuccess } from './Files.actions'
5
5
 
6
- export const getFiles = async (id: string) => {
7
- const { data } = await api.get(`/files/${id}`)
8
- console.log('DATA ----------------------->', data)
9
- console.log('DATA.FILES ----------------------->', data.files)
10
- return data.files
6
+ export function* getFiles (id: string) {
7
+ const { data } = yield call(api.get, `/files/${id}`)
8
+ yield put(getFilesActionSuccess(data.files));
11
9
  }
12
10
 
13
11
  export default all([