| 454 | |
| 455 | // delete user address |
| 456 | export const deleteUserAddress = (id) => async (dispatch, getState) => { |
| 457 | try { |
| 458 | dispatch({ |
| 459 | type: DELETE_USER_ADDRESS_REQUEST |
| 460 | }) |
| 461 | |
| 462 | const { |
| 463 | userLoginReducer: { userInfo } |
| 464 | } = getState() |
| 465 | |
| 466 | const config = { |
| 467 | headers: { |
| 468 | "Content-Type": "application/json", |
| 469 | Authorization: `Bearer ${userInfo.token}` |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | // call api |
| 474 | const { data } = await axios.delete( |
| 475 | `/account/delete-address/${id}/`, |
| 476 | config |
| 477 | ) |
| 478 | |
| 479 | dispatch({ |
| 480 | type: DELETE_USER_ADDRESS_SUCCESS, |
| 481 | payload: data |
| 482 | }) |
| 483 | |
| 484 | } catch (error) { |
| 485 | dispatch({ |
| 486 | type: DELETE_USER_ADDRESS_FAIL, |
| 487 | payload: error.response && error.response.data.details ? error.response.data.details : error.message |
| 488 | }) |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | // get all orders |
| 493 | export const getAllOrders = () => async (dispatch, getState) => { |