diff --git a/src/pages/SoccorsoEditPreInstructor/index.js b/src/pages/SoccorsoEditPreInstructor/index.js
index d0835be..f048d4e 100644
--- a/src/pages/SoccorsoEditPreInstructor/index.js
+++ b/src/pages/SoccorsoEditPreInstructor/index.js
@@ -1,7 +1,7 @@
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useEffect, useRef, useMemo } from 'react';
import { __ } from '@wordpress/i18n';
import { useNavigate, useParams } from 'react-router-dom';
-import { is, isEmpty, isNil } from 'ramda';
+import { head, is, isEmpty, isNil, pathOr } from 'ramda';
import { wrap } from 'object-path-immutable';
// store
@@ -26,6 +26,13 @@ import { classNames } from 'primereact/utils';
import { Dialog } from 'primereact/dialog';
import { InputText } from 'primereact/inputtext';
import { InputTextarea } from 'primereact/inputtextarea';
+import { klona } from 'klona';
+import { useForm } from 'react-hook-form';
+import FormField from '../../components/FormField';
+import uniqid from '../../helpers/uniqid';
+import { Editor } from 'primereact/editor';
+import { TZDate } from '@date-fns/tz';
+import { InputNumber } from 'primereact/inputnumber';
const SoccorsoEditPreInstructor = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
@@ -36,10 +43,28 @@ const SoccorsoEditPreInstructor = () => {
const [isVisibleNewCommDialog, setIsVisibleNewCommDialog] = useState(false);
const [newCommData, setNewCommData] = useState({});
const [isLoadingCommunication, setIsLoadingCommunication] = useState(false);
+ const [isVisibleExtendTimeDialog, setIsVisibleExtendTimeDialog] = useState(false);
+ const [extendedTime, setExtendedTime] = useState(3);
+ const [isLoadingExtendingTime, setIsLoadingExtendingTime] = useState(false);
const toast = useRef(null);
+ const [formInitialData, setFormInitialData] = useState({});
+ const {
+ control,
+ handleSubmit,
+ formState: { errors, isValid },
+ setValue,
+ register,
+ trigger,
+ getValues,
+ clearErrors
+ } = useForm({
+ defaultValues: useMemo(() => {
+ return formInitialData;
+ }, [formInitialData]), mode: 'onChange'
+ });
const goToEvaluationPage = () => {
- //navigate('/domande');
+ navigate(`/domande/${id}`);
}
const getCallback = (data) => {
@@ -64,7 +89,7 @@ const SoccorsoEditPreInstructor = () => {
const getCommsCallback = (data) => {
if (data.status === 'SUCCESS') {
- setComms(data.data.commentsList);
+ setComms(data.data.commentsList.map(o => getFormattedCommsData(o)));
}
storeSet.main.unsetAsyncRequest();
}
@@ -87,31 +112,19 @@ const SoccorsoEditPreInstructor = () => {
return data;
};
- const renderHeader = () => {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
+ const getFormattedCommsData = (data) => {
+ data.id = isNil(data.id) ? uniqid('id') : data.id;
+ data.commentedDate = is(String, data.commentedDate) ? new Date(data.commentedDate) : (data.commentedDate ? data.commentedDate : '');
+ data.createdDate = is(String, data.createdDate) ? new Date(data.createdDate) : (data.createdDate ? data.createdDate : '');
+ data.updatedDate = is(String, data.updatedDate) ? new Date(data.updatedDate) : (data.updatedDate ? data.updatedDate : '');
+ return data;
};
- const header = renderHeader();
-
- const headerEditDialog = () => {
+ const headerNewComDialog = () => {
return
{__('Aggiungi comunicazione', 'gepafin')}
}
- const hideEditDialog = () => {
+ const hideNewComDialog = () => {
setIsVisibleNewCommDialog(false);
setNewCommData({
title: '',
@@ -119,9 +132,9 @@ const SoccorsoEditPreInstructor = () => {
});
}
- const footerEditDialog = () => {
+ const footerNewComDialog = () => {
return
-
+
@@ -245,7 +426,8 @@ const SoccorsoEditPreInstructor = () => {