use custom user endpoint for validation and JWT auth for login
This commit is contained in:
@@ -29,36 +29,15 @@ export const recieveProfileInfo = (json) => ({
|
||||
export const fetchProfileInfo = (idUser) => {
|
||||
return dispatch => {
|
||||
dispatch(requestProfileInfo());
|
||||
|
||||
dispatch(recieveProfileInfo({
|
||||
"id": 2,
|
||||
"name": "Customer User",
|
||||
"mail": "customer@mail.com",
|
||||
"phone": "",
|
||||
"userType": "customer",
|
||||
"vatCode": "556084-6783",
|
||||
"companyName": "Coor Service Management AB",
|
||||
"billingAddresses": [
|
||||
{
|
||||
"id": 1,
|
||||
"city": "Göteborg",
|
||||
"countryName": "SE",
|
||||
"detailedAddress": "Lilla Bommen 2",
|
||||
"firstName": "Customer",
|
||||
"lastName": "User",
|
||||
"zipCode": "12323"
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/customers/${idUser}`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data){
|
||||
dispatch(recieveProfileInfo(response.data));
|
||||
}
|
||||
],
|
||||
"profileAddresses": [
|
||||
{
|
||||
"id": 1,
|
||||
"city": "Göteborg",
|
||||
"countryName": "Göteborg",
|
||||
"detailedAddress": "Lilla Bommen 2",
|
||||
"zipCode": "12323"
|
||||
}
|
||||
]
|
||||
}));
|
||||
});
|
||||
// return client.fetch({
|
||||
// url: `${API_SERVER}/wp-json/wiaas/cart/customer-info`,
|
||||
// method: 'get',
|
||||
@@ -82,10 +61,14 @@ const requestSaveProfile = () => ({
|
||||
export const saveProfileInfo = (idUser, profile) => {
|
||||
return dispatch => {
|
||||
dispatch(requestSaveProfile());
|
||||
const parsedFullName = profile.name.trim().split(' ');
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/saveProfileInfo`,
|
||||
method: 'post',
|
||||
data: {idUser, profile: JSON.stringify(profile)}
|
||||
url: `${API_SERVER}/wp-json/wc/v2/customers/${idUser}`,
|
||||
method: 'put',
|
||||
data: {
|
||||
'first_name': parsedFullName[0],
|
||||
'last_name': parsedFullName[1],
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
|
||||
Reference in New Issue
Block a user