- saving progress;
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { head, is, pluck, isEmpty, pathOr, isNil } from 'ramda';
|
||||
import { head, is, pluck, isEmpty, pathOr, isNil, uniq, uniqBy } from 'ramda';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import 'quill/dist/quill.core.css';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
@@ -47,6 +47,7 @@ import FileuploadApplicationSignedPdf from '../../components/FileuploadApplicati
|
||||
|
||||
import { defaultMaxFileSize } from '../../configData';
|
||||
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
||||
import CompanyDocumentsService from '../../service/company-documents-service';
|
||||
|
||||
const BandoApplication = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
@@ -62,6 +63,8 @@ const BandoApplication = () => {
|
||||
const [applicationStatus, setApplicationStatus] = useState('');
|
||||
const [activeStep, setActiveStep] = useState(1);
|
||||
const [signedPdfFile, setSignedPdfFile] = useState([]);
|
||||
const [companyDocs, setCompanyDocs] = useState([]);
|
||||
const [personalDocs, setPersonalDocs] = useState([]);
|
||||
const [isRequestForApplData, setIsRequestForApplData] = useState(false);
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const previousStatus = useRef('');
|
||||
@@ -217,7 +220,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
if (formField && ['fileupload', 'fileselect'].includes(formField.name)) {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
@@ -540,6 +543,27 @@ const BandoApplication = () => {
|
||||
? ['.p7m', '.pdf']
|
||||
: ['.p7m'];
|
||||
|
||||
const getDocsCallback = (resp, type) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (type === 'PERSONAL_DOCUMENT') {
|
||||
setPersonalDocs(uniqBy((o) => o.id, getFormattedDocsData(resp.data)));
|
||||
} else {
|
||||
setCompanyDocs(uniqBy((o) => o.id, getFormattedDocsData(resp.data)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const errDocsGetCallbacks = () => {
|
||||
}
|
||||
|
||||
const getFormattedDocsData = (data) => {
|
||||
return data.map((d) => {
|
||||
d.callEndDate = is(String, d.callEndDate) ? new Date(d.callEndDate) : (d.callEndDate ? d.callEndDate : '');
|
||||
return d;
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let updatedFormValues = klona(formValues);
|
||||
let context = {};
|
||||
@@ -628,6 +652,12 @@ const BandoApplication = () => {
|
||||
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['companyId', chosenCompanyId]
|
||||
]);
|
||||
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, (resp) => getDocsCallback(resp, 'COMPANY_DOCUMENT'), errDocsGetCallbacks, [
|
||||
['documentType', 'COMPANY_DOCUMENT']
|
||||
]);
|
||||
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, (resp) => getDocsCallback(resp, 'PERSONAL_DOCUMENT'), errDocsGetCallbacks, [
|
||||
['documentType', 'PERSONAL_DOCUMENT']
|
||||
]);
|
||||
}
|
||||
}, [id, chosenCompanyId]);
|
||||
|
||||
@@ -684,7 +714,9 @@ const BandoApplication = () => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
const placeholder = head(o.settings.filter(o => o.name === 'placeholder'));
|
||||
const options = head(o.settings.filter(o => o.name === 'options'));
|
||||
const options = ['fileselect'].includes(o.name)
|
||||
? {value: [...companyDocs, ...personalDocs]}
|
||||
: head(o.settings.filter(o => o.name === 'options'));
|
||||
let tableColumns = head(o.settings.filter(o => o.name === 'table_columns'));
|
||||
if (!tableColumns) {
|
||||
tableColumns = head(o.settings.filter(o => o.name === 'criteria_table_columns'));
|
||||
@@ -718,9 +750,9 @@ const BandoApplication = () => {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
if (o.name === 'fileselect') {
|
||||
console.log('options::', options)
|
||||
}
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
import { head, isEmpty, pathOr } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
@@ -22,6 +22,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const ref = useRef(null);
|
||||
const elements = useStore().main.formElements();
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const elementSettings = pathOr([], ['settings'], element);
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
@@ -134,10 +135,10 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
drag(drop(ref));
|
||||
|
||||
useEffect(() => {
|
||||
const variable = head(element.settings.filter(o => o.name === 'variable'));
|
||||
const formula = head(element.settings.filter(o => o.name === 'formula'));
|
||||
const isRequestedAmount = head(element.settings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const isDelegation = head(element.settings.filter(o => o.name === 'isDelegation'));
|
||||
const variable = head(elementSettings.filter(o => o.name === 'variable'));
|
||||
const formula = head(elementSettings.filter(o => o.name === 'formula'));
|
||||
const isRequestedAmount = head(elementSettings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const isDelegation = head(elementSettings.filter(o => o.name === 'isDelegation'));
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
@@ -151,12 +152,16 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
setIsRequestedAmount('tertiary');
|
||||
} else {
|
||||
setIsRequestedAmount(false);
|
||||
}
|
||||
|
||||
if (isDelegation && !isEmpty(isDelegation.value) && isDelegation.value) {
|
||||
setIsDelegation('tertiary');
|
||||
} else {
|
||||
setIsDelegation(false);
|
||||
}
|
||||
}, [elements]);
|
||||
}, [elementSettings]);
|
||||
|
||||
return (
|
||||
draggingElementId === id
|
||||
|
||||
Reference in New Issue
Block a user