Handle wiaas documents
This commit is contained in:
@@ -225,15 +225,15 @@ export const previousStep = (params) => ({type: GO_TO_PREVIOUS_STEP, params});
|
||||
|
||||
export const uploadDocumnet = () => ({type: UPLOAD_DOCUMENT});
|
||||
|
||||
export const uploadOrderDocument = (idPackage, idDocumentType, file, packages) => {
|
||||
export const uploadOrderDocument = (packageCartKey, idDocumentType, file, packages) => {
|
||||
return dispatch => {
|
||||
dispatch(uploadDocumnet());
|
||||
|
||||
return client.uploadFile(file, {
|
||||
url: `${API_SERVER}/cart/api/uploadOrderDocument`,
|
||||
url: `${API_SERVER}/wp-json/wiaas/cart/documents`,
|
||||
data: {
|
||||
idDocumentType,
|
||||
idPackage
|
||||
'doc_type': idDocumentType,
|
||||
'package_key': packageCartKey
|
||||
}
|
||||
}).then(response => {
|
||||
if (typeof response.data !== 'undefined' && 'messages' in response.data) {
|
||||
@@ -266,30 +266,21 @@ export const fetchCartDocuments = (packages, isForSteps = false) => {
|
||||
return dispatch => {
|
||||
dispatch(requestCartDocuments());
|
||||
|
||||
dispatch(receiveCartDocuments({
|
||||
areFilesUploaded: true,
|
||||
templates: [],
|
||||
uploaded: []
|
||||
}));
|
||||
if(isForSteps) {
|
||||
dispatch(loadSteps(true));
|
||||
}
|
||||
|
||||
// return client.fetch({
|
||||
// url: `${API_SERVER}/wp-json/wiaas/cart/documents`,
|
||||
// method: 'get',
|
||||
// data: {packages}
|
||||
// }).then(response => {
|
||||
// if (response.data) {
|
||||
// dispatch(receiveCartDocuments(response.data));
|
||||
// if(isForSteps) {
|
||||
// const whitoutUploadDoc = response.data.templates.length === 0;
|
||||
// dispatch(loadSteps(whitoutUploadDoc));
|
||||
// }
|
||||
// }
|
||||
// }).catch(error => {
|
||||
// client.onError(error, dispatch);
|
||||
// });
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/cart/documents`,
|
||||
method: 'get',
|
||||
data: {packages}
|
||||
}).then(response => {
|
||||
if (response.data) {
|
||||
dispatch(receiveCartDocuments(response.data));
|
||||
if(isForSteps) {
|
||||
const whitoutUploadDoc = response.data.templates.length === 0;
|
||||
dispatch(loadSteps(whitoutUploadDoc));
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user