initial docker setup
This commit is contained in:
118
frontend/src/actions/profileSettings/addressActions.js
Normal file
118
frontend/src/actions/profileSettings/addressActions.js
Normal file
@@ -0,0 +1,118 @@
|
||||
import {
|
||||
API_SERVER
|
||||
} from '../../config';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
import {
|
||||
REQUEST_SAVE_PROFILE_ADDRESS,
|
||||
REQUEST_REMOVE_PROFILE_ADDRESS,
|
||||
REQUEST_REMOVE_BILLING_ADDRESS,
|
||||
REQUEST_SAVE_BILLING_ADDRESS,
|
||||
profileTexts
|
||||
} from '../../constants/profileSettingsConstants';
|
||||
import {fetchProfileInfo} from './profileSettingsActions';
|
||||
import {updateMessages} from '../notification/notificationActions';
|
||||
import {setDialogOpenFlag} from '../dialog/dialogActions';
|
||||
|
||||
const client = new HtmlClient();
|
||||
|
||||
const requestSaveAddress = () => ({
|
||||
type: REQUEST_SAVE_PROFILE_ADDRESS
|
||||
});
|
||||
|
||||
export const saveProfileAddress = (idUser, profileAddress) => {
|
||||
return dispatch => {
|
||||
dispatch(requestSaveAddress());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/saveProfileAddress`,
|
||||
method: 'post',
|
||||
data: {profileAddress: JSON.stringify(profileAddress)}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
if(response.data.messages[0].code === 'success'){
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
dispatch(setDialogOpenFlag(false));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const requestRemoveAddress = () => ({
|
||||
type: REQUEST_REMOVE_PROFILE_ADDRESS
|
||||
});
|
||||
|
||||
export const removeProfileAddress = (idUser, idProfileAddress) => {
|
||||
return dispatch => {
|
||||
dispatch(requestRemoveAddress());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/removeProfileAddress`,
|
||||
method: 'post',
|
||||
data: {idProfileAddress}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const requestSaveBillingAddress = () => ({
|
||||
type: REQUEST_SAVE_BILLING_ADDRESS
|
||||
});
|
||||
|
||||
export const saveBillingAddress = (idUser, idCompany, billingAddress) => {
|
||||
return dispatch => {
|
||||
dispatch(requestSaveBillingAddress());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/saveBillingAddress`,
|
||||
method: 'post',
|
||||
data: {idCompany, billingAddress: JSON.stringify(billingAddress)}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
if(response.data.messages[0].code === 'success'){
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
dispatch(setDialogOpenFlag(false));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const requestRemoveBillingAddress = () => ({
|
||||
type: REQUEST_REMOVE_BILLING_ADDRESS
|
||||
});
|
||||
|
||||
export const removeBillingAddress = (idUser, idBillingAddress) => {
|
||||
return dispatch => {
|
||||
dispatch(requestRemoveBillingAddress());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/removeBillingAddress`,
|
||||
method: 'post',
|
||||
data: {idBillingAddress}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
}
|
||||
123
frontend/src/actions/profileSettings/profileSettingsActions.js
Normal file
123
frontend/src/actions/profileSettings/profileSettingsActions.js
Normal file
@@ -0,0 +1,123 @@
|
||||
import {
|
||||
API_SERVER
|
||||
} from '../../config';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
import {
|
||||
REQUEST_PROFILE_INFO,
|
||||
RECIEVE_PROFILE_INFO,
|
||||
REQUEST_SAVE_PROFILE,
|
||||
REQUEST_SAVE_COMPANY,
|
||||
REQUEST_COUNTRIES,
|
||||
RECIEVE_COUNTRIES,
|
||||
profileTexts
|
||||
} from '../../constants/profileSettingsConstants';
|
||||
import {updateMessages} from '../notification/notificationActions';
|
||||
|
||||
const client = new HtmlClient();
|
||||
|
||||
const requestProfileInfo = () => ({
|
||||
type: REQUEST_PROFILE_INFO,
|
||||
isLoading: true
|
||||
});
|
||||
|
||||
export const recieveProfileInfo = (json) => ({
|
||||
type: RECIEVE_PROFILE_INFO,
|
||||
isLoading: false,
|
||||
profileInfo: json
|
||||
});
|
||||
|
||||
export const fetchProfileInfo = (idUser) => {
|
||||
return dispatch => {
|
||||
dispatch(requestProfileInfo());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/getProfileInfo`,
|
||||
method: 'post',
|
||||
data: {idUser}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data){
|
||||
dispatch(recieveProfileInfo(response.data));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const requestSaveProfile = () => ({
|
||||
type: REQUEST_SAVE_PROFILE
|
||||
});
|
||||
|
||||
export const saveProfileInfo = (idUser, profile) => {
|
||||
return dispatch => {
|
||||
dispatch(requestSaveProfile());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/saveProfileInfo`,
|
||||
method: 'post',
|
||||
data: {idUser, profile: JSON.stringify(profile)}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const requestSaveCompany = () => ({
|
||||
type: REQUEST_SAVE_COMPANY
|
||||
});
|
||||
|
||||
export const saveCompanyInfo = (idUser, companyInfo) => {
|
||||
return dispatch => {
|
||||
dispatch(requestSaveCompany());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/saveCompanyInfo`,
|
||||
method: 'post',
|
||||
data: {companyInfo: JSON.stringify(companyInfo)}
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.messages){
|
||||
dispatch(updateMessages(response.data.messages, profileTexts.messages));
|
||||
dispatch(fetchProfileInfo(idUser));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const requestCountries = () => ({
|
||||
type: REQUEST_COUNTRIES,
|
||||
areCountriesLoading: true
|
||||
});
|
||||
|
||||
const recieveCountries = (json) => ({
|
||||
type: RECIEVE_COUNTRIES,
|
||||
areCountriesLoading: false,
|
||||
countries: json
|
||||
});
|
||||
|
||||
export const fetchCountries = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestCountries());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/profileSettings/api/getCoutnries`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data){
|
||||
dispatch(recieveCountries(response.data));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user