(id, addressData)
| 415 | |
| 416 | // update user address |
| 417 | export const updateUserAddress = (id, addressData) => async (dispatch, getState) => { |
| 418 | try { |
| 419 | dispatch({ |
| 420 | type: UPDATE_USER_ADDRESS_REQUEST |
| 421 | }) |
| 422 | |
| 423 | const { |
| 424 | userLoginReducer: { userInfo } |
| 425 | } = getState() |
| 426 | |
| 427 | const config = { |
| 428 | headers: { |
| 429 | "Content-Type": "application/json", |
| 430 | Authorization: `Bearer ${userInfo.token}` |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | // call api |
| 435 | const { data } = await axios.put( |
| 436 | `/account/update-address/${id}/`, |
| 437 | addressData, |
| 438 | config |
| 439 | ) |
| 440 | |
| 441 | dispatch({ |
| 442 | type: UPDATE_USER_ADDRESS_SUCCESS, |
| 443 | payload: data |
| 444 | }) |
| 445 | |
| 446 | } catch (error) { |
| 447 | dispatch({ |
| 448 | type: UPDATE_USER_ADDRESS_FAIL, |
| 449 | payload: error.response && error.response.data.details ? error.response.data.details : error.message |
| 450 | }) |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | |
| 455 | // delete user address |
no test coverage detected