diff --git a/src/modules/rendicontazione/pages/RendicontazioniMie.js b/src/modules/rendicontazione/pages/RendicontazioniMie.js index 804cf49..25475fb 100644 --- a/src/modules/rendicontazione/pages/RendicontazioniMie.js +++ b/src/modules/rendicontazione/pages/RendicontazioniMie.js @@ -31,7 +31,7 @@ const RendicontazioniMie = () => { const toast = useRef(null); const [apps, setApps] = useState([]); const [loading, setLoading] = useState(true); - const [startDialog, setStartDialog] = useState(null); // { application_id, max_tranches, next_seq, show_copy_ula } + const [startDialog, setStartDialog] = useState(null); const [startForm, setStartForm] = useState({ period_label: '', copy_ula: true }); const [starting, setStarting] = useState(false); @@ -58,30 +58,39 @@ const RendicontazioniMie = () => { call_name: app.call_name, max_tranches: app.max_tranches, next_seq: nextSeq, - show_copy_ula: nextSeq > 1, max_remission_next: app.max_remission_next_tranche, + show_copy_ula: nextSeq > 1, }); - setStartForm({ period_label: '', copy_ula: nextSeq > 1 }); + setStartForm({ period_label: '', copy_ula: true }); }; const confirmStart = () => { if (!startDialog) return; setStarting(true); - RendicontazioneService.startPractice( - startDialog.application_id, + RendicontazioneService.startPractice(startDialog.application_id, (resp) => { setStarting(false); setStartDialog(null); - toast.current?.show({ severity: 'success', summary: resp?.message || __('Tranche avviata', 'gepafin') }); - navigate(`/rendicontazioni/${resp.data.id}`); + toast.current?.show({ + severity: 'success', + summary: __('Tranche avviata', 'gepafin'), + detail: resp?.message + }); + const newId = resp?.data?.id; + if (newId) navigate(`/rendicontazioni/${newId}`); + else load(); }, (err) => { setStarting(false); - toast.current?.show({ severity: 'error', summary: __('Avvio fallito', 'gepafin'), detail: err?.detail }); + toast.current?.show({ + severity: 'error', + summary: __('Avvio fallito', 'gepafin'), + detail: err?.detail || err?.message + }); }, { - period_label: startForm.period_label?.trim() || null, - copy_ula_from_previous: startForm.copy_ula, + period_label: startForm.period_label || null, + copy_ula_from_previous: startDialog.show_copy_ula ? startForm.copy_ula : false, } ); }; @@ -93,79 +102,92 @@ const RendicontazioniMie = () => { const blockReason = app.start_blocked_reason; return ( -
- {/* HEADER CARD */} -
-
-

+
+ {/* HEADER: bando + erogato */} +
+
+

{app.call_name || `Bando #${app.call_id}`} -

-
+

+

{app.company_name || ''} · {__('Domanda', 'gepafin')} #{app.application_id} -

+

-
{__('Finanziamento erogato','gepafin')}
-
{fmtEur(app.amount_erogato)}
+
+ {__('Finanziamento erogato','gepafin')} +
+
{fmtEur(app.amount_erogato)}
- {/* CAP INFO */} -
-
-
{__('Cap remissione totale', 'gepafin')}
- {fmtEur(app.max_remission_global)} -
-
-
{__('Già approvato', 'gepafin')}
- 0 ? '#22543d' : 'inherit' }}>{fmtEur(app.already_approved_sum)} -
-
-
{__('Disponibile prossima tranche', 'gepafin')}
- {fmtEur(app.max_remission_next_tranche)} -
-
-
{__('Tranches', 'gepafin')}
- {app.tranches?.length || 0} / {app.max_tranches} -
+ {/* METRICHE cap/approvato/disponibile/tranches in griglia 4 colonne */} +
+

+ {__('Cap remissione totale', 'gepafin')} + {fmtEur(app.max_remission_global)} +

+

+ {__('Già approvato', 'gepafin')} + 0 ? 'var(--green-700)' : 'inherit' }}> + {fmtEur(app.already_approved_sum)} + +

+

+ {__('Disponibile prossima tranche', 'gepafin')} + + {fmtEur(app.max_remission_next_tranche)} + +

+

+ {__('Tranches', 'gepafin')} + {app.tranches?.length || 0} / {app.max_tranches} +

- {/* TRANCHES LIST */} + {/* LISTA TRANCHES */} {hasTranches && ( -
+ )} - {/* BOTTONE NUOVA TRANCHE */} -
+ {/* AZIONI: nuova tranche */} +
{!canStart && blockReason && ( - - + + {blockReason} )} @@ -190,26 +212,33 @@ const RendicontazioniMie = () => {

{__('Le mie rendicontazioni', 'gepafin')}

-

{__('Per ogni pratica finanziata puoi avviare la rendicontazione delle spese e il calcolo della remissione del debito. I bandi che prevedono piu tranches permettono rendicontazioni multi-fase.', 'gepafin')}

+

{__('Per ogni pratica finanziata puoi avviare la rendicontazione delle spese e il calcolo della remissione del debito. I bandi che prevedono più tranches permettono rendicontazioni multi-fase.', 'gepafin')}

- {loading && } + {loading && ( +
+ +
+ )} {!loading && apps.length === 0 && ( -
+

{__('Non ci sono rendicontazioni disponibili al momento.', 'gepafin')}

- + {__('Le rendicontazioni diventano disponibili dopo la firma del contratto e quando l\'ente ha pubblicato lo schema di rendicontazione per il bando.', 'gepafin')}
)} - {!loading && apps.length > 0 && apps.map(renderApplicationCard)} + {!loading && apps.length > 0 && ( +
+ {apps.map(renderApplicationCard)} +
+ )} - {/* START DIALOG */} !starting && setStartDialog(null)} @@ -240,7 +269,7 @@ const RendicontazioniMie = () => { onChange={(e) => setStartForm(f => ({ ...f, period_label: e.target.value }))} placeholder={__('es. "I trimestre 2021", "Stato avanzamento II"', 'gepafin')} disabled={starting} /> - + {__('Descrizione libera per identificare la tranche. Apparirà sul verbale.', 'gepafin')}
@@ -255,7 +284,7 @@ const RendicontazioniMie = () => { {__('Copia i dipendenti ULA dalla tranche precedente', 'gepafin')}
- + {__('Se attivo, i dipendenti censiti nella tranche precedente saranno precaricati. Potrai modificarli o rimuoverli prima di inviare.', 'gepafin')}