- merged with master;

This commit is contained in:
Vitalii Kiiko
2024-10-22 14:41:28 +02:00
6 changed files with 32 additions and 24 deletions

View File

@@ -136,7 +136,8 @@ const Table = ({
return (
<>
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
{label}{config.required || config.isRequired ? <span className="appForm__field--required">*</span> : null}
{label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
? <span className="appForm__field--required">*</span> : null}
</label>
{rows ? <RenderTable columns={columns} data={rows} setRowsFn={updateRows}/> : null}
{!isEmpty(columns) && !shouldDisableNewRows

View File

@@ -1,5 +1,6 @@
import parse from 'html-react-parser';
import { isNil } from 'ramda';
const renderHtmlContent = (content) => parse(content);
const renderHtmlContent = (content = '') => !isNil(content) ? parse(content) : '';
export default renderHtmlContent;

View File

@@ -68,7 +68,6 @@ export const maxChecks = (v, num) => {
}
export const nonEmptyTables = (v = [], tableCfg = []) => {
//console.log('nonEmptyTables',v)
const colsCfg = pathOr([], ['stateFieldData'], tableCfg);
const nonPredefinedCells = colsCfg
.filter(o => !o.predefined)
@@ -76,22 +75,24 @@ export const nonEmptyTables = (v = [], tableCfg = []) => {
let isTableValid = true;
let atLeastOneCellFilled = false
// eslint-disable-next-line array-callback-return
v.map((row) => {
if (isEmpty(row)) {
isTableValid = false;
} else {
// eslint-disable-next-line array-callback-return
nonPredefinedCells.map((k) => {
if (isNil(row[k]) || isEmpty(row[k])) {
isTableValid = atLeastOneCellFilled;
} else {
atLeastOneCellFilled = true;
isTableValid = true;
}
});
}
});
if (is(Array, v)) {
// eslint-disable-next-line array-callback-return
v.map((row) => {
if (isEmpty(row)) {
isTableValid = false;
} else {
// eslint-disable-next-line array-callback-return
nonPredefinedCells.map((k) => {
if (isNil(row[k]) || isEmpty(row[k])) {
isTableValid = atLeastOneCellFilled;
} else {
atLeastOneCellFilled = true;
isTableValid = true;
}
});
}
});
}
return is(Array, v) ? v.length >= 1 && isTableValid : false;
}

View File

@@ -96,7 +96,7 @@ const BandoApplication = () => {
const submitApplicationCallback = (data) => {
if (data.status === 'SUCCESS') {
if (data.data.applicationStatus) {
if (data.data.status) {
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
}
}
@@ -275,7 +275,7 @@ const BandoApplication = () => {
acc[cur.fieldId] = cur.fieldValue;
return acc;
}, {});
reset();
setFormInitialData(formDataInitial);
}
}
@@ -394,7 +394,7 @@ const BandoApplication = () => {
useEffect(() => {
if (formInitialData) {
reset();
//reset();
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]))
}
}, [formInitialData]);
@@ -483,6 +483,7 @@ const BandoApplication = () => {
return acc;
}, {});
//console.log('validations', validations, o.name)
return ['paragraph'].includes(o.name) && text
? <div className="appForm__content" key={o.id}>{renderHtmlContent(text.value)}</div>

View File

@@ -176,7 +176,9 @@ const BandoView = () => {
<h2>{__('Allegati', 'gepafin')}</h2>
<div className="row rowContent">
<ul>
{data.docs.map((o, i) => <li key={i}>
{data.docs
.filter(o => o.source === 'CALL')
.map((o, i) => <li key={i}>
<a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a>
</li>)}
</ul>

View File

@@ -324,7 +324,9 @@ const BandoViewBeneficiario = () => {
<h2>{__('Allegati', 'gepafin')}</h2>
<div className="row rowContent">
<ul>
{data.docs.map((o, i) => <li key={i}>
{data.docs
.filter(o => o.source === 'CALL')
.map((o, i) => <li key={i}>
<a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a>
</li>)}
</ul>