- added updating status for initiating evaluation process;
- fixed issues with displaying and calcuating decimals in appl form;
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect} from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { is, uniq, isNil } from 'ramda';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { is, uniq, isNil, head } from 'ramda';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
|
||||
// api
|
||||
import AssignedApplicationService from '../../../../service/assigned-application-service';
|
||||
@@ -22,10 +22,12 @@ import { Tag } from 'primereact/tag';
|
||||
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import { useStore } from '../../../../store';
|
||||
import { klona } from 'klona';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const PreInstructorDomandeTable = ({ userId = null, statuses = [] }) => {
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
@@ -136,13 +138,44 @@ const PreInstructorDomandeTable = ({ userId = null, statuses = [] }) => {
|
||||
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)} />;
|
||||
};
|
||||
|
||||
const handleInitiateEvaluation = (id) => {
|
||||
setLocalAsyncRequest(true);
|
||||
AssignedApplicationService.updateStatusAssignedApplication(id, getInitEvalCallback, errInitEvalCallbacks, [
|
||||
['status', 'OPEN']
|
||||
])
|
||||
}
|
||||
|
||||
const getInitEvalCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
const evaluation = klona(head(getFormattedData([resp.data])));
|
||||
const newItems = items.map(o => o.id === evaluation.id ? evaluation : o);
|
||||
setItems(newItems);
|
||||
navigate(`/domande/${evaluation.applicationId}`);
|
||||
}
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errInitEvalCallbacks = (resp) => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
const label = ['OPEN', 'SOCCORSO'].includes(rowData.status) && userData.id === rowData.userId
|
||||
? __('Valuta', 'gepafin')
|
||||
: __('Mostra', 'gepafin');
|
||||
return <Link to={`/domande/${rowData.applicationId}`}>
|
||||
<Button severity="info" label={label} icon="pi pi-eye" size="small" iconPos="right"/>
|
||||
</Link>
|
||||
if (rowData.status === 'AWAITING') {
|
||||
return <Button
|
||||
severity="info"
|
||||
onClick={() => handleInitiateEvaluation(rowData.id)}
|
||||
label={__('Valuta', 'gepafin')}
|
||||
icon="pi pi-eye"
|
||||
size="small"
|
||||
iconPos="right"/>
|
||||
} else {
|
||||
const label = ['OPEN', 'SOCCORSO'].includes(rowData.status) && userData.id === rowData.userId
|
||||
? __('Valuta', 'gepafin')
|
||||
: __('Mostra', 'gepafin');
|
||||
return <Link to={`/domande/${rowData.applicationId}`}>
|
||||
<Button severity="info" label={label} icon="pi pi-eye" size="small" iconPos="right"/>
|
||||
</Link>
|
||||
}
|
||||
}
|
||||
|
||||
const header = renderHeader();
|
||||
|
||||
Reference in New Issue
Block a user