(id)
| 175 | |
| 176 | // user details |
| 177 | export const userDetails = (id) => async (dispatch, getState) => { |
| 178 | |
| 179 | try { |
| 180 | |
| 181 | dispatch({ |
| 182 | type: USER_DETAILS_REQUEST |
| 183 | }) |
| 184 | |
| 185 | const { |
| 186 | userLoginReducer: { userInfo } |
| 187 | } = getState() |
| 188 | |
| 189 | const config = { |
| 190 | headers: { |
| 191 | "Content-Type": "application/json", |
| 192 | Authorization: `Bearer ${userInfo.token}` |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // call api |
| 197 | const { data } = await axios.get(`/account/user/${id}`, config) |
| 198 | |
| 199 | dispatch({ |
| 200 | type: USER_DETAILS_SUCCESS, |
| 201 | payload: data |
| 202 | }) |
| 203 | |
| 204 | } catch (error) { |
| 205 | dispatch({ |
| 206 | type: USER_DETAILS_FAIL, |
| 207 | payload: error.response && error.response.data.details ? error.response.data.details : error.message |
| 208 | }) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // user update details |
| 213 | export const userUpdateDetails = (userData) => async (dispatch, getState) => { |
no test coverage detected