Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { completeAction, createActionThunk, startAction } from "../../../redux"; import { getIndexedAction } from "../../../redux/utils"; import api from "../api"; import { GET_PROFILE_ACTION, GET_USER_DETAILS_ACTION, GET_USER_ORGS_ACTION, LOGIN_ACTION, LOGOUT_ACTION, SET_NEXT_PAGE_ACTION, CLEAR_NEXT_PAGE_ACTION } from "./actionTypes"; const loginAction = createActionThunk(LOGIN_ACTION, api.login); const getProfileAction = createActionThunk(GET_PROFILE_ACTION, api.getProfile); const getUserOrgsAction = createActionThunk( GET_USER_ORGS_ACTION, api.getUserOrgs ); const getUserDetailsAction = () => { return async (dispatch: Function) => { dispatch(startAction(GET_USER_DETAILS_ACTION)); let [userProfile] = await Promise.all([dispatch(getProfileAction())]); let [userOrgs] = await Promise.all([ dispatch(getUserOrgsAction(userProfile.username)) ]); if (!(userProfile || userOrgs)) dispatch({ type: LOGOUT_ACTION }); dispatch(completeAction(GET_USER_DETAILS_ACTION)); }; }; const setNextPageAction = (nextPage: string) => { return async (dispatch: Function) => { const action = getIndexedAction(SET_NEXT_PAGE_ACTION); dispatch({ type: action.actionType, index: action.actionIndex, payload: nextPage }); }; }; const clearNextPageAction = () => { return (dispatch: Function) => { const { actionType, actionIndex } = getIndexedAction( CLEAR_NEXT_PAGE_ACTION ); dispatch({ type: actionType, index: actionIndex }); }; }; export { loginAction, getUserDetailsAction, getProfileAction, setNextPageAction, clearNextPageAction }; |