- added modal window for approving/rejecting;
This commit is contained in:
@@ -28,6 +28,8 @@ import BlockingOverlay from '../../components/BlockingOverlay';
|
|||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import HelpIcon from '../../icons/HelpIcon';
|
import HelpIcon from '../../icons/HelpIcon';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { classNames } from 'primereact/utils';
|
||||||
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
|
|
||||||
const DomandaEditPreInstructor = () => {
|
const DomandaEditPreInstructor = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
@@ -40,6 +42,9 @@ const DomandaEditPreInstructor = () => {
|
|||||||
const [isAdmissible, setIsAdmissible] = useState(false);
|
const [isAdmissible, setIsAdmissible] = useState(false);
|
||||||
const [connectedSoccorsoId, setConnectedSoccorsoId] = useState(0);
|
const [connectedSoccorsoId, setConnectedSoccorsoId] = useState(0);
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false);
|
||||||
|
const [operationType, setOperationType] = useState('')
|
||||||
|
|
||||||
const goToEvaluationsPage = () => {
|
const goToEvaluationsPage = () => {
|
||||||
navigate('/domande');
|
navigate('/domande');
|
||||||
@@ -256,12 +261,48 @@ const DomandaEditPreInstructor = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const errGetAmendmentsCallback = () => {
|
const errGetAmendmentsCallback = () => {
|
||||||
|
if (toast.current && data.message) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'error',
|
||||||
|
summary: '',
|
||||||
|
detail: data.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
set404FromErrorResponse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldDisableField = (fieldName) => {
|
const shouldDisableField = (fieldName) => {
|
||||||
return !['EVALUATION', 'OPEN'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria'
|
return !['EVALUATION', 'OPEN'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headerCompleteDialog = () => {
|
||||||
|
return 'approve' === operationType
|
||||||
|
? <span>{__('Confermare l\'approvazione', 'gepafin')}</span>
|
||||||
|
: <span>{__('Confermare il rifiuto', 'gepafin')}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideCompleteDialog = () => {
|
||||||
|
setIsVisibleCompleteDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const footerCompleteDialog = () => {
|
||||||
|
return <div>
|
||||||
|
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideCompleteDialog} outlined/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={loading}
|
||||||
|
label={__('Invia', 'gepafin')} onClick={'approve' === operationType ? doApprove : doReject}/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
const initiateApproving = () => {
|
||||||
|
setOperationType('approve');
|
||||||
|
}
|
||||||
|
|
||||||
|
const initiateRejecting = () => {
|
||||||
|
setOperationType('approve');
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const maxScore = pathOr(0, ['minScore'], data);
|
const maxScore = pathOr(0, ['minScore'], data);
|
||||||
const criteria = pathOr([], ['criteria'], data);
|
const criteria = pathOr([], ['criteria'], data);
|
||||||
@@ -329,7 +370,7 @@ const DomandaEditPreInstructor = () => {
|
|||||||
</p>
|
</p>
|
||||||
<p className="appPageSection__pMeta">
|
<p className="appPageSection__pMeta">
|
||||||
<span>{__('Stato', 'gepafin')}</span>
|
<span>{__('Stato', 'gepafin')}</span>
|
||||||
<span>{getBandoLabel(data.status)}</span>
|
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -548,14 +589,14 @@ const DomandaEditPreInstructor = () => {
|
|||||||
? <Button
|
? <Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={!isAdmissible || ['CLOSE', 'SOCCORSO'].includes(data.status)}
|
disabled={!isAdmissible || ['CLOSE', 'SOCCORSO'].includes(data.status)}
|
||||||
onClick={doApprove}
|
onClick={initiateApproving}
|
||||||
label={__('Approva Domanda', 'gepafin')}
|
label={__('Approva Domanda', 'gepafin')}
|
||||||
icon="pi pi-check" iconPos="right"/> : null}
|
icon="pi pi-check" iconPos="right"/> : null}
|
||||||
{data.id
|
{data.id
|
||||||
? <Button
|
? <Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={['CLOSE', 'SOCCORSO'].includes(data.status)}
|
disabled={['CLOSE', 'SOCCORSO'].includes(data.status)}
|
||||||
onClick={doReject}
|
onClick={initiateRejecting}
|
||||||
label={__('Respingi Domanda', 'gepafin')}
|
label={__('Respingi Domanda', 'gepafin')}
|
||||||
icon="pi pi-times" iconPos="right"/> : null}
|
icon="pi pi-times" iconPos="right"/> : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -569,6 +610,28 @@ const DomandaEditPreInstructor = () => {
|
|||||||
{criterionDataContent}
|
{criterionDataContent}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
visible={isVisibleCompleteDialog}
|
||||||
|
modal
|
||||||
|
header={headerCompleteDialog}
|
||||||
|
footer={footerCompleteDialog}
|
||||||
|
style={{ maxWidth: '600px', width: '100%' }}
|
||||||
|
onHide={hideCompleteDialog}>
|
||||||
|
<div className="appForm__field">
|
||||||
|
{/*<label
|
||||||
|
className={classNames({ 'p-error': isEmpty(chosenUser) || chosenUser === 0 || chosenApplication === 0 })}>
|
||||||
|
{__('Istruttore', 'gepafin')}*
|
||||||
|
</label>
|
||||||
|
<Dropdown
|
||||||
|
value={chosenUser}
|
||||||
|
invalid={isEmpty(chosenUser) || chosenUser === 0 || chosenApplication === 0}
|
||||||
|
onChange={(e) => setChosenUser(e.value)}
|
||||||
|
options={users}
|
||||||
|
optionLabel="name"
|
||||||
|
optionValue="value"/>*/}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
: <>
|
: <>
|
||||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
||||||
|
|||||||
Reference in New Issue
Block a user