(addressData)
| 375 | |
| 376 | // create user address |
| 377 | export const createUserAddress = (addressData) => async (dispatch, getState) => { |
| 378 | |
| 379 | try { |
| 380 | dispatch({ |
| 381 | type: CREATE_USER_ADDRESS_REQUEST |
| 382 | }) |
| 383 | |
| 384 | const { |
| 385 | userLoginReducer: { userInfo } |
| 386 | } = getState() |
| 387 | |
| 388 | const config = { |
| 389 | headers: { |
| 390 | "Content-Type": "application/json", |
| 391 | Authorization: `Bearer ${userInfo.token}` |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | // call api |
| 396 | const { data } = await axios.post( |
| 397 | "/account/create-address/", |
| 398 | addressData, |
| 399 | config |
| 400 | ) |
| 401 | |
| 402 | dispatch({ |
| 403 | type: CREATE_USER_ADDRESS_SUCCESS, |
| 404 | payload: data |
| 405 | }) |
| 406 | |
| 407 | } catch (error) { |
| 408 | dispatch({ |
| 409 | type: CREATE_USER_ADDRESS_FAIL, |
| 410 | payload: error.response && error.response.data.details ? error.response.data.details : error.message |
| 411 | }) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | |
| 416 | // update user address |
no test coverage detected