commit
debfcaeb1e
@ -1,30 +0,0 @@
|
|||||||
import api from '../api';
|
|
||||||
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST = 'IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST';
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS = 'IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS';
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL = 'IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL';
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofs = accountId => (dispatch, getState) => {
|
|
||||||
dispatch(fetchAccountIdentityProofsRequest(accountId));
|
|
||||||
|
|
||||||
api(getState).get(`/api/v1/accounts/${accountId}/identity_proofs`)
|
|
||||||
.then(({ data }) => dispatch(fetchAccountIdentityProofsSuccess(accountId, data)))
|
|
||||||
.catch(err => dispatch(fetchAccountIdentityProofsFail(accountId, err)));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsRequest = id => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsSuccess = (accountId, identity_proofs) => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS,
|
|
||||||
accountId,
|
|
||||||
identity_proofs,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsFail = (accountId, error) => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
|
|
||||||
accountId,
|
|
||||||
error,
|
|
||||||
});
|
|
@ -1,32 +0,0 @@
|
|||||||
import { Map as ImmutableMap } from 'immutable';
|
|
||||||
|
|
||||||
import * as actions from 'soapbox/actions/identity_proofs';
|
|
||||||
|
|
||||||
import reducer from '../identity_proofs';
|
|
||||||
|
|
||||||
describe('identity_proofs reducer', () => {
|
|
||||||
it('should return the initial state', () => {
|
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST', () => {
|
|
||||||
const state = ImmutableMap({ isLoading: false });
|
|
||||||
const action = {
|
|
||||||
type: actions.IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST,
|
|
||||||
};
|
|
||||||
expect(reducer(state, action).toJS()).toMatchObject({
|
|
||||||
isLoading: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL', () => {
|
|
||||||
const state = ImmutableMap({ isLoading: true });
|
|
||||||
const action = {
|
|
||||||
type: actions.IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
|
|
||||||
};
|
|
||||||
expect(reducer(state, action).toJS()).toMatchObject({
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,26 +0,0 @@
|
|||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
|
||||||
|
|
||||||
import {
|
|
||||||
IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST,
|
|
||||||
IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS,
|
|
||||||
IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
|
|
||||||
} from '../actions/identity_proofs';
|
|
||||||
|
|
||||||
const initialState = ImmutableMap();
|
|
||||||
|
|
||||||
export default function identityProofsReducer(state = initialState, action) {
|
|
||||||
switch (action.type) {
|
|
||||||
case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST:
|
|
||||||
return state.set('isLoading', true);
|
|
||||||
case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL:
|
|
||||||
return state.set('isLoading', false);
|
|
||||||
case IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS:
|
|
||||||
return state.update(identity_proofs => identity_proofs.withMutations(map => {
|
|
||||||
map.set('isLoading', false);
|
|
||||||
map.set('loaded', true);
|
|
||||||
map.set(action.accountId, fromJS(action.identity_proofs));
|
|
||||||
}));
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue