From a42806c0f0334e07efefc783663e64cab71646cc Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 11 Nov 2024 14:16:33 +0100 Subject: [PATCH 01/13] - added btn 'add to favourites; --- src/assets/scss/components/appPage.scss | 14 +++-- .../components/AllBandiAccordion/index.js | 9 ++- .../components/LatestBandiTable/index.js | 63 ++++++++++++------- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index 3c62a17..4fdac21 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -355,8 +355,8 @@ .appPageSection__tableActions { display: flex; - gap: 24px; - padding: 0; + gap: 10px; + align-items: center; flex-wrap: wrap; } @@ -368,12 +368,18 @@ justify-content: center; border-radius: 50%; border: none; - background-color: var(--message-info-color); - color: white; + background-color: transparent; + color: var(--global-textColor); padding: 0; &:hover { cursor: pointer; + color: var(--message-info-color); + } + + &[data-active="true"] { + background-color: var(--message-info-color); + color: white; } &[disabled] { diff --git a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js index 0fc5fe1..183e894 100644 --- a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js +++ b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js @@ -102,7 +102,9 @@ const AllBandiAccordion = () => { const actionsBodyTemplate = (rowData) => { return
-
@@ -151,8 +153,9 @@ const AllBandiAccordion = () => { - {/**/} + ) diff --git a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js index 301094f..9ae2864 100644 --- a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js +++ b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js @@ -55,6 +55,10 @@ const LatestBandiTable = () => { storeSet.main.unsetAsyncRequest(); } + const addToFavourites = (id) => { + + } + const getFormattedData = (data) => { return [...(data || [])].map((d) => { d.start_date = new Date(d.dates[0]); @@ -89,9 +93,18 @@ const LatestBandiTable = () => { const initFilters = () => { setFilters({ global: { value: null, matchMode: FilterMatchMode.CONTAINS }, - name: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, - start_date: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, - end_date: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, + name: { + operator: FilterOperator.AND, + constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] + }, + start_date: { + operator: FilterOperator.AND, + constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] + }, + end_date: { + operator: FilterOperator.AND, + constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] + }, status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] } }); setGlobalFilterValue(''); @@ -100,10 +113,12 @@ const LatestBandiTable = () => { const renderHeader = () => { return (
-
); @@ -118,26 +133,31 @@ const LatestBandiTable = () => { }; const dateFilterTemplate = (options) => { - return options.filterCallback(e.value, options.index)} dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999" />; + return options.filterCallback(e.value, options.index)} + dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>; }; const statusBodyTemplate = (rowData) => { return ; }; - const statusItemTemplate = (option) => { - return ; - }; - const actionsBodyTemplate = (rowData) => { - return rowData.confidi - ? - + {rowData.confidi + ? + - }*/ + } const rowExpansionTemplate = (data) => { return ( @@ -151,10 +183,10 @@ const AllBandiAccordion = () => { diff --git a/src/pages/BandiBeneficiario/index.js b/src/pages/BandiBeneficiario/index.js index 66942d3..8165092 100644 --- a/src/pages/BandiBeneficiario/index.js +++ b/src/pages/BandiBeneficiario/index.js @@ -1,10 +1,8 @@ import React from 'react'; import { __ } from '@wordpress/i18n'; -import { useNavigate } from 'react-router-dom'; // components import AllBandiAccordion from './components/AllBandiAccordion'; -import { Button } from 'primereact/button'; const BandiBeneficiario = () => { return( diff --git a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js index ba04ffb..ab791ef 100644 --- a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js +++ b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js @@ -4,7 +4,7 @@ import { uniq } from 'ramda'; import { Link } from 'react-router-dom'; // store -import { storeSet } from '../../../../store'; +import { storeGet, storeSet } from '../../../../store'; // api import BandoService from '../../../../service/bando-service'; @@ -19,6 +19,8 @@ import { InputIcon } from 'primereact/inputicon'; import { Button } from 'primereact/button'; import { Calendar } from 'primereact/calendar'; import ProperBandoLabel from '../../../../components/ProperBandoLabel'; +import PreferredBandoService from '../../../../service/preferred-bando-service'; +import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; const LatestBandiTable = () => { @@ -29,7 +31,7 @@ const LatestBandiTable = () => { const [statuses, setStatuses] = useState([]); useEffect(() => { - storeSet.main.setAsyncRequest(); + setLoading(true); BandoService.getBandi(getCallback, errGetCallbacks); }, []); @@ -40,16 +42,47 @@ const LatestBandiTable = () => { setStatuses(uniq(data.data.map(o => o.status))) initFilters(); } - storeSet.main.unsetAsyncRequest(); + setLoading(false); } const errGetCallbacks = (data) => { - console.log('errGetCallbacks', data) - storeSet.main.unsetAsyncRequest(); + set404FromErrorResponse(data); + setLoading(false); } - const addToFavourites = (id) => { + const addToFavourites = (id, preferredId = 0) => { + const companyId = storeGet.main.chosenCompanyId() + const data = { + companyId, + callId: id + } + setLoading(true); + if (preferredId !== 0) { + // TODO implement removing from preferrenced + //PreferredBandoService.addToPreferred(data, toggleFavCallback, errToggleFavCallback); + } else { + PreferredBandoService.addToPreferred(data, toggleFavCallback, errToggleFavCallback); + } + } + const toggleFavCallback = (data) => { + if (data.status === 'SUCCESS') { + const newItems = items.map((o) => { + if (o.id === data.data.callId) { + return { + ...o, + preferred: data.data.id + } + } else { + return o; + } + }); + setItems(newItems) + } + } + + const errToggleFavCallback = (data) => { + set404FromErrorResponse(data); } const getFormattedData = (data) => { @@ -138,7 +171,8 @@ const LatestBandiTable = () => { return
{rowData.confidi diff --git a/src/service/preferred-bando-service.js b/src/service/preferred-bando-service.js new file mode 100644 index 0000000..1738e85 --- /dev/null +++ b/src/service/preferred-bando-service.js @@ -0,0 +1,10 @@ +import { NetworkService } from './network-service'; + +const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS; + +export default class PreferredBandoService { + + static addToPreferred = (body, callback, errCallback) => { + NetworkService.post(`${API_BASE_URL}/beneficiaryPreferredCall`, body, callback, errCallback); + }; +} From 2ed3fd010bde94c4af32fa05160d523d0ef303ec Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 13 Nov 2024 15:46:48 +0100 Subject: [PATCH 03/13] - enabled assigning in staging; --- src/pages/Domande/components/AllDomandeTable/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Domande/components/AllDomandeTable/index.js b/src/pages/Domande/components/AllDomandeTable/index.js index 5b09ae8..ca0598f 100644 --- a/src/pages/Domande/components/AllDomandeTable/index.js +++ b/src/pages/Domande/components/AllDomandeTable/index.js @@ -163,8 +163,8 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/> - {/**/} +
) From 2ce8107f2cc6f6bba16604c62c5c27d025590b30 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 13 Nov 2024 15:58:50 +0100 Subject: [PATCH 04/13] - added 'preview' btn for the tables of applications submitted; --- .../components/AllDomandeTable/index.js | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/pages/Domande/components/AllDomandeTable/index.js b/src/pages/Domande/components/AllDomandeTable/index.js index ca0598f..6039d0b 100644 --- a/src/pages/Domande/components/AllDomandeTable/index.js +++ b/src/pages/Domande/components/AllDomandeTable/index.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect} from 'react'; +import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; import { is, uniq } from 'ramda'; import { Link } from 'react-router-dom'; @@ -101,10 +101,12 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { const renderHeader = () => { return (
-
); @@ -119,7 +121,8 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { }; const dateFilterTemplate = (options) => { - return options.filterCallback(e.value, options.index)} dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999" />; + return options.filterCallback(e.value, options.index)} + dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>; }; const statusBodyTemplate = (rowData) => { @@ -127,19 +130,25 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { }; const actionsBodyTemplate = (rowData) => { - return openDialogFn - ? diff --git a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js index ab791ef..51c8bc8 100644 --- a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js +++ b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js @@ -1,10 +1,10 @@ import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; -import { uniq } from 'ramda'; +import { uniq, isNil } from 'ramda'; import { Link } from 'react-router-dom'; // store -import { storeGet, storeSet } from '../../../../store'; +import { storeGet } from '../../../../store'; // api import BandoService from '../../../../service/bando-service'; @@ -50,28 +50,27 @@ const LatestBandiTable = () => { setLoading(false); } - const addToFavourites = (id, preferredId = 0) => { + const addToFavourites = (id, preferredId) => { const companyId = storeGet.main.chosenCompanyId() const data = { companyId, callId: id } setLoading(true); - if (preferredId !== 0) { - // TODO implement removing from preferrenced - //PreferredBandoService.addToPreferred(data, toggleFavCallback, errToggleFavCallback); + if (preferredId && preferredId !== 0) { + PreferredBandoService.deleteFromPreferred(preferredId, (data) => removeFavCallback(data, id), errToggleFavCallback); } else { - PreferredBandoService.addToPreferred(data, toggleFavCallback, errToggleFavCallback); + PreferredBandoService.addToPreferred(data, addFavCallback, errToggleFavCallback); } } - const toggleFavCallback = (data) => { + const removeFavCallback = (data, id) => { if (data.status === 'SUCCESS') { const newItems = items.map((o) => { - if (o.id === data.data.callId) { + if (o.id === id) { return { ...o, - preferred: data.data.id + preferredCallId: null } } else { return o; @@ -79,10 +78,28 @@ const LatestBandiTable = () => { }); setItems(newItems) } + setLoading(false); + } + const addFavCallback = (data) => { + if (data.status === 'SUCCESS') { + const newItems = items.map((o) => { + if (o.id === data.data.callId) { + return { + ...o, + preferredCallId: data.data.id + } + } else { + return o; + } + }); + setItems(newItems) + } + setLoading(false); } const errToggleFavCallback = (data) => { set404FromErrorResponse(data); + setLoading(false); } const getFormattedData = (data) => { @@ -171,8 +188,8 @@ const LatestBandiTable = () => { return
{rowData.confidi diff --git a/src/service/preferred-bando-service.js b/src/service/preferred-bando-service.js index 1738e85..95416af 100644 --- a/src/service/preferred-bando-service.js +++ b/src/service/preferred-bando-service.js @@ -7,4 +7,8 @@ export default class PreferredBandoService { static addToPreferred = (body, callback, errCallback) => { NetworkService.post(`${API_BASE_URL}/beneficiaryPreferredCall`, body, callback, errCallback); }; + + static deleteFromPreferred = (id, callback, errCallback) => { + NetworkService.delete(`${API_BASE_URL}/beneficiaryPreferredCall/${id}`, {}, callback, errCallback); + }; } From ee47a48f99c66443f036b9e6cc96db6c6e0340d4 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 14 Nov 2024 11:45:06 +0100 Subject: [PATCH 06/13] - saving progress; --- src/pages/BandiBeneficiario/index.js | 2 - .../components/BandoEditFormStep1/index.js | 39 +++++++++++-------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/pages/BandiBeneficiario/index.js b/src/pages/BandiBeneficiario/index.js index 66942d3..8165092 100644 --- a/src/pages/BandiBeneficiario/index.js +++ b/src/pages/BandiBeneficiario/index.js @@ -1,10 +1,8 @@ import React from 'react'; import { __ } from '@wordpress/i18n'; -import { useNavigate } from 'react-router-dom'; // components import AllBandiAccordion from './components/AllBandiAccordion'; -import { Button } from 'primereact/button'; const BandiBeneficiario = () => { return( diff --git a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js index 4117123..8f92b67 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js @@ -176,8 +176,12 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st storeSet.main.unsetAsyncRequest(); } - const shouldDisableField = () => { - return values.status === 'PUBLISH' + const shouldDisableField = (fieldName) => { + return values.status === 'PUBLISH' && + ![ + 'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold', + 'aimedTo', 'criteria', 'docs', 'checklist', 'faq' + ].includes(fieldName) } useImperativeHandle( @@ -239,7 +243,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st Date: Thu, 14 Nov 2024 14:27:19 +0100 Subject: [PATCH 07/13] Make some call fields editable after publishing the call - call form fields are editable (according to the list of keys); - some parts of the form are editable; --- src/assets/scss/components/appForm.scss | 1 + src/assets/scss/components/misc.scss | 4 ++++ src/components/FormFieldRepeater/index.js | 1 + .../FormFieldRepeaterCriteria/index.js | 1 + src/components/FormFieldRepeaterFaq/index.js | 1 + .../components/BandoEditFormActions/index.js | 6 +++-- .../components/BandoEditFormStep1/index.js | 3 ++- .../components/BandoEditFormStep2/index.js | 17 +++++++++----- .../components/BuilderElement/index.js | 22 ++----------------- .../components/ElementSetting/index.js | 4 +++- .../ElementSettingRepeater/index.js | 7 +++--- .../ElementSettingTableColumns/index.js | 18 ++++++++++----- .../BuilderElementSettings/index.js | 3 ++- .../components/FormBuilder/index.js | 7 +++--- src/pages/BandoFormsEdit/index.js | 8 +++---- 15 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/assets/scss/components/appForm.scss b/src/assets/scss/components/appForm.scss index c114ba9..bb532bd 100644 --- a/src/assets/scss/components/appForm.scss +++ b/src/assets/scss/components/appForm.scss @@ -147,6 +147,7 @@ .appForm__fileUploadItemName { color: var(--global-textColor); font-style: italic; + text-align: left; } .appForm__row { diff --git a/src/assets/scss/components/misc.scss b/src/assets/scss/components/misc.scss index c276636..0b795e1 100644 --- a/src/assets/scss/components/misc.scss +++ b/src/assets/scss/components/misc.scss @@ -118,6 +118,10 @@ user-select: none; } +.p-dropdown-panel { + max-width: 100%; +} + .p-inputgroup.flex-1 { align-items: center; } diff --git a/src/components/FormFieldRepeater/index.js b/src/components/FormFieldRepeater/index.js index 9d69312..fe00a72 100644 --- a/src/components/FormFieldRepeater/index.js +++ b/src/components/FormFieldRepeater/index.js @@ -73,6 +73,7 @@ const FormFieldRepeater = ({ const properField = (item, i) => { return !isNil(item.lookUpDataId) ? selectItem(e, i)} optionDisabled={(opt) => usedExistingValues().includes(opt.value)} diff --git a/src/components/FormFieldRepeaterCriteria/index.js b/src/components/FormFieldRepeaterCriteria/index.js index 7882cf8..9f96447 100644 --- a/src/components/FormFieldRepeaterCriteria/index.js +++ b/src/components/FormFieldRepeaterCriteria/index.js @@ -79,6 +79,7 @@ const FormFieldRepeaterCriteria = ({ const properField = (item, i) => { return !isNil(item.lookUpDataId) ? selectItem(e, i)} optionDisabled={(opt) => usedExistingValues().includes(opt.value)} diff --git a/src/components/FormFieldRepeaterFaq/index.js b/src/components/FormFieldRepeaterFaq/index.js index 2420943..5ba60a3 100644 --- a/src/components/FormFieldRepeaterFaq/index.js +++ b/src/components/FormFieldRepeaterFaq/index.js @@ -182,6 +182,7 @@ const FormFieldRepeaterFaq = ({ disabled={disabled} icon="pi pi-plus" onClick={addNewItem}/> selectItem(e)} + filter disabled={disabled} optionDisabled={(opt) => usedExistingValues().includes(opt.title)} options={stateOptionsData} diff --git a/src/pages/BandoEdit/components/BandoEditFormActions/index.js b/src/pages/BandoEdit/components/BandoEditFormActions/index.js index 3b65462..b431c89 100644 --- a/src/pages/BandoEdit/components/BandoEditFormActions/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormActions/index.js @@ -5,14 +5,16 @@ import { isNil } from 'ramda'; // components import { Button } from 'primereact/button'; -const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn }) => { +const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn, status }) => { return (
) - - /*return ( -
- {draggingId === id - ?
- : <> -
- - -
-
-
- - } -
- )*/ } export default BuilderElement; \ No newline at end of file diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js index 6264b89..6e2dcfc 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js @@ -11,7 +11,7 @@ import { Editor } from 'primereact/editor'; import { mimeTypes } from '../../../../../../configData'; import ElementSettingTableColumns from '../ElementSettingTableColumns'; -const ElementSetting = ({ setting, changeFn, updateDataFn }) => { +const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => { const settingLabels = { label: __('Label', 'gepafin'), @@ -48,6 +48,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn }) => { return } else if (setting.name === 'mime') { return { return } else { return { const [stateFieldData, setStateFieldData] = useState([]); @@ -53,10 +54,10 @@ const ElementSettingRepeater = ({ {stateFieldData.map((o, i) =>
{properField(o, i)} -
)} -
) } diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js index 5815843..9681540 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js @@ -14,7 +14,8 @@ import uniqid from '../../../../../../helpers/uniqid'; const ElementSettingTableColumns = ({ value, name, - setDataFn + setDataFn, + bandoStatus }) => { const [stateFieldData, setStateFieldData] = useState([]); const [rowsData, setRowsData] = useState([]); @@ -34,7 +35,7 @@ const ElementSettingTableColumns = ({ .reduce((acc, cur) => { acc[cur.name] = '' return acc; - }, {}); + }, {}); setRowsData([...rowsData, obj]); } @@ -87,7 +88,10 @@ const ElementSettingTableColumns = ({ onInputChange(e, i)}/>
{__('Predefinito?', 'gepafin')} - setChecked(e.value, i)}/> + setChecked(e.value, i)}/>
} @@ -118,10 +122,10 @@ const ElementSettingTableColumns = ({ {stateFieldData.map((o, i) =>
{properField(o, i)} -
)} - : null} - {data.confidi + {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi ? : null} diff --git a/src/pages/BandoViewBeneficiario/index.js b/src/pages/BandoViewBeneficiario/index.js index c452129..3496c13 100644 --- a/src/pages/BandoViewBeneficiario/index.js +++ b/src/pages/BandoViewBeneficiario/index.js @@ -247,13 +247,15 @@ const BandoViewBeneficiario = () => { const header = renderHeader(); useEffect(() => { - const bandoId = getBandoId(); - storeSet.main.setAsyncRequest(); - BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback); - ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ - ['callId', bandoId], - ['companyId', chosenCompanyId] - ]) + if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) { + const bandoId = getBandoId(); + storeSet.main.setAsyncRequest(); + BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback); + ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ + ['callId', bandoId], + ['companyId', chosenCompanyId] + ]); + } }, [id, chosenCompanyId]); return ( diff --git a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js index 5e381d9..a5dd246 100644 --- a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js +++ b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js @@ -1,10 +1,10 @@ import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; -import { uniq } from 'ramda'; +import { isEmpty, uniq } from 'ramda'; import { Link } from 'react-router-dom'; // store -import { storeSet } from '../../../../store'; +import { storeSet, useStore } from '../../../../store'; // api import BandoService from '../../../../service/bando-service'; @@ -22,6 +22,7 @@ import ProperBandoLabel from '../../../../components/ProperBandoLabel'; const LatestBandiTable = () => { + const chosenCompanyId = useStore().main.chosenCompanyId(); const [items, setItems] = useState(null); const [filters, setFilters] = useState(null); const [loading, setLoading] = useState(false); @@ -145,8 +146,9 @@ const LatestBandiTable = () => { body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/> - + {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 + ? : null} ) diff --git a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js index 608b2ba..ce3f987 100644 --- a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js +++ b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; -import { uniq, is } from 'ramda'; +import { uniq, is, isEmpty } from 'ramda'; // tools import getBandoLabel from '../../../../helpers/getBandoLabel'; @@ -36,11 +36,13 @@ const MyLatestSubmissionsTable = () => { const [statuses, setStatuses] = useState([]); useEffect(() => { - setLocalAsyncRequest(true); - ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ - ['companyId', chosenCompanyId], - ['statuses', ['DRAFT', 'AWAITING', 'READY']] - ]) + if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) { + setLocalAsyncRequest(true); + ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ + ['companyId', chosenCompanyId], + ['statuses', ['DRAFT', 'AWAITING', 'READY']] + ]); + } }, [chosenCompanyId]); const getApplCallback = (data) => { diff --git a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js index d97fd2e..22ac157 100644 --- a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js +++ b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; -import { is, uniq } from 'ramda'; +import { is, isEmpty, uniq } from 'ramda'; import { Link } from 'react-router-dom'; // store @@ -36,11 +36,13 @@ const BeneficiarioDomandeTable = () => { const [statuses, setStatuses] = useState([]); useEffect(() => { - setLocalAsyncRequest(true); - ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ - ['companyId', chosenCompanyId], - ['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION']] - ]) + if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) { + setLocalAsyncRequest(true); + ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ + ['companyId', chosenCompanyId], + ['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION']] + ]); + } }, [chosenCompanyId]); const getApplCallback = (data) => { From 11a1c351088797e3599b35a67264fd1948833d37 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Fri, 15 Nov 2024 14:28:23 +0100 Subject: [PATCH 09/13] - updates in labels and some refactoring; --- src/configData.js | 31 ++++++++++++++++++- .../components/BandoEditFormActions/index.js | 6 ++-- .../components/BandoEditFormStep1/index.js | 2 +- .../components/BandoEditFormStep2/index.js | 2 +- src/pages/BandoFlowEdit/index.js | 2 +- src/pages/BandoForms/index.js | 4 +-- .../ElementSettingTableColumns/index.js | 4 ++- .../BuilderElementSettings/index.js | 3 +- src/pages/BandoFormsEdit/index.js | 2 +- src/pages/DomandaEditPreInstructor/index.js | 4 +++ 10 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/configData.js b/src/configData.js index a7d3d1c..5de2560 100644 --- a/src/configData.js +++ b/src/configData.js @@ -13,4 +13,33 @@ export const mimeTypes = [ } ]; -export const defaultMaxFileSize = 314572800; // 314572800 = 300 Mb \ No newline at end of file +export const defaultMaxFileSize = 314572800; // 314572800 = 300 Mb + +const dynamicDataForTextinput = [ + { label: 'company name', value: 'company.companyName' }, + { label: 'company piva', value: 'company.vatNumber' }, + { label: 'company codiceFiscale', value: 'company.codiceFiscale' }, + { label: 'company address', value: 'company.address' }, + { label: 'company phoneNumber', value: 'company.phoneNumber' }, + { label: 'company city', value: 'company.city' }, + { label: 'company province', value: 'company.province' }, + { label: 'company cap', value: 'company.cap' }, + { label: 'company country', value: 'company.country' }, + { label: 'company pec', value: 'company.pec' }, + { label: 'company email', value: 'company.email' }, + { label: 'company contactName', value: 'company.contactName' }, + { label: 'company contactEmail', value: 'company.contactEmail' }, + { label: 'user email', value: 'user.email' }, + { label: 'user firstName', value: 'user.firstName' }, + { label: 'user lastName', value: 'user.lastName' }, + { label: 'user phoneNumber', value: 'user.phoneNumber' }, + { label: 'user codiceFiscale', value: 'user.codiceFiscale' } +] + +export const dynamicDataOptions = { + datepicker: [ + { label: 'user dateOfBirth', value: 'user.dateOfBirth' } + ], + textinput: dynamicDataForTextinput, + textarea: dynamicDataForTextinput +} \ No newline at end of file diff --git a/src/pages/BandoEdit/components/BandoEditFormActions/index.js b/src/pages/BandoEdit/components/BandoEditFormActions/index.js index b431c89..4658387 100644 --- a/src/pages/BandoEdit/components/BandoEditFormActions/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormActions/index.js @@ -5,7 +5,7 @@ import { isNil } from 'ramda'; // components import { Button } from 'primereact/button'; -const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn, status }) => { +const BandoEditFormActions = ({ id, openPreview, submitFn, status }) => { return (
@@ -21,13 +21,13 @@ const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn outlined onClick={openPreview} label={__('Anteprima beneficiario', 'gepafin')} icon="pi pi-eye" iconPos="right"/> -
) diff --git a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js index 4e3d009..0baca40 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js @@ -112,7 +112,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st toast.current.show({ severity: 'success', summary: '', - detail: __('Il bando è stato aggiornato corretamente!', 'gepafin') + detail: __('Il bando è stato aggiornato correttamente!', 'gepafin') }); } const values = getValues(); diff --git a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js index d861c97..5b8e098 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js @@ -104,7 +104,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st toast.current.show({ severity: 'success', summary: '', - detail: __('Il bando è stato aggiornato corretamente!', 'gepafin') + detail: __('Il bando è stato aggiornato correttamente!', 'gepafin') }); const newFormData = {...formInitialData, ...data.data}; setFormInitialData(newFormData); diff --git a/src/pages/BandoFlowEdit/index.js b/src/pages/BandoFlowEdit/index.js index f10d9e0..e6b210d 100644 --- a/src/pages/BandoFlowEdit/index.js +++ b/src/pages/BandoFlowEdit/index.js @@ -112,7 +112,7 @@ const BandoFlowEdit = () => { toast.current.show({ severity: 'success', summary: '', - detail: __('Il flusso è stato aggiornato corretamente!', 'gepafin') + detail: __('Il flusso è stato aggiornato correttamente!', 'gepafin') }); } } diff --git a/src/pages/BandoForms/index.js b/src/pages/BandoForms/index.js index ea70e59..cee1051 100644 --- a/src/pages/BandoForms/index.js +++ b/src/pages/BandoForms/index.js @@ -91,7 +91,7 @@ const BandoForms = () => { toast.current.show({ severity: 'success', summary: '', - detail: __('Il form è stato aggiornato corretamente!', 'gepafin') + detail: __('Il form è stato aggiornato correttamente!', 'gepafin') }); } @@ -235,7 +235,7 @@ const BandoForms = () => { outlined disabled={!selectedForm} onClick={goToEditForm} - label={'PUBLISH' === bandoStatus ? __('Mostra', 'gepafin') : __('Modifica', 'gepafin')} + label={__('Modifica', 'gepafin')} icon="pi pi-cog" iconPos="right"/> diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js index 9681540..5537956 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingTableColumns/index.js @@ -137,7 +137,9 @@ const ElementSettingTableColumns = ({ return
{properSubField(c, k, o.name)} -
diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js index a22a4ac..79b8671 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js @@ -16,6 +16,7 @@ import { InputSwitch } from 'primereact/inputswitch'; import ElementSetting from './components/ElementSetting'; import { Dropdown } from 'primereact/dropdown'; import { MultiSelect } from 'primereact/multiselect'; +import { dynamicDataOptions } from '../../../../configData'; const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => { const elements = useStore().main.formElements(); @@ -166,7 +167,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => { changeFn={onChange} updateDataFn={onUpdateOptions}/>) : null} - {['textinput', 'datepicker'].includes(activeElementData.name) + {!isNil(dynamicDataOptions[activeElementData.name]) ?
{ toast.current.show({ severity: 'success', summary: '', - detail: __('Il form è stato aggiornato corretamente!', 'gepafin') + detail: __('Il form è stato aggiornato correttamente!', 'gepafin') }); } } diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index e3871e3..82d1dd3 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -329,6 +329,10 @@ const DomandaEditPreInstructor = () => {

+
+ +
+

{__('Punteggi di valutazione', 'gepafin')}

{data.criteria From 0534b7cd0a0eaffd919931d3eb63905712c18ac2 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 18 Nov 2024 13:50:47 +0100 Subject: [PATCH 10/13] - fixed detecting unsaved changes; --- src/components/TopBarProfileMenu/index.js | 1 + src/components/UnsavedChangesDetector/index.js | 4 +++- src/pages/BandoEdit/components/BandoEditFormStep1/index.js | 5 +++-- src/pages/BandoEdit/components/BandoEditFormStep2/index.js | 5 +++-- src/pages/BandoEdit/index.js | 6 ++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/TopBarProfileMenu/index.js b/src/components/TopBarProfileMenu/index.js index 4288572..2c3c729 100644 --- a/src/components/TopBarProfileMenu/index.js +++ b/src/components/TopBarProfileMenu/index.js @@ -78,6 +78,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => { icon: 'pi pi-sign-out', command: () => { storeSet.main.doLogout(); + window.location.reload(); }, enable: true } diff --git a/src/components/UnsavedChangesDetector/index.js b/src/components/UnsavedChangesDetector/index.js index 86c21fd..fefef9d 100644 --- a/src/components/UnsavedChangesDetector/index.js +++ b/src/components/UnsavedChangesDetector/index.js @@ -26,6 +26,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { } formData = wrap(formData).insert(['dates'], starDate, 0).value(); + delete formData.startDate; } if (formData.endDate) { let endDate; @@ -38,6 +39,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { } formData = wrap(formData).insert(['dates'], endDate, 1).value(); + delete formData.endDate; } if (!isNil(formData.startTime)) { if (!is(String, formData.startTime)) { @@ -54,7 +56,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { const initial = storeGet.main.formInitialData(); const isEqual = equal(initial, formData); - // TODO + // debug /*console.log('isEqual', isEqual, initial, formData, diff(initial, formData))*/ diff --git a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js index 0baca40..07f5ad5 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js @@ -27,7 +27,7 @@ import { storeSet } from '../../../../store'; import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString'; -const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, status }, ref) { +const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) { const navigate = useNavigate(); const [aimedToOptions, setAimedToOptions] = useState([]); const [faqOptions, setFaqOptions] = useState([]); @@ -86,7 +86,6 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st formData.startTime = tzAwareDate.toISOString().substring(11, 16); } } - if (!isNil(formData.endTime)) { if (!is(String, formData.endTime)) { const tzAwareDate = new TZDate(formData.endTime, 'Europe/Berlin'); @@ -120,6 +119,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st navigate(`/bandi/${data.data.id}`); } else { setFormInitialData(data.data); + setInitialData(data.data); } } } @@ -202,6 +202,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st }, [errors, isValid]); useEffect(() => { + console.log('here1') storeSet.main.formInitialData(initialData); setFormInitialData(initialData); }, [initialData]); diff --git a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js index 5b8e098..791c2c1 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js @@ -24,7 +24,7 @@ import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString import { mimeTypes } from '../../../../configData'; import { wrap } from 'object-path-immutable'; -const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, status }, ref) { +const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) { const navigate = useNavigate(); const [criteriaOptions, setCriteriaOptions] = useState([]); const [checklistOptions, setChecklistOptions] = useState([]); @@ -108,7 +108,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st }); const newFormData = {...formInitialData, ...data.data}; setFormInitialData(newFormData); - storeSet.main.formInitialData(newFormData); + setInitialData(newFormData); } } @@ -174,6 +174,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st }, [errors, isValid]); useEffect(() => { + console.log('here2') storeSet.main.formInitialData(initialData); setFormInitialData(initialData); }, [initialData]); diff --git a/src/pages/BandoEdit/index.js b/src/pages/BandoEdit/index.js index b7f3ee6..f9b0951 100644 --- a/src/pages/BandoEdit/index.js +++ b/src/pages/BandoEdit/index.js @@ -288,9 +288,11 @@ const BandoEdit = () => { {!isEmpty(data) ? <> {activeStep === 0 - ? : null} + ? + : null} {activeStep === 1 - ? : null} + ? + : null}

{__('Crea o modifica il Form compilabile dal Beneficiario', 'gepafin')}

From c698de622b38cb5f2a53a21bb29cb30f8c4af606 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 18 Nov 2024 15:13:20 +0100 Subject: [PATCH 11/13] - fixed issue with number form field; - fixed issue with datepicker form field; - updated tables displaying submitted calls; --- src/assets/scss/components/appPage.scss | 4 ++++ .../FormField/components/Datepicker/index.js | 23 +++++++++---------- .../FormField/components/NumberInput/index.js | 10 +++++--- .../components/BandoEditFormStep1/index.js | 1 - .../components/BandoEditFormStep2/index.js | 1 - .../MyLatestSubmissionsTable/index.js | 2 +- .../components/AllDomandeTable/index.js | 6 ++--- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index 54a8fba..dd87777 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -375,6 +375,10 @@ gap: 24px; padding: 0; flex-wrap: wrap; + + &.lessGap { + gap: 12px; + } } .appPageSection__addToFavourites { diff --git a/src/components/FormField/components/Datepicker/index.js b/src/components/FormField/components/Datepicker/index.js index 6744491..b33c13c 100644 --- a/src/components/FormField/components/Datepicker/index.js +++ b/src/components/FormField/components/Datepicker/index.js @@ -28,18 +28,17 @@ const Datepicker = ({ control={control} defaultValue={defaultValue} rules={config} - render={({ field, fieldState }) => ( - field.onChange(e.value)} - dateFormat="dd/mm/yy" - hourFormat="24" - timeOnly={timeOnly} - showIcon - minDate={minDate} - maxDate={maxDate} - className={classNames({ 'p-invalid': fieldState.invalid })}/> + render={({ field, fieldState }) => ( field.onChange(e.value)} + dateFormat="dd/mm/yy" + hourFormat="24" + timeOnly={timeOnly} + showIcon + minDate={minDate} + maxDate={maxDate} + className={classNames({ 'p-invalid': fieldState.invalid })}/> )}/> {infoText ? {infoText} : null} ) diff --git a/src/components/FormField/components/NumberInput/index.js b/src/components/FormField/components/NumberInput/index.js index d5d4ee4..62a90e9 100644 --- a/src/components/FormField/components/NumberInput/index.js +++ b/src/components/FormField/components/NumberInput/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { classNames } from 'primereact/utils'; import { Controller } from 'react-hook-form'; -import { is } from 'ramda'; +import { is, isEmpty } from 'ramda'; import { InputNumber } from 'primereact/inputnumber'; @@ -23,6 +23,8 @@ const NumberInput = ({ disabled = false, useGrouping = true }) => { + const minAttr = config.min ? config.min : min; + const maxAttr = config.max ? config.max : max; const input = field.onChange(e.value)} - min={min} - max={max} + min={minAttr} + max={maxAttr} locale={locale} useGrouping={useGrouping} maxFractionDigits={!isNaN(parseInt(maxFractionDigits)) ? parseInt(maxFractionDigits) : 0} @@ -45,6 +47,8 @@ const NumberInput = ({ <> {inputgroup ?
diff --git a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js index 07f5ad5..5d1d12b 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js @@ -202,7 +202,6 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g }, [errors, isValid]); useEffect(() => { - console.log('here1') storeSet.main.formInitialData(initialData); setFormInitialData(initialData); }, [initialData]); diff --git a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js index 791c2c1..8ce097e 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js @@ -174,7 +174,6 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g }, [errors, isValid]); useEffect(() => { - console.log('here2') storeSet.main.formInitialData(initialData); setFormInitialData(initialData); }, [initialData]); diff --git a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js index ce3f987..75a7865 100644 --- a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js +++ b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js @@ -40,7 +40,7 @@ const MyLatestSubmissionsTable = () => { setLocalAsyncRequest(true); ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ['companyId', chosenCompanyId], - ['statuses', ['DRAFT', 'AWAITING', 'READY']] + ['statuses', ['DRAFT', 'AWAITING', 'READY', 'SUBMIT']] ]); } }, [chosenCompanyId]); diff --git a/src/pages/Domande/components/AllDomandeTable/index.js b/src/pages/Domande/components/AllDomandeTable/index.js index 6039d0b..eb0ae9e 100644 --- a/src/pages/Domande/components/AllDomandeTable/index.js +++ b/src/pages/Domande/components/AllDomandeTable/index.js @@ -31,7 +31,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { useEffect(() => { setLocalAsyncRequest(true); ApplicationService.getApplications(getCallback, errGetCallbacks, [ - ['statuses', 'SUBMIT'] + ['statuses', ['SUBMIT', 'EVALUATION', 'SOCCORSO']] ]); }, [updaterString]); @@ -130,7 +130,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { }; const actionsBodyTemplate = (rowData) => { - return <> + return
{openDialogFn ?
} const header = renderHeader(); From 291f76984034d07297ffe92476c1305ec36bb6a3 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 18 Nov 2024 16:44:28 +0100 Subject: [PATCH 12/13] - implemnted functionality adding to preferred calls; --- .../components/AllBandiAccordion/index.js | 6 +- src/pages/BandoViewBeneficiario/index.js | 57 ++++++++++++++++--- .../components/LatestBandiTable/index.js | 6 +- src/service/bando-service.js | 8 +-- 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js index 615f0f1..e6a155f 100644 --- a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js +++ b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js @@ -39,8 +39,10 @@ const AllBandiAccordion = () => { useEffect(() => { storeSet.main.setAsyncRequest(); - BandoService.getBandi(getCallback, errGetCallbacks); - }, []); + BandoService.getBandi(getCallback, errGetCallbacks, [ + ['companyId', chosenCompanyId] + ]); + }, [chosenCompanyId]); const getCallback = (data) => { if (data.status === 'SUCCESS') { diff --git a/src/pages/BandoViewBeneficiario/index.js b/src/pages/BandoViewBeneficiario/index.js index 3496c13..bcb7bc0 100644 --- a/src/pages/BandoViewBeneficiario/index.js +++ b/src/pages/BandoViewBeneficiario/index.js @@ -5,7 +5,7 @@ import { is, isEmpty, isNil } from 'ramda'; import "quill/dist/quill.core.css"; // store -import { storeSet, useStore } from '../../store'; +import { storeGet, storeSet, useStore } from '../../store'; // tools import getNumberWithCurrency from '../../helpers/getNumberWithCurrency'; @@ -28,6 +28,7 @@ import { Message } from 'primereact/message'; import { Toast } from 'primereact/toast'; import { Editor } from 'primereact/editor'; import { Dialog } from 'primereact/dialog'; +import PreferredBandoService from '../../service/preferred-bando-service'; const BandoViewBeneficiario = () => { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -246,11 +247,50 @@ const BandoViewBeneficiario = () => { const header = renderHeader(); + const addToFavourites = () => { + const companyId = storeGet.main.chosenCompanyId(); + const bandoId = getBandoId(); + const formdData = { + companyId, + callId: bandoId + } + + if (data.preferredCallId && data.preferredCallId !== 0) { + PreferredBandoService.deleteFromPreferred(data.preferredCallId, removeFavCallback, errToggleFavCallback); + } else { + PreferredBandoService.addToPreferred(formdData, addFavCallback, errToggleFavCallback); + } + } + + const removeFavCallback = (resp) => { + if (resp.status === 'SUCCESS') { + const newData = { + ...data, + preferredCallId: null + } + setData(newData); + } + } + const addFavCallback = (resp) => { + if (resp.status === 'SUCCESS') { + const newData = { + ...data, + preferredCallId: resp.data.id + } + setData(newData); + } + } + const errToggleFavCallback = (data) => { + set404FromErrorResponse(data); + } + useEffect(() => { if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) { const bandoId = getBandoId(); storeSet.main.setAsyncRequest(); - BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback); + BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback, [ + ['companyId', chosenCompanyId] + ]); ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ['callId', bandoId], ['companyId', chosenCompanyId] @@ -445,14 +485,15 @@ const BandoViewBeneficiario = () => { onClick={submitApplication} label={submitBtnLabel()} icon={submitBtnIcon()} iconPos="right"/> - {/*
diff --git a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js index b6cb22c..0de8d69 100644 --- a/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js +++ b/src/pages/DashboardBeneficiario/components/LatestBandiTable/index.js @@ -33,8 +33,10 @@ const LatestBandiTable = () => { useEffect(() => { setLoading(true); - BandoService.getBandi(getCallback, errGetCallbacks); - }, []); + BandoService.getBandi(getCallback, errGetCallbacks, [ + ['companyId', chosenCompanyId] + ]); + }, [chosenCompanyId]); const getCallback = (data) => { if (data.status === 'SUCCESS') { diff --git a/src/service/bando-service.js b/src/service/bando-service.js index 60b70b1..dfda3f4 100644 --- a/src/service/bando-service.js +++ b/src/service/bando-service.js @@ -4,12 +4,12 @@ const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS; export default class BandoService { - static getBandi = (callback, errCallback) => { - NetworkService.get(`${API_BASE_URL}/call`, callback, errCallback); + static getBandi = (callback, errCallback, queryParams) => { + NetworkService.get(`${API_BASE_URL}/call`, callback, errCallback, queryParams); }; - static getBando = (id, callback, errCallback) => { - NetworkService.get(`${API_BASE_URL}/call/${id}`, callback, errCallback); + static getBando = (id, callback, errCallback, queryParams) => { + NetworkService.get(`${API_BASE_URL}/call/${id}`, callback, errCallback, queryParams); }; static validateBando = (id, callback, errCallback) => { From e59a64ae7b9c3f4dcd000b59b919e555722dac47 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Tue, 19 Nov 2024 08:52:48 +0100 Subject: [PATCH 13/13] - removed submitted applications from Applications page and display them in Archive page for beneficiary; --- .../components/MyLatestSubmissionsTable/index.js | 2 +- .../components/BeneficiarioDomandeTable/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js index 75a7865..ce3f987 100644 --- a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js +++ b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js @@ -40,7 +40,7 @@ const MyLatestSubmissionsTable = () => { setLocalAsyncRequest(true); ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ['companyId', chosenCompanyId], - ['statuses', ['DRAFT', 'AWAITING', 'READY', 'SUBMIT']] + ['statuses', ['DRAFT', 'AWAITING', 'READY']] ]); } }, [chosenCompanyId]); diff --git a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js index 22ac157..56bc773 100644 --- a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js +++ b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js @@ -40,7 +40,7 @@ const BeneficiarioDomandeTable = () => { setLocalAsyncRequest(true); ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ['companyId', chosenCompanyId], - ['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION']] + ['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT']] ]); } }, [chosenCompanyId]);