Files
bflows-bandi-fe/src/pages/DomandaEditPreInstructor/components/DownloadSignedApplication/index.js
Vitalii Kiiko 0f54ce6bd9 - updated tables - displaying protocol id, columns for ndg and appointment;
- added 2 buttons for download delega and download signed pdf for application;
2024-12-05 17:16:27 +01:00

45 lines
1.3 KiB
JavaScript

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;