mirror of
https://github.com/plankanban/planka.git
synced 2025-07-28 17:49:43 +02:00
31 lines
719 B
JavaScript
31 lines
719 B
JavaScript
|
import { call, put } from 'redux-saga/effects';
|
||
|
|
||
|
import request from './request';
|
||
|
import { fetchUsersFailed, fetchUsersRequested, fetchUsersSucceeded } from '../../../actions';
|
||
|
import api from '../../../api';
|
||
|
|
||
|
// eslint-disable-next-line import/prefer-default-export
|
||
|
export function* fetchUsersRequest() {
|
||
|
yield put(fetchUsersRequested());
|
||
|
|
||
|
try {
|
||
|
const { items } = yield call(request, api.getUsers);
|
||
|
|
||
|
const action = fetchUsersSucceeded(items);
|
||
|
yield put(action);
|
||
|
|
||
|
return {
|
||
|
success: true,
|
||
|
payload: action.payload,
|
||
|
};
|
||
|
} catch (error) {
|
||
|
const action = fetchUsersFailed(error);
|
||
|
yield put(action);
|
||
|
|
||
|
return {
|
||
|
success: false,
|
||
|
payload: action.payload,
|
||
|
};
|
||
|
}
|
||
|
}
|