- 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 HelpIcon from '../../icons/HelpIcon';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
|
||||
const DomandaEditPreInstructor = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
@@ -40,6 +42,9 @@ const DomandaEditPreInstructor = () => {
|
||||
const [isAdmissible, setIsAdmissible] = useState(false);
|
||||
const [connectedSoccorsoId, setConnectedSoccorsoId] = useState(0);
|
||||
const toast = useRef(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false);
|
||||
const [operationType, setOperationType] = useState('')
|
||||
|
||||
const goToEvaluationsPage = () => {
|
||||
navigate('/domande');
|
||||
@@ -256,12 +261,48 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
|
||||
const errGetAmendmentsCallback = () => {
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
}
|
||||
|
||||
const shouldDisableField = (fieldName) => {
|
||||
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(() => {
|
||||
const maxScore = pathOr(0, ['minScore'], data);
|
||||
const criteria = pathOr([], ['criteria'], data);
|
||||
@@ -329,7 +370,7 @@ const DomandaEditPreInstructor = () => {
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Stato', 'gepafin')}</span>
|
||||
<span>{getBandoLabel(data.status)}</span>
|
||||
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -548,14 +589,14 @@ const DomandaEditPreInstructor = () => {
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible || ['CLOSE', 'SOCCORSO'].includes(data.status)}
|
||||
onClick={doApprove}
|
||||
onClick={initiateApproving}
|
||||
label={__('Approva Domanda', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={['CLOSE', 'SOCCORSO'].includes(data.status)}
|
||||
onClick={doReject}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi Domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
@@ -569,6 +610,28 @@ const DomandaEditPreInstructor = () => {
|
||||
{criterionDataContent}
|
||||
</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>
|
||||
: <>
|
||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
||||
|
||||
Reference in New Issue
Block a user