diff --git a/src/modules/rendicontazione/pages/PraticaRendicontazioneEdit.js b/src/modules/rendicontazione/pages/PraticaRendicontazioneEdit.js index 24b539b..d82d554 100644 --- a/src/modules/rendicontazione/pages/PraticaRendicontazioneEdit.js +++ b/src/modules/rendicontazione/pages/PraticaRendicontazioneEdit.js @@ -360,10 +360,33 @@ const PraticaRendicontazioneEdit = () => { toast.current?.show({ severity: 'warn', summary: __('Risposta troppo corta', 'gepafin') }); return; } + const fileToUpload = amendDialog.response_file; + const amendmentId = amendDialog.amendment.id; + RendicontazioneService.respondAmendmentBeneficiary( - practiceId, amendDialog.amendment.id, amendDialog.responseText, - (resp) => { setAmendDialog({ visible: false, amendment: null, responseText: '' }); - afterMutation(__('Risposta inviata all\'istruttore', 'gepafin'))(resp); }, + practiceId, amendmentId, amendDialog.responseText, + (resp) => { + if (fileToUpload) { + RendicontazioneService.uploadResponseDocument(practiceId, amendmentId, fileToUpload, + () => { + setAmendDialog({ visible: false, amendment: null, responseText: '', response_file: null }); + afterMutation(__('Risposta trasmessa con allegato', 'gepafin'))(resp); + }, + (err) => { + // testo salvato ma upload fallito — avviso e ricarico + setAmendDialog({ visible: false, amendment: null, responseText: '', response_file: null }); + toast.current?.show({ + severity: 'warn', + summary: __('Risposta salvata, upload allegato fallito', 'gepafin'), + detail: err?.message || '' + }); + afterMutation(null)(resp); + }); + } else { + setAmendDialog({ visible: false, amendment: null, responseText: '', response_file: null }); + afterMutation(__('Risposta inviata all\'istruttore', 'gepafin'))(resp); + } + }, onMutationError); }; @@ -465,8 +488,8 @@ const PraticaRendicontazioneEdit = () => { )} - {/* SOCCORSO ISTRUTTORIO (se presente) */} - {practice.amendments && practice.amendments.length > 0 && (<> + {/* SOCCORSO ISTRUTTORIO (se presente — esclude DRAFT, visibile solo quando PEC partita) */} + {practice.amendments && practice.amendments.filter(a => a.status !== 'DRAFT').length > 0 && (<>

{__('Richieste di soccorso istruttorio', 'gepafin')}

@@ -474,7 +497,7 @@ const PraticaRendicontazioneEdit = () => { {__('L\'istruttore ha chiesto integrazioni o chiarimenti. Rispondi al più presto.', 'gepafin')}

- {practice.amendments.map(a => { + {practice.amendments.filter(a => a.status !== 'DRAFT').map(a => { const statusCfg = { AWAITING: { sev: 'warning', label: 'In attesa della tua risposta' }, RESPONSE_RECEIVED: { sev: 'info', label: 'Risposta inviata, in attesa di chiusura' }, @@ -484,25 +507,41 @@ const PraticaRendicontazioneEdit = () => { return (
-
+ background: a.status === 'AWAITING' ? 'var(--orange-50, #fff7ed)' : 'var(--surface-50)', + marginBottom: '0.75rem' }}> +
- - {__('Scadenza:', 'gepafin')} {new Date(a.deadline).toLocaleDateString('it-IT')} + + {__('Scadenza:', 'gepafin')} {new Date(a.deadline).toLocaleDateString('it-IT')} + {a.response_days ? ` (${a.response_days}gg dalla richiesta)` : ''}
{a.status === 'AWAITING' && (
{__('Richiesta istruttore:', 'gepafin')} -
{a.request_text}
+
+ {a.amendment_document_path && ( +
+ + {__('Allegato istruttore presente (disponibile via PEC)', 'gepafin')} +
+ )} {a.response_text && (<> {__('Tua risposta:', 'gepafin')} -
{a.response_text}
+
+ {a.response_document_path && ( +
+ + {__('Allegato inviato con la risposta', 'gepafin')} +
+ )} )}
@@ -911,23 +950,52 @@ const PraticaRendicontazioneEdit = () => { {/* ---------- DIALOG RISPOSTA SOCCORSO ---------- */} - setAmendDialog({ visible: false, amendment: null, responseText: '' })}> + onHide={() => setAmendDialog({ visible: false, amendment: null, responseText: '', response_file: null })}> {amendDialog.amendment && (
{ e.preventDefault(); submitAmendmentResponse(); }}> -
- {__('Richiesta istruttore:', 'gepafin')} -
{amendDialog.amendment.request_text}
+
+ + {__('Richiesta istruttore', 'gepafin')} + {amendDialog.amendment.response_days ? ` — ${__('hai', 'gepafin')} ${amendDialog.amendment.response_days} ${__('giorni per rispondere', 'gepafin')}` : ''} + +
+ {amendDialog.amendment.amendment_document_path && ( +
+ + {__('L\'istruttore ha allegato un documento (trasmesso via PEC)', 'gepafin')} +
+ )} +
+ + {__('Scadenza:', 'gepafin')} {new Date(amendDialog.amendment.deadline).toLocaleDateString('it-IT')} +
+
- - setAmendDialog(d => ({ ...d, responseText: e.target.value }))} - placeholder={__('Descrivi le integrazioni fornite, allegati caricati, chiarimenti...', 'gepafin')} /> + + setAmendDialog(d => ({ ...d, responseText: e.htmlValue || '' }))} + placeholder={__('Descrivi le integrazioni fornite, gli allegati caricati, i chiarimenti...', 'gepafin')} />
+ +
+ + {}} + onSelect={(e) => setAmendDialog(d => ({ ...d, response_file: e.files[0] || null }))} /> + + {__('Documento integrativo (DURC aggiornato, chiarimento contabile, ecc.)', 'gepafin')} + +
+
-