- 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:
Vitalii Kiiko
2024-12-05 17:16:27 +01:00
parent f072c3d6a6
commit 0f54ce6bd9
8 changed files with 152 additions and 18 deletions

View File

@@ -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;

View File

@@ -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;