diff --git a/src/helpers/validators.js b/src/helpers/validators.js index 8923b2b..d24c99d 100644 --- a/src/helpers/validators.js +++ b/src/helpers/validators.js @@ -1,3 +1,27 @@ -export const isVAT = (v) => { +export const isPIVA = (v) => { + return false; +} + +export const isCodiceFiscale = (v) => { + return false; +} + +export const isCAP = (v) => { + return false; +} + +export const isIBAN = (v) => { + return false; +} + +export const isEmail = (v) => { + return false; +} + +export const isEmailPEC = (v) => { + return false; +} + +export const isUrl = (v) => { return false; } \ No newline at end of file diff --git a/src/pages/BandoApplication/index.js b/src/pages/BandoApplication/index.js index ad3e8bc..2261841 100644 --- a/src/pages/BandoApplication/index.js +++ b/src/pages/BandoApplication/index.js @@ -12,7 +12,15 @@ import { storeSet, useStore } from '../../store'; import FormsService from '../../service/forms-service'; // tools -import { isVAT } from '../../helpers/validators'; +import { + isPIVA, + isCodiceFiscale, + isCAP, + isIBAN, + isEmail, + isEmailPEC, + isUrl +} from '../../helpers/validators'; // components import { Skeleton } from 'primereact/skeleton'; @@ -22,6 +30,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import { formData as testformData } from '../../tempData'; import BandoService from '../../service/bando-service'; +import ApplicationService from '../../service/application-service'; const BandoApplication = () => { const { id } = useParams(); @@ -41,20 +50,16 @@ const BandoApplication = () => { const values = getValues(); const validationFns = { - isVAT + isPIVA, + isCodiceFiscale, + isCAP, + isIBAN, + isEmail, + isEmailPEC, + isUrl } - const onSubmit = (formData) => { - /*const newFormData = Object.keys(formData).reduce((acc, cur) => { - acc.push({ - 'fieldId': cur, - 'fieldValue': formData[cur] && formData[cur].getMonth ? formData[cur].toISOString() : formData[cur] - }); - return acc; - }, []); - console.log('newFormData', newFormData); - console.log('errors', errors);*/ - }; + const onSubmit = () => {}; const saveDraft = () => { trigger(); @@ -70,7 +75,7 @@ const BandoApplication = () => { console.log('errors', errors); }; - const getBandoId = () => { + const getApplicationId = () => { const parsed = parseInt(id) return !isNaN(parsed) ? parsed : 0; } @@ -94,11 +99,11 @@ const BandoApplication = () => { } useEffect(() => { - const bandoId = getBandoId(); + const applId = getApplicationId(); - if (bandoId) { + if (applId) { storeSet.main.setAsyncRequest(); - FormsService.getFormsForCall(bandoId, getCallback, errGetCallbacks); + ApplicationService.getApplication(applId, getCallback, errGetCallbacks); } }, [id]); diff --git a/src/pages/BandoFormsEdit/components/BuilderElementItem/index.js b/src/pages/BandoFormsEdit/components/BuilderElementItem/index.js index e888a6f..8f77591 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementItem/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementItem/index.js @@ -4,7 +4,7 @@ import { ItemTypes } from '../ItemTypes'; import uniqid from '../../../../helpers/uniqid'; -const BuilderElementItem = ({ dbId, name, label }) => { +const BuilderElementItem = ({ dbId, name, label, description = '' }) => { const ref = useRef(null); const [{ isDragging }, drag] = useDrag(() => ({ @@ -28,7 +28,11 @@ const BuilderElementItem = ({ dbId, name, label }) => { drag(ref); return ( -
+
{label}
) diff --git a/src/pages/BandoFormsEdit/components/FormBuilder/index.js b/src/pages/BandoFormsEdit/components/FormBuilder/index.js index 8a346c8..a095f57 100644 --- a/src/pages/BandoFormsEdit/components/FormBuilder/index.js +++ b/src/pages/BandoFormsEdit/components/FormBuilder/index.js @@ -38,6 +38,7 @@ const FormBuilder = () => { dbId={item.id} label={item.label} name={item.name} + description={item.description} /> ) }, []); diff --git a/src/pages/BandoViewBeneficiario/index.js b/src/pages/BandoViewBeneficiario/index.js index fcc87ee..099cbfe 100644 --- a/src/pages/BandoViewBeneficiario/index.js +++ b/src/pages/BandoViewBeneficiario/index.js @@ -20,6 +20,7 @@ import BandoService from '../../service/bando-service'; import { Messages } from 'primereact/messages'; import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import FaqItemService from '../../service/faq-item-service'; +import ApplicationService from '../../service/application-service'; const BandoViewBeneficiario = () => { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -27,12 +28,9 @@ const BandoViewBeneficiario = () => { const navigate = useNavigate(); const [data, setData] = useState({}); const [newQuestion, setNewQuestion] = useState(''); + const [isApplRequest, setIsApplRequest] = useState(true); const bandoMsgs = useRef(null); - const closePreview = () => { - navigate(`/tenders/${id}`); - } - const scaricaBando = () => { } @@ -100,14 +98,14 @@ const BandoViewBeneficiario = () => { storeSet.main.unsetAsyncRequest(); } - const getCallback = (data) => { + const getBandoCallback = (data) => { if (data.status === 'SUCCESS') { setData(getFormattedBandiData(data.data)); } storeSet.main.unsetAsyncRequest(); } - const errGetCallback = (data) => { + const errGetBandoCallback = (data) => { if (bandoMsgs.current && data.message) { bandoMsgs.current.show([ { @@ -126,11 +124,33 @@ const BandoViewBeneficiario = () => { return data; }; + const getApplCallback = (data) => { + if (data.status === 'SUCCESS') { + console.log(data.data) + } + storeSet.main.unsetAsyncRequest(); + } + + const errGetApplCallback = (data) => { + /*if (bandoMsgs.current && data.message) { + bandoMsgs.current.show([ + { + sticky: true, severity: 'error', summary: '', + detail: data.message, + closable: true + } + ]); + }*/ + set404FromErrorResponse(data); + storeSet.main.unsetAsyncRequest(); + } + useEffect(() => { const parsed = parseInt(id) const bandoId = !isNaN(parsed) ? parsed : 0; storeSet.main.setAsyncRequest(); - BandoService.getBando(bandoId, getCallback, errGetCallback); + BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback); + ApplicationService.getApplications(getApplCallback, errGetApplCallback) }, [id]); return ( @@ -289,6 +309,7 @@ const BandoViewBeneficiario = () => { icon="pi pi-download" iconPos="right"/>