- added files field to evaluation rejection, ammendment creation and ammendment communication modal windows;
- fixed issue with filtering applications in dashboard for pre instructor;
This commit is contained in:
@@ -56,6 +56,9 @@ import FormField from '../../components/FormField';
|
||||
import SoccorsoResendEmails from '../SoccorsoEditPreInstructor/components/SoccorsoResendEmails';
|
||||
import EvaluationReAdmit from './components/EvaluationReAdmit';
|
||||
import { SplitButton } from 'primereact/splitbutton';
|
||||
import { FileUpload } from 'primereact/fileupload';
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../configData';
|
||||
import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
||||
|
||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -75,8 +78,10 @@ const DomandaEditPreInstructor = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false);
|
||||
const [operationType, setOperationType] = useState('');
|
||||
const [motivation, setMotivation] = useState('');
|
||||
const [amountAccepted, setAmountAccepted] = useState(0);
|
||||
const [finalDialogData, setFinalDialogData] = useState({
|
||||
motivation: ''
|
||||
});
|
||||
const finalDialogFilesRef = useRef(null);
|
||||
const [isVisibleAppointmentDialog, setIsVisibleAppointmentDialog] = useState(false);
|
||||
const [isVisiblePreTecEvalDialog, setIsVisiblePreTecEvalDialog] = useState(false);
|
||||
const [preTecEvalData, setPreTecEvalData] = useState({
|
||||
@@ -219,7 +224,7 @@ const DomandaEditPreInstructor = () => {
|
||||
const getCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setData(getFormattedData(resp.data));
|
||||
setMotivation(resp.data.motivation);
|
||||
setFinalDialogData((prev) => ({...prev, motivation: resp.data.motivation}));
|
||||
updateFlagsForSoccorso(resp.data);
|
||||
|
||||
if (resp.data.evaluationVersion === 'V2') {
|
||||
@@ -445,8 +450,8 @@ const DomandaEditPreInstructor = () => {
|
||||
checklist: klona(data.checklist),
|
||||
files: klona(data.files),
|
||||
note: data.note,
|
||||
motivation,
|
||||
amountAccepted
|
||||
motivation: finalDialogData.motivation,
|
||||
amountAccepted: finalDialogData.amount
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
@@ -470,8 +475,8 @@ const DomandaEditPreInstructor = () => {
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation,
|
||||
amountAccepted
|
||||
motivation: finalDialogData.motivation,
|
||||
amountAccepted: finalDialogData.amount
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
@@ -484,7 +489,7 @@ const DomandaEditPreInstructor = () => {
|
||||
errApproveRejectCallback
|
||||
);
|
||||
}
|
||||
}, [data, motivation]);
|
||||
}, [data, finalDialogData]);
|
||||
|
||||
const doReject = useCallback((newStatus) => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
@@ -494,7 +499,7 @@ const DomandaEditPreInstructor = () => {
|
||||
checklist: klona(data.checklist),
|
||||
files: klona(data.files),
|
||||
note: data.note,
|
||||
motivation
|
||||
motivation: finalDialogData.motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
@@ -518,7 +523,7 @@ const DomandaEditPreInstructor = () => {
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
motivation: finalDialogData.motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
@@ -531,7 +536,7 @@ const DomandaEditPreInstructor = () => {
|
||||
errApproveRejectCallback
|
||||
);
|
||||
}
|
||||
}, [data, motivation]);
|
||||
}, [data, finalDialogData]);
|
||||
|
||||
const approveRejectCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
@@ -653,7 +658,7 @@ const DomandaEditPreInstructor = () => {
|
||||
const hideCompleteDialog = () => {
|
||||
setIsVisibleCompleteDialog(false);
|
||||
setOperationType('');
|
||||
setMotivation('');
|
||||
setFinalDialogData({});
|
||||
}
|
||||
|
||||
const footerCompleteDialog = useCallback(() => {
|
||||
@@ -662,11 +667,12 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
if (operationType === 'approve') {
|
||||
onSubmitAction = doApprove;
|
||||
isDisabled = isDisabled || !amountAccepted || isEmpty(amountAccepted) || amountAccepted === 0;
|
||||
isDisabled = isDisabled || !finalDialogData.amount || isEmpty(finalDialogData.amount) || finalDialogData.amount === 0;
|
||||
} else if (operationType === 'tf_reject') {
|
||||
onSubmitAction = () => doReject('TECHNICAL_EVALUATION_REJECTED');
|
||||
} else {
|
||||
onSubmitAction = () => doReject('REJECTED');
|
||||
isDisabled = isDisabled || !finalDialogData.subject || isEmpty(finalDialogData.subject) || !finalDialogData.motivation || isEmpty(finalDialogData.motivation)
|
||||
}
|
||||
|
||||
return <div>
|
||||
@@ -676,7 +682,12 @@ const DomandaEditPreInstructor = () => {
|
||||
disabled={isDisabled}
|
||||
label={__('Invia', 'gepafin')} onClick={onSubmitAction}/>
|
||||
</div>
|
||||
}, [amountAccepted, data, motivation]);
|
||||
}, [finalDialogData, data]);
|
||||
|
||||
const updateFinalDialogData = (value, path) => {
|
||||
const newData = wrap(finalDialogData).set(path.split('.'), value).value();
|
||||
setFinalDialogData(newData);
|
||||
};
|
||||
|
||||
const initiateApproving = () => {
|
||||
setOperationType('approve');
|
||||
@@ -945,7 +956,7 @@ const DomandaEditPreInstructor = () => {
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE'
|
||||
|| (data.applicationStatus === 'EVALUATION' && shouldDisableNewSoccorso())
|
||||
|| (data.applicationStatus !== 'SOCCORSO' && shouldDisableNewSoccorso())
|
||||
|| evaluationBlockedForUser(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
@@ -1505,28 +1516,95 @@ const DomandaEditPreInstructor = () => {
|
||||
{operationType === 'approve'
|
||||
? <div className="appForm__field">
|
||||
<label
|
||||
className={classNames({ 'p-error': !amountAccepted || isEmpty(amountAccepted) || amountAccepted === 0 })}>
|
||||
className={classNames({ 'p-error': !finalDialogData.amount || isEmpty(finalDialogData.amount) || finalDialogData.amount === 0 })}>
|
||||
{__('Importo approvato', 'gepafin')}
|
||||
</label>
|
||||
<InputNumber
|
||||
value={amountAccepted}
|
||||
value={finalDialogData.amount}
|
||||
keyfilter="int"
|
||||
invalid={!amountAccepted || isEmpty(amountAccepted) || amountAccepted === 0}
|
||||
onChange={(e) => setAmountAccepted(e.value)}/>
|
||||
invalid={!finalDialogData.amount || isEmpty(finalDialogData.amount) || finalDialogData.amount === 0}
|
||||
onChange={(e) => updateFinalDialogData(e.value, 'amount')}/>
|
||||
</div> : null}
|
||||
{operationType === 'reject'
|
||||
? <div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': !finalDialogData.subject || isEmpty(finalDialogData.subject) })}>
|
||||
{__('Soggetto', 'gepafin')}
|
||||
</label>
|
||||
<InputText
|
||||
value={finalDialogData.subject}
|
||||
invalid={!finalDialogData.subject || isEmpty(finalDialogData.subject)}
|
||||
onChange={(e) => updateFinalDialogData(e.target.value, 'subject')}/>
|
||||
</div> : null}
|
||||
<div className="appForm__field">
|
||||
<label>{__('Motivazione', 'gepafin')}</label>
|
||||
<label className={classNames({ 'p-error': !finalDialogData.motivation || isEmpty(finalDialogData.motivation) })}>
|
||||
{__('Motivazione', 'gepafin')}
|
||||
</label>
|
||||
<div translate="no">
|
||||
<Editor
|
||||
value={motivation}
|
||||
value={finalDialogData.motivation}
|
||||
readOnly={loading}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => setMotivation(e.htmlValue)}
|
||||
onTextChange={(e) => updateFinalDialogData(e.htmlValue, 'motivation')}
|
||||
style={{ height: 80 * 3, width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{operationType === 'reject'
|
||||
? <div className="appForm__field">
|
||||
<label>
|
||||
{__('Files', 'gepafin')}
|
||||
</label>
|
||||
<FileUpload
|
||||
ref={finalDialogFilesRef}
|
||||
name="files[]"
|
||||
multiple
|
||||
accept={mimeTypes.map(o => o.code).join(',')}
|
||||
maxFileSize={defaultMaxFileSize}
|
||||
auto={false}
|
||||
customUpload={true}
|
||||
onSelect={(e) => {
|
||||
updateFinalDialogData(e.files, 'files');
|
||||
}}
|
||||
onRemove={(e) => {
|
||||
const updatedFiles = finalDialogFilesRef.current.getFiles();
|
||||
updateFinalDialogData(updatedFiles, 'files');
|
||||
}}
|
||||
headerTemplate={(options) => {
|
||||
const { chooseButton } = options;
|
||||
return (
|
||||
<div className="p-fileupload-buttonbar" data-pc-section="buttonbar">
|
||||
{chooseButton}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
chooseOptions={{
|
||||
label: __('Aggiungi i file', 'gepafin'),
|
||||
icon: 'pi pi-plus'
|
||||
}}
|
||||
itemTemplate={(file, props) => {
|
||||
return(
|
||||
<div className="p-fileupload-row" data-pc-section="file">
|
||||
<div data-pc-section="details" style={{display: 'flex', flexDirection: 'column', gap: '10px', textAlign: 'left'}}>
|
||||
<div className="p-fileupload-filename" data-pc-section="filename">
|
||||
{file.name}
|
||||
</div>
|
||||
<span data-pc-section="filesize">{getFormatedFileSizeText(file.size)}</span>
|
||||
</div>
|
||||
<div data-pc-section="actions">
|
||||
<Button
|
||||
type="button"
|
||||
icon="pi pi-times"
|
||||
className="p-button-rounded p-button-danger p-button-text"
|
||||
onClick={() => props.onRemove()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
emptyTemplate={<p className="m-0">{__('Trascina i file qua')}</p>}
|
||||
/>
|
||||
</div> : null}
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
|
||||
Reference in New Issue
Block a user