- completed page for instructor manager;
- update API related to profile updating; - fixed displaying stats for instructor manager; - added checklist items based validation;
This commit is contained in:
@@ -27,21 +27,12 @@ const DashboardInstructorManager = () => {
|
|||||||
|
|
||||||
const errGetStats = () => {}
|
const errGetStats = () => {}
|
||||||
|
|
||||||
const getDoubleStats = (data) => {
|
|
||||||
if (data.status === 'SUCCESS') {
|
|
||||||
console.log(data.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const errGetDoubleStats = () => {}
|
|
||||||
|
|
||||||
const getStatValue = (key, fallback = '') => {
|
const getStatValue = (key, fallback = '') => {
|
||||||
return pathOr(fallback, [key], mainStats);
|
return pathOr(fallback, [key], mainStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
DashboardService.getEvaluationsStats(getStats, errGetStats);
|
DashboardService.getEvaluationsStats(getStats, errGetStats);
|
||||||
DashboardService.getInstructorAmendmentsStats(getDoubleStats, errGetDoubleStats);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ const DashboardPreInstructor = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
DashboardService.getInstructorAmendmentsStats(getStats, errGetStats);
|
DashboardService.getInstructorAmendmentsStats(getStats, errGetStats, [
|
||||||
|
['userId', userData.id]
|
||||||
|
]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||||||
import { is, isEmpty, isNil, sum, pathOr, head, pluck } from 'ramda';
|
import { is, isEmpty, isNil, sum, pathOr, head, pluck } from 'ramda';
|
||||||
import { klona } from 'klona';
|
import { klona } from 'klona';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
import { evaluate } from 'mathjs';
|
||||||
|
import equal from 'fast-deep-equal';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeGet, storeSet, useStore } from '../../store';
|
import { storeGet, storeSet, useStore } from '../../store';
|
||||||
@@ -15,31 +18,6 @@ import AppointmentService from '../../service/appointment-service';
|
|||||||
|
|
||||||
// tools
|
// tools
|
||||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
import getBandoLabel from '../../helpers/getBandoLabel';
|
|
||||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
|
||||||
|
|
||||||
// components
|
|
||||||
import { Skeleton } from 'primereact/skeleton';
|
|
||||||
import { Button } from 'primereact/button';
|
|
||||||
import { Tag } from 'primereact/tag';
|
|
||||||
import { Checkbox } from 'primereact/checkbox';
|
|
||||||
import { Editor } from 'primereact/editor';
|
|
||||||
import { InputNumber } from 'primereact/inputnumber';
|
|
||||||
import { Toast } from 'primereact/toast';
|
|
||||||
import { Dialog } from 'primereact/dialog';
|
|
||||||
import HelpIcon from '../../icons/HelpIcon';
|
|
||||||
import { classNames } from 'primereact/utils';
|
|
||||||
import { InputTextarea } from 'primereact/inputtextarea';
|
|
||||||
import { InputText } from 'primereact/inputtext';
|
|
||||||
import DownloadApplicationArchive from '../DomandaEditPreInstructor/components/DownloadApplicationArchive';
|
|
||||||
import DownloadCompanyDelegation from '../DomandaEditPreInstructor/components/DownloadCompanyDelegation';
|
|
||||||
import DownloadSignedApplication from '../DomandaEditPreInstructor/components/DownloadSignedApplication';
|
|
||||||
import ListOfFiles from '../DomandaEditPreInstructor/components/ListOfFiles';
|
|
||||||
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
|
||||||
import getDateTimeFromISOstring from '../../helpers/getDateTimeFromISOstring';
|
|
||||||
import ApplicationInfo from '../DomandaEditPreInstructor/components/ApplicationInfo';
|
|
||||||
import ApplicationDownloadFiles from '../DomandaEditPreInstructor/components/ApplicationDownloadFiles';
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
import {
|
import {
|
||||||
isCAP,
|
isCAP,
|
||||||
isCodiceFiscale,
|
isCodiceFiscale,
|
||||||
@@ -54,9 +32,25 @@ import formatDateString from '../../helpers/formatDateString';
|
|||||||
import getTokens from '../../helpers/getTokens';
|
import getTokens from '../../helpers/getTokens';
|
||||||
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
||||||
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
||||||
import { evaluate } from 'mathjs';
|
|
||||||
import equal from 'fast-deep-equal';
|
|
||||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { Skeleton } from 'primereact/skeleton';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Checkbox } from 'primereact/checkbox';
|
||||||
|
import { Editor } from 'primereact/editor';
|
||||||
|
import { InputNumber } from 'primereact/inputnumber';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import HelpIcon from '../../icons/HelpIcon';
|
||||||
|
import { classNames } from 'primereact/utils';
|
||||||
|
import { InputTextarea } from 'primereact/inputtextarea';
|
||||||
|
import { InputText } from 'primereact/inputtext';
|
||||||
|
import ListOfFiles from '../DomandaEditPreInstructor/components/ListOfFiles';
|
||||||
|
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
||||||
|
import ApplicationInfo from '../DomandaEditPreInstructor/components/ApplicationInfo';
|
||||||
|
import ApplicationDownloadFiles from '../DomandaEditPreInstructor/components/ApplicationDownloadFiles';
|
||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
|
|
||||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||||
@@ -126,7 +120,7 @@ const DomandaEditInstructorManager = () => {
|
|||||||
navigate('/mie-domande');
|
navigate('/mie-domande');
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateFlagsForSoccorso = (data) => {
|
const updateFlagsForSoccorso = useCallback((data) => {
|
||||||
let nonRatedFilesLength = 0;
|
let nonRatedFilesLength = 0;
|
||||||
|
|
||||||
if (data.files) {
|
if (data.files) {
|
||||||
@@ -145,14 +139,28 @@ const DomandaEditInstructorManager = () => {
|
|||||||
|
|
||||||
setAllFilesRated(nonRatedFilesLength === 0);
|
setAllFilesRated(nonRatedFilesLength === 0);
|
||||||
|
|
||||||
if (data.checklist) {
|
if (data.evaluationVersion === 'V1') {
|
||||||
const checkedChecklistItems = data.checklist
|
if (data.checklist) {
|
||||||
.map(el => el.valid)
|
const checkedChecklistItems = data.checklist
|
||||||
.filter(v => v);
|
.map(el => el.valid)
|
||||||
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
.filter(v => v);
|
||||||
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
||||||
|
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
||||||
|
}
|
||||||
|
} else if (data.evaluationVersion === 'V2') {
|
||||||
|
const minChecks = data.numberOfCheck;
|
||||||
|
const formFieldsChecklist = formData
|
||||||
|
.filter(o => head(o.settings.filter(s => s.name === 'isChecklistItem' && s.value)))
|
||||||
|
.map(o => o.id);
|
||||||
|
|
||||||
|
if (formFieldsChecklist.length >= minChecks) {
|
||||||
|
const valuesTotal = formFieldsChecklist.map(v => formValues[v]);
|
||||||
|
const valuesFirst = valuesTotal.toSpliced(minChecks);
|
||||||
|
setAtLeastOneChecked(valuesTotal.filter(v => v === true).length === valuesTotal.length);
|
||||||
|
setAllChecksChecked(valuesFirst.filter(v => v === true).length === valuesFirst.length)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, [formValues]);
|
||||||
|
|
||||||
const doNewSoccorso = () => {
|
const doNewSoccorso = () => {
|
||||||
if (connectedSoccorsoId !== 0) {
|
if (connectedSoccorsoId !== 0) {
|
||||||
@@ -191,24 +199,43 @@ const DomandaEditInstructorManager = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCallback = (data) => {
|
const getCallback = (resp) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (resp.status === 'SUCCESS') {
|
||||||
setData(getFormattedData(data.data));
|
setData(getFormattedData(resp.data));
|
||||||
setMotivation(data.data.motivation);
|
setMotivation(resp.data.motivation);
|
||||||
updateFlagsForSoccorso(data.data);
|
updateFlagsForSoccorso(resp.data);
|
||||||
|
setFormData(resp.data.applicationEvaluationFormResponse.content);
|
||||||
|
setFormId(resp.data.applicationEvaluationFormResponse.id);
|
||||||
|
let formDataInitial = {};
|
||||||
|
|
||||||
|
if (resp.data.applicationEvaluationFormResponse.formFields) {
|
||||||
|
const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
|
||||||
|
fieldId: o.fieldId,
|
||||||
|
fieldValue: o.fieldValue
|
||||||
|
}));
|
||||||
|
formDataInitial = submitData.reduce((acc, cur) => {
|
||||||
|
if (cur.fieldValue) {
|
||||||
|
acc[cur.fieldId] = cur.fieldValue;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, formDataInitial);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
setFormInitialData(formDataInitial);
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const errGetCallback = (data) => {
|
const errGetCallback = (resp) => {
|
||||||
if (toast.current && data.message) {
|
if (toast.current && resp.message) {
|
||||||
toast.current.show({
|
toast.current.show({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
summary: '',
|
summary: '',
|
||||||
detail: data.message
|
detail: resp.message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
set404FromErrorResponse(data);
|
set404FromErrorResponse(resp);
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,6 +861,8 @@ const DomandaEditInstructorManager = () => {
|
|||||||
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
||||||
reset(updatedFormValues);
|
reset(updatedFormValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFlagsForSoccorso(data);
|
||||||
}, [formValues]);
|
}, [formValues]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const Profile = () => {
|
|||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCallback = (data) => {
|
const updateCallback = (data) => {
|
||||||
@@ -109,6 +109,7 @@ const Profile = () => {
|
|||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
fieldName="email"
|
fieldName="email"
|
||||||
|
disabled={true}
|
||||||
label={__('Email', 'gepafin')}
|
label={__('Email', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const ProfileBeneficiario = () => {
|
|||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCallback = (data) => {
|
const updateCallback = (data) => {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default class DashboardService {
|
|||||||
NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback);
|
NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
static getInstructorAmendmentsStats = (callback, errCallback) => {
|
static getInstructorAmendmentsStats = (callback, errCallback, queryParams) => {
|
||||||
NetworkService.get(`${API_BASE_URL}/dashboard/instructor/amendment`, callback, errCallback);
|
NetworkService.get(`${API_BASE_URL}/dashboard/instructor/amendment`, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export default class UserService {
|
|||||||
NetworkService.put(`${API_BASE_URL}/user/${id}`, body, callback, errCallback);
|
NetworkService.put(`${API_BASE_URL}/user/${id}`, body, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static updateUserSelf = (id, body, callback, errCallback) => {
|
||||||
|
NetworkService.put(`${API_BASE_URL}/user/${id}/update-details`, body, callback, errCallback);
|
||||||
|
};
|
||||||
|
|
||||||
static createUser = (body, callback, errCallback) => {
|
static createUser = (body, callback, errCallback) => {
|
||||||
NetworkService.post(`${API_BASE_URL}/user`, body, callback, errCallback);
|
NetworkService.post(`${API_BASE_URL}/user`, body, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user