From 2027ec65afeee62b8925885763db6e4a382dddee Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Mon, 8 Jun 2020 14:10:50 +0700 Subject: [PATCH] added api fn to request git stats --- src/constants/api.ts | 3 +++ src/containers/node/BorisLayout/index.tsx | 2 +- src/redux/boris/api.ts | 8 ++++++++ src/redux/boris/sagas.ts | 7 ++++++- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/redux/boris/api.ts diff --git a/src/constants/api.ts b/src/constants/api.ts index c211d541..1b03bc3e 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -36,4 +36,7 @@ export const API = { EMBED: { YOUTUBE: '/embed/youtube', }, + BORIS: { + GET_GIT_LOG: 'http://vault48.org/stats/git.json', + }, }; diff --git a/src/containers/node/BorisLayout/index.tsx b/src/containers/node/BorisLayout/index.tsx index a51f0cd7..80730939 100644 --- a/src/containers/node/BorisLayout/index.tsx +++ b/src/containers/node/BorisLayout/index.tsx @@ -119,7 +119,7 @@ const BorisLayoutUnconnected: FC = ({

Здесь мы сидим и слушаем всё, что вас беспокоит.

-

А потом чиним долгими дождливыми вечерами.

+

Все виновные будут наказаны. Невиновные, впрочем, тоже. Такова жизнь.

{/* diff --git a/src/redux/boris/api.ts b/src/redux/boris/api.ts new file mode 100644 index 00000000..a1c59be4 --- /dev/null +++ b/src/redux/boris/api.ts @@ -0,0 +1,8 @@ +import Axios from 'axios'; +import { API } from '~/constants/api'; +import { resultMiddleware, errorMiddleware } from '~/utils/api'; + +export const getBorisGitStats = (): Promise => + Axios.get(API.BORIS.GET_GIT_LOG) + .then(resultMiddleware) + .catch(errorMiddleware); diff --git a/src/redux/boris/sagas.ts b/src/redux/boris/sagas.ts index e5f8ed9c..74523d7a 100644 --- a/src/redux/boris/sagas.ts +++ b/src/redux/boris/sagas.ts @@ -1,9 +1,14 @@ -import { takeLatest, put } from 'redux-saga/effects'; +import { takeLatest, put, call } from 'redux-saga/effects'; import { BORIS_ACTIONS } from './constants'; import { borisSet } from './actions'; +import { getBorisGitStats } from './api'; function* loadStats() { yield put(borisSet({ is_loading: true })); + + const result = yield getBorisGitStats(); + console.log(result); + yield put(borisSet({ is_loading: false })); }