- fixed issue of making calls with empty company id or it equal to 0;

This commit is contained in:
Vitalii Kiiko
2024-11-14 14:40:51 +01:00
parent b08e2d46c0
commit cf5f04d6c2
5 changed files with 35 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect} from 'react'; import React, { useState, useEffect} from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { is, uniq, isNil } from 'ramda'; import { is, uniq, isNil, isEmpty } from 'ramda';
import { wrap } from 'object-path-immutable'; import { wrap } from 'object-path-immutable';
// store // store
@@ -28,6 +28,7 @@ import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse
const AllBandiAccordion = () => { const AllBandiAccordion = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
const isAsyncRequest = useStore().main.isAsyncRequest(); const isAsyncRequest = useStore().main.isAsyncRequest();
const [items, setItems] = useState(null); const [items, setItems] = useState(null);
const [filters, setFilters] = useState(null); const [filters, setFilters] = useState(null);
@@ -113,11 +114,11 @@ const AllBandiAccordion = () => {
<div className="p-3"> <div className="p-3">
{renderHtmlContent(data.descriptionShort)} {renderHtmlContent(data.descriptionShort)}
<p>{__('Scadenza', 'gepafin')}: {getDateFromISOstring(data.dates[1])}</p> <p>{__('Scadenza', 'gepafin')}: {getDateFromISOstring(data.dates[1])}</p>
{!data.confidi {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && !data.confidi
? <Button onClick={() => goToBandoPage(data.id)} severity="info"> ? <Button onClick={() => goToBandoPage(data.id)} severity="info">
{__('Partecipa', 'gepafin')} {__('Partecipa', 'gepafin')}
</Button> : null} </Button> : null}
{data.confidi {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi
? <Button onClick={() => goToBandoPage(data.id)} severity="info"> ? <Button onClick={() => goToBandoPage(data.id)} severity="info">
{__('Mostra', 'gepafin')} {__('Mostra', 'gepafin')}
</Button> : null} </Button> : null}

View File

@@ -247,13 +247,15 @@ const BandoViewBeneficiario = () => {
const header = renderHeader(); const header = renderHeader();
useEffect(() => { useEffect(() => {
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
const bandoId = getBandoId(); const bandoId = getBandoId();
storeSet.main.setAsyncRequest(); storeSet.main.setAsyncRequest();
BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback); BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
['callId', bandoId], ['callId', bandoId],
['companyId', chosenCompanyId] ['companyId', chosenCompanyId]
]) ]);
}
}, [id, chosenCompanyId]); }, [id, chosenCompanyId]);
return ( return (

View File

@@ -1,10 +1,10 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { uniq } from 'ramda'; import { isEmpty, uniq } from 'ramda';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
// store // store
import { storeSet } from '../../../../store'; import { storeSet, useStore } from '../../../../store';
// api // api
import BandoService from '../../../../service/bando-service'; import BandoService from '../../../../service/bando-service';
@@ -22,6 +22,7 @@ import ProperBandoLabel from '../../../../components/ProperBandoLabel';
const LatestBandiTable = () => { const LatestBandiTable = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
const [items, setItems] = useState(null); const [items, setItems] = useState(null);
const [filters, setFilters] = useState(null); const [filters, setFilters] = useState(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -145,8 +146,9 @@ const LatestBandiTable = () => {
body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/> body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/>
<Column field="status" header={__('Stato', 'gepafin')} <Column field="status" header={__('Stato', 'gepafin')}
style={{ minWidth: '7rem' }} body={statusBodyTemplate} /> style={{ minWidth: '7rem' }} body={statusBodyTemplate} />
<Column header={__('Azioni', 'gepafin')} {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0
body={actionsBodyTemplate}/> ? <Column header={__('Azioni', 'gepafin')}
body={actionsBodyTemplate}/> : null}
</DataTable> </DataTable>
</div> </div>
) )

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { uniq, is } from 'ramda'; import { uniq, is, isEmpty } from 'ramda';
// tools // tools
import getBandoLabel from '../../../../helpers/getBandoLabel'; import getBandoLabel from '../../../../helpers/getBandoLabel';
@@ -36,11 +36,13 @@ const MyLatestSubmissionsTable = () => {
const [statuses, setStatuses] = useState([]); const [statuses, setStatuses] = useState([]);
useEffect(() => { useEffect(() => {
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
setLocalAsyncRequest(true); setLocalAsyncRequest(true);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
['companyId', chosenCompanyId], ['companyId', chosenCompanyId],
['statuses', ['DRAFT', 'AWAITING', 'READY']] ['statuses', ['DRAFT', 'AWAITING', 'READY']]
]) ]);
}
}, [chosenCompanyId]); }, [chosenCompanyId]);
const getApplCallback = (data) => { const getApplCallback = (data) => {

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { is, uniq } from 'ramda'; import { is, isEmpty, uniq } from 'ramda';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
// store // store
@@ -36,11 +36,13 @@ const BeneficiarioDomandeTable = () => {
const [statuses, setStatuses] = useState([]); const [statuses, setStatuses] = useState([]);
useEffect(() => { useEffect(() => {
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
setLocalAsyncRequest(true); setLocalAsyncRequest(true);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [ ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
['companyId', chosenCompanyId], ['companyId', chosenCompanyId],
['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION']] ['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION']]
]) ]);
}
}, [chosenCompanyId]); }, [chosenCompanyId]);
const getApplCallback = (data) => { const getApplCallback = (data) => {