(id)
| 337 | |
| 338 | // get user single address |
| 339 | export const getSingleAddress = (id) => async (dispatch, getState) => { |
| 340 | try { |
| 341 | dispatch({ |
| 342 | type: GET_SINGLE_ADDRESS_REQUEST |
| 343 | }) |
| 344 | |
| 345 | const { |
| 346 | userLoginReducer: { userInfo } |
| 347 | } = getState() |
| 348 | |
| 349 | const config = { |
| 350 | headers: { |
| 351 | "Content-Type": "application/json", |
| 352 | Authorization: `Bearer ${userInfo.token}` |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // call api |
| 357 | const { data } = await axios.get( |
| 358 | `/account/address-details/${id}/`, |
| 359 | config |
| 360 | ) |
| 361 | |
| 362 | dispatch({ |
| 363 | type: GET_SINGLE_ADDRESS_SUCCESS, |
| 364 | payload: data |
| 365 | }) |
| 366 | |
| 367 | } catch (error) { |
| 368 | dispatch({ |
| 369 | type: GET_SINGLE_ADDRESS_FAIL, |
| 370 | payload: error.response && error.response.data.details ? error.response.data.details : error.message |
| 371 | }) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | |
| 376 | // create user address |
no test coverage detected