code7-leia 0.1.72 → 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,4 +1,13 @@
1
1
  export declare function getFilesAction(id: string): {
2
2
  type: string;
3
- payload: Promise<any>;
3
+ payload: Generator<import("redux-saga/effects").CallEffect<unknown> | import("redux-saga/effects").PutEffect<{
4
+ type: string;
5
+ payload: [];
6
+ }>, void, {
7
+ data: any;
8
+ }>;
9
+ };
10
+ export declare function getFilesActionSuccess(data: []): {
11
+ type: string;
12
+ payload: [];
4
13
  };
@@ -1,3 +1,5 @@
1
1
  export default function filesReducer(state: {
2
2
  files: never[];
3
- } | undefined, action: any): any;
3
+ } | undefined, action: any): {
4
+ files: never[];
5
+ };
@@ -1,3 +1,8 @@
1
- export declare const getFiles: (id: string) => Promise<any>;
1
+ export declare function getFiles(id: string): Generator<import("redux-saga/effects").CallEffect<unknown> | import("redux-saga/effects").PutEffect<{
2
+ type: string;
3
+ payload: [];
4
+ }>, void, {
5
+ data: any;
6
+ }>;
2
7
  declare const _default: import("redux-saga/effects").AllEffect<import("redux-saga/effects").ForkEffect<never>>;
3
8
  export default _default;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.72",
2
+ "version": "0.1.73",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -70,6 +70,7 @@
70
70
  "@reduxjs/toolkit": "^2.2.1",
71
71
  "axios": "^1.6.7",
72
72
  "classcat": "^5.0.4",
73
+ "immer": "^10.0.4",
73
74
  "react-dropzone": "^14.2.3",
74
75
  "react-icons": "^5.0.1",
75
76
  "react-redux": "^9.1.0",
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState} from 'react';
2
- import { useDispatch } from 'react-redux';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
3
 
4
4
  import { FaUpload, FaList, FaPlus } from 'react-icons/fa';
5
5
 
@@ -27,7 +27,7 @@ export const FileArea = () => {
27
27
  const { id, language } = useSharedProps();
28
28
  const t = getLanguage(language)
29
29
  const dispatch = useDispatch();
30
- // const initFiles = useSelector((state: any) => state.files);
30
+ const initFiles = useSelector((state: any) => state.files);
31
31
  const tags = [
32
32
  "pae",
33
33
  "boteria",
@@ -41,9 +41,11 @@ export const FileArea = () => {
41
41
  dispatch(getFilesAction(id))
42
42
  }, [])
43
43
 
44
- // useEffect(() => {
45
- // console.log(initFiles)
46
- // }, [initFiles])
44
+ useEffect(() => {
45
+ console.log(initFiles)
46
+ setFiles(initFiles)
47
+ setInitialFiles(initFiles)
48
+ }, [initFiles])
47
49
 
48
50
  useEffect(() => {
49
51
  console.log('language, id: ', language, id)
@@ -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([