From 1b37b7b548a525931c09acf0652f51976299c5ba Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Tue, 22 Oct 2024 12:51:58 +0200 Subject: [PATCH 1/3] - fixed validating table form field; - fixed issue with bando preview; --- .../FormField/components/Table/index.js | 3 +- src/helpers/renderHtmlContent.js | 2 +- src/helpers/validators.js | 35 ++++++++++--------- src/pages/BandoApplication/index.js | 5 +-- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/components/FormField/components/Table/index.js b/src/components/FormField/components/Table/index.js index d02badb..5d80b09 100644 --- a/src/components/FormField/components/Table/index.js +++ b/src/components/FormField/components/Table/index.js @@ -136,7 +136,8 @@ const Table = ({ return ( <> {rows ? : null} {!isEmpty(columns) && !shouldDisableNewRows diff --git a/src/helpers/renderHtmlContent.js b/src/helpers/renderHtmlContent.js index 8a59d21..61f176f 100644 --- a/src/helpers/renderHtmlContent.js +++ b/src/helpers/renderHtmlContent.js @@ -1,5 +1,5 @@ import parse from 'html-react-parser'; -const renderHtmlContent = (content) => parse(content); +const renderHtmlContent = (content = '') => parse(content); export default renderHtmlContent; \ No newline at end of file diff --git a/src/helpers/validators.js b/src/helpers/validators.js index e4f9aff..3a05435 100644 --- a/src/helpers/validators.js +++ b/src/helpers/validators.js @@ -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; } \ No newline at end of file diff --git a/src/pages/BandoApplication/index.js b/src/pages/BandoApplication/index.js index 9272991..bdbf0bd 100644 --- a/src/pages/BandoApplication/index.js +++ b/src/pages/BandoApplication/index.js @@ -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'? } } @@ -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 ?
{renderHtmlContent(text.value)}
From 81f6ca04c3eba6f57f73140f233f598ce64d4d38 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Tue, 22 Oct 2024 13:07:54 +0200 Subject: [PATCH 2/3] - added filter for bando docs; --- src/pages/BandoApplication/index.js | 2 +- src/pages/BandoViewBeneficiario/index.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/BandoApplication/index.js b/src/pages/BandoApplication/index.js index bdbf0bd..5b3d9a5 100644 --- a/src/pages/BandoApplication/index.js +++ b/src/pages/BandoApplication/index.js @@ -275,7 +275,7 @@ const BandoApplication = () => { acc[cur.fieldId] = cur.fieldValue; return acc; }, {}); - + reset(); setFormInitialData(formDataInitial); } } diff --git a/src/pages/BandoViewBeneficiario/index.js b/src/pages/BandoViewBeneficiario/index.js index 0ddec79..34d728f 100644 --- a/src/pages/BandoViewBeneficiario/index.js +++ b/src/pages/BandoViewBeneficiario/index.js @@ -324,7 +324,9 @@ const BandoViewBeneficiario = () => {

{__('Allegati', 'gepafin')}

    - {data.docs.map((o, i) =>
  • + {data.docs + .filter(o => o.source === 'CALL') + .map((o, i) =>
  • {o.name}
  • )}
From f11845084787942a05188c4d9f67e615488c7d56 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Tue, 22 Oct 2024 13:28:40 +0200 Subject: [PATCH 3/3] - updated bando preview by admin; --- src/helpers/renderHtmlContent.js | 3 ++- src/pages/BandoView/index.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/renderHtmlContent.js b/src/helpers/renderHtmlContent.js index 61f176f..672546a 100644 --- a/src/helpers/renderHtmlContent.js +++ b/src/helpers/renderHtmlContent.js @@ -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; \ No newline at end of file diff --git a/src/pages/BandoView/index.js b/src/pages/BandoView/index.js index 3e78d30..2132270 100644 --- a/src/pages/BandoView/index.js +++ b/src/pages/BandoView/index.js @@ -176,7 +176,9 @@ const BandoView = () => {

{__('Allegati', 'gepafin')}

    - {data.docs.map((o, i) =>
  • + {data.docs + .filter(o => o.source === 'CALL') + .map((o, i) =>
  • {o.name}
  • )}