186 lines
4.5 KiB
JavaScript
186 lines
4.5 KiB
JavaScript
import axios from 'axios';
|
|
import { Cookies } from 'react-cookie';
|
|
import Router from 'next/router';
|
|
import moment from 'moment';
|
|
import { nSQL } from "@nano-sql/core";
|
|
import { concatSeries, eachSeries } from 'async';
|
|
import fileDownload from 'js-file-download';
|
|
|
|
import * as actionTypes from '../constants/actionTypes';
|
|
import * as currentState from '../reducers/initialState';
|
|
|
|
export const signCheckEDOCreatePrintForm = ({ contract_number, sign_type }) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/check`;
|
|
|
|
console.log("ACTION", "sign", "signCheckEDOCreatePrintForm()", { url });
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, { contract_number, sign_type }, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
console.log("ACTION", "sign", "signCheckEDOCreatePrintForm()", "response", response.data);
|
|
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signCheckEDOCreatePrintForm()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signGetGUIDEntity = ({ contract_number }) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/entity`;
|
|
|
|
console.log("ACTION", "sign", "signGetGUIDEntity()", { url });
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, { contract_number }, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
console.log("ACTION", "sign", "signGetGUIDEntity()", "response", response.data);
|
|
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signGetGUIDEntity()", "ERROR");
|
|
console.error(error);
|
|
|
|
resolve(response.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signCheckPowerAttorneyClient = ({ contract_number }) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/check`;
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, { contract_number }, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
console.log("ACTION", "sign", "signCheckPowerAttorneyClient()", "response", response.data);
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signCheckPowerAttorneyClient()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signGetPowerAttorneyClient = ({ contract_number }) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/get`;
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, { contract_number }, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
console.log("ACTION", "sign", "signGetPowerAttorneyClient()", "response", response.data);
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signGetPowerAttorneyClient()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signGetWMDoc = (payload) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/create`;
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, payload, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
console.log("ACTION", "sign", "signGetWMDoc()", "response", response.data);
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signGetWMDoc()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signDownloadFile = ({ payload, filename }) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/download`;
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.get(url, {
|
|
params: payload,
|
|
responseType: 'blob',
|
|
})
|
|
.then((response) =>
|
|
{
|
|
fileDownload(response.data, filename);
|
|
resolve();
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signDownloadFile()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
}
|
|
|
|
export const signGetFileContractProject = (payload) =>
|
|
{
|
|
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/link`;
|
|
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
axios.post(url, payload, {
|
|
withCredentials: true,
|
|
})
|
|
.then((response) =>
|
|
{
|
|
if(parseInt(process.env.LOG, 10) === 1) { console.log("ACTION", "sign", "signGetFileContractProject()", "response", response.data); }
|
|
|
|
resolve(response.data);
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
console.error("ACTION", "sign", "signGetFileContractProject()", "ERROR");
|
|
console.error(error);
|
|
|
|
reject(error.data);
|
|
});
|
|
});
|
|
} |