UNPKG

bcs-banksigners-module

Version:

# Модуль, реализующий получение сущности bankSigners

28 lines (23 loc) 1.26 kB
import { HttpError } from '@bcs/sdk/lib/sdk-core/models'; import { ApiResource } from '@bcs/sdk/lib/sdk-core/monads/api-resource'; import { createAction, Options } from '@bcs/sdk/lib/sdk-core/persistence'; import { RemoteData } from '@devexperts/remote-data-ts'; import { put, takeEvery } from 'redux-saga/effects'; import { IApiEntities, IBankSignerModuleActions, IResponseType, ISignerInfo, StorageKeys } from './types'; // tslint:disable-next-line:max-line-length export default (opts: Options<StorageKeys, IApiEntities>, actions: IBankSignerModuleActions) => { const getBankSignerAction = createAction(actions.getBankSignersConst.finish); function* getBankSignerSaga() { const result: RemoteData<HttpError<string>, ApiResource<ISignerInfo[] | null>> = yield opts.api.signersList(); yield put(getBankSignerAction(result)); } function* postBankSignerSaga(selectedBankSigner: ISignerInfo) { const result: RemoteData<HttpError<string>, ApiResource<IResponseType | null>> = yield opts.api.remoteService(selectedBankSigner); yield put(getBankSignerAction(result)); } return [ takeEvery(actions.getBankSignersConst.init, getBankSignerSaga), takeEvery(actions.postBankSignersConst.init, postBankSignerSaga), ]; };