- updated tables - displaying protocol id, columns for ndg and appointment;
- added 2 buttons for download delega and download signed pdf for application;
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// api
|
||||
import CompanyService from '../../../../service/company-service';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
|
||||
const DownloadCompanyDelegation = ({ applicationId = 0 }) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [delega, setDelega] = useState({});
|
||||
|
||||
const onClickDownload = () => {
|
||||
if (delega.filePath) {
|
||||
window.open(encodeURI(delega.filePath), '_blank').focus()
|
||||
}
|
||||
}
|
||||
|
||||
const getDellegaCallback = (data) => {
|
||||
if (data.data) {
|
||||
setDelega([data.data]);
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
const errDellegaCallback = () => {
|
||||
setDelega([]);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
CompanyService.getCompanyDelega(0, getDellegaCallback, errDellegaCallback, [
|
||||
['applicationId', applicationId]
|
||||
]);
|
||||
}, [])
|
||||
|
||||
return (applicationId && applicationId !== 0
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={loading || isEmpty(delega)}
|
||||
onClick={onClickDownload}
|
||||
label={__('Scarica la delega', 'gepafin')}
|
||||
icon="pi pi-download"
|
||||
iconPos="right"/> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default DownloadCompanyDelegation;
|
||||
@@ -0,0 +1,45 @@
|
||||
import React, { useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
|
||||
const DownloadSignedApplication = ({ applicationId = 0 }) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [, setDocument] = useState({});
|
||||
|
||||
const onClickDownload = () => {
|
||||
setLoading(true);
|
||||
ApplicationService.getApplicationSignedPdf(applicationId, getSignedPdfCallback, errSignedPdfCallbacks);
|
||||
}
|
||||
|
||||
const getSignedPdfCallback = (data) => {
|
||||
if (data.data) {
|
||||
setDocument([data.data]);
|
||||
if (data.data.filePath) {
|
||||
window.open(encodeURI(data.data.filePath), '_blank').focus()
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
const errSignedPdfCallbacks = () => {
|
||||
setDocument([]);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (applicationId && applicationId !== 0
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
onClick={onClickDownload}
|
||||
label={__('Scarica PDF firmato', 'gepafin')}
|
||||
icon="pi pi-download"
|
||||
iconPos="right"/> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default DownloadSignedApplication;
|
||||
Reference in New Issue
Block a user