- 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,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}/>
<Column field="status" header={__('Stato', 'gepafin')}
style={{ minWidth: '7rem' }} body={statusBodyTemplate} />
<Column header={__('Azioni', 'gepafin')}
body={actionsBodyTemplate}/>
{!isEmpty(chosenCompanyId) && chosenCompanyId !== 0
? <Column header={__('Azioni', 'gepafin')}
body={actionsBodyTemplate}/> : null}
</DataTable>
</div>
)

View File

@@ -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) => {