Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1018 | Rev 6359 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1018 Rev 5310
Línea 1... Línea 1...
1
import { axios } from "../../utils";
1
import { axios } from '../../utils'
2
import { feedActionTypes } from "./feed.types";
2
import { feedActionTypes } from './feed.types'
Línea 3... Línea 3...
3
 
3
 
4
export const setTimelineUrl = (url) => {
4
export const setTimelineUrl = (url) => {
5
  return {
5
  return {
6
    type: feedActionTypes.SET_TIMELINE_URL,
6
    type: feedActionTypes.SET_TIMELINE_URL,
7
    payload: url,
7
    payload: url
8
  };
8
  }
Línea 9... Línea 9...
9
};
9
}
10
 
10
 
11
export const loadFeeds = () => {
11
export const loadFeeds = () => {
12
  return {
12
  return {
13
    type: feedActionTypes.LOAD_FEEDS,
13
    type: feedActionTypes.LOAD_FEEDS
Línea 14... Línea 14...
14
  };
14
  }
15
};
15
}
16
 
16
 
17
export const loadFeedsSuccess = (feeds, currentPage, pages) => {
17
export const loadFeedsSuccess = (feeds, currentPage, pages) => {
18
  return {
18
  return {
19
    type: feedActionTypes.LOAD_FEEDS_SUCCESS,
19
    type: feedActionTypes.LOAD_FEEDS_SUCCESS,
Línea 20... Línea 20...
20
    payload: { feeds: feeds, currentPage: currentPage, pages: pages },
20
    payload: { feeds, currentPage, pages }
21
  };
21
  }
22
};
22
}
23
 
23
 
Línea 24... Línea 24...
24
export const addFeed = (feed, feedSharedId = '') => ({
24
export const addFeed = (feed, feedSharedId = '') => ({
25
  type: feedActionTypes.ADD_FEED,
25
  type: feedActionTypes.ADD_FEED,
26
  payload: { feed: feed, feedSharedId: feedSharedId },
26
  payload: { feed, feedSharedId }
27
});
27
})
Línea 28... Línea 28...
28
 
28
 
29
export const deleteFeed = (feedId) => ({
29
export const deleteFeed = (feedId) => ({
30
  type: feedActionTypes.DELETE_FEED,
30
  type: feedActionTypes.DELETE_FEED,
31
  payload: feedId,
31
  payload: feedId
Línea 32... Línea 32...
32
});
32
})
33
 
-
 
34
export const setCurrentPage = (page) => ({
33
 
35
  type: feedActionTypes.SET_CURRENT_PAGE,
34
export const setCurrentPage = (page) => ({
36
  payload: page,
35
  type: feedActionTypes.SET_CURRENT_PAGE,
37
});
36
  payload: page
38
 
37
})
39
export const fetchFeeds = (url, page) => {
38
 
40
  (url);
-
 
41
  return (dispatch) => {
39
export const fetchFeeds = (url, page) => {
42
    dispatch(loadFeeds());
40
  return (dispatch) => {
43
    axios
41
    dispatch(loadFeeds())
44
      .get(url + '?page=' + page)
42
    axios
45
      .then((res) => {
43
      .get(url + '?page=' + page)
46
        const resData = res.data;
44
      .then((res) => {
47
        (resData);
45
        const resData = res.data
48
        const feeds = resData.data.current.items;
46
        const feeds = resData.data.current.items
49
        const currentPage = resData.data.current.page;
47
        const currentPage = resData.data.current.page
50
        const pages = resData.data.total.pages;
48
        const pages = resData.data.total.pages
51
        if (resData.success) {
49
        if (resData.success) {
52
          dispatch(loadFeedsSuccess(feeds, currentPage, pages));
50
          dispatch(loadFeedsSuccess(feeds, currentPage, pages))
53
        }
51
        }