~cytrogen/masto-fe

ref: 86ba8d3e14955841fed45b49114e06b7a3473ba4 masto-fe/app/javascript/flavours/glitch/actions/identity_proofs.js -rw-r--r-- 1.1 KiB
86ba8d3e — Claire Merge pull request #2368 from ClearlyClaire/glitch-soc/merge-upstream 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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, err) => ({
  type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
  accountId,
  err,
  skipNotFound: true,
});