- fixed login for confidi users;
- restyled fileselect UI;
This commit is contained in:
@@ -37,7 +37,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (role === 'ROLE_BENEFICIARY') {
|
if (['ROLE_BENEFICIARY', 'ROLE_CONFIDI'].includes(role)) {
|
||||||
const userData = storeGet.main.userData();
|
const userData = storeGet.main.userData();
|
||||||
if (userData.companies && !isEmpty(userData.companies)) {
|
if (userData.companies && !isEmpty(userData.companies)) {
|
||||||
storeSet.main.companies(userData.companies);
|
storeSet.main.companies(userData.companies);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ListBox } from 'primereact/listbox';
|
|||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import CompanyDocumentsService from '../../../../service/company-documents-service';
|
import CompanyDocumentsService from '../../../../service/company-documents-service';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import FileUploadService from '../../../../service/file-upload-service';
|
||||||
|
|
||||||
const FileSelect = ({
|
const FileSelect = ({
|
||||||
fieldName,
|
fieldName,
|
||||||
@@ -29,6 +30,7 @@ const FileSelect = ({
|
|||||||
const [selectedUnconfirmed, setSelectedUnconfirmed] = useState([]);
|
const [selectedUnconfirmed, setSelectedUnconfirmed] = useState([]);
|
||||||
const [optionsTransformed, setOptionsTransformed] = useState([]);
|
const [optionsTransformed, setOptionsTransformed] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [addNewMode, setAddNewMode] = useState(false);
|
||||||
|
|
||||||
const attachSelectedFiles = useCallback(() => {
|
const attachSelectedFiles = useCallback(() => {
|
||||||
const existingIds = pluck('id', stateFieldData.current);
|
const existingIds = pluck('id', stateFieldData.current);
|
||||||
@@ -43,10 +45,12 @@ const FileSelect = ({
|
|||||||
['documentType', source]
|
['documentType', source]
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
|
setAddNewMode(false);
|
||||||
}, [selectedUnconfirmed]);
|
}, [selectedUnconfirmed]);
|
||||||
|
|
||||||
const removeAttached = (id) => {
|
const doGoBackToListOfFiles = () => {
|
||||||
console.log('stateFieldData', stateFieldData, id)
|
setSelectedUnconfirmed([]);
|
||||||
|
setAddNewMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const callback = (resp) => {
|
const callback = (resp) => {
|
||||||
@@ -62,9 +66,30 @@ const FileSelect = ({
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
const removeAttached = (id) => {
|
||||||
|
FileUploadService.deleteFile(
|
||||||
|
{},
|
||||||
|
(data) => deleteCallback(data, id),
|
||||||
|
deleteErrorCallback,
|
||||||
|
[['id', id]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteCallback = (data, id) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
stateFieldData.current = stateFieldData.current.filter(o => id !== o.id);
|
||||||
|
setDataFn(fieldName, stateFieldData.current, { shouldValidate: true });
|
||||||
|
saveFormCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteErrorCallback = (err) => {
|
||||||
|
console.log('err', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*useEffect(() => {
|
||||||
console.log('selectedUnconfirmed', selectedUnconfirmed)
|
console.log('selectedUnconfirmed', selectedUnconfirmed)
|
||||||
}, [selectedUnconfirmed]);
|
}, [selectedUnconfirmed]);*/
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
stateFieldData.current = defaultValue;
|
stateFieldData.current = defaultValue;
|
||||||
@@ -73,6 +98,7 @@ const FileSelect = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isEmpty(options)) {
|
if (!isEmpty(options)) {
|
||||||
|
console.log('options', options);
|
||||||
const optionsDefault = [
|
const optionsDefault = [
|
||||||
{
|
{
|
||||||
label: __('Documenti dell\'Azienda', 'gepafin'),
|
label: __('Documenti dell\'Azienda', 'gepafin'),
|
||||||
@@ -92,7 +118,7 @@ const FileSelect = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
stateFieldData.current = defaultValue;
|
stateFieldData.current = defaultValue;
|
||||||
}, [defaultValue]);
|
}, [defaultValue]);
|
||||||
|
//console.log([...stateFieldData.current])
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||||
@@ -100,25 +126,32 @@ const FileSelect = ({
|
|||||||
<span className="appForm__field--required">*</span> : null}
|
<span className="appForm__field--required">*</span> : null}
|
||||||
</label>
|
</label>
|
||||||
<div className="fileselectInner">
|
<div className="fileselectInner">
|
||||||
<div className="fileselectInner__selectionBox">
|
{addNewMode
|
||||||
<ListBox multiple
|
? <div className="fileselectInner__selectionBox">
|
||||||
value={selectedUnconfirmed}
|
<ListBox multiple
|
||||||
onChange={(e) => setSelectedUnconfirmed(e.value)}
|
value={selectedUnconfirmed}
|
||||||
options={optionsTransformed}
|
onChange={(e) => setSelectedUnconfirmed(e.value)}
|
||||||
optionLabel="name"
|
options={optionsTransformed}
|
||||||
optionGroupLabel="label"
|
optionLabel="name"
|
||||||
optionGroupChildren="items"
|
optionGroupLabel="label"
|
||||||
className="w-full md:w-14rem"
|
optionGroupChildren="items"
|
||||||
listStyle={{ maxHeight: '130px' }}/>
|
className="w-full md:w-14rem"
|
||||||
{!isEmpty(optionsTransformed)
|
listStyle={{ maxHeight: '130px' }}/>
|
||||||
? <Button
|
{!isEmpty(selectedUnconfirmed)
|
||||||
severity="success"
|
? <Button
|
||||||
disabled={loading}
|
severity="success"
|
||||||
onClick={attachSelectedFiles}
|
disabled={loading}
|
||||||
label={__('Conferma i file scelti', 'gepafin')}
|
onClick={attachSelectedFiles}
|
||||||
icon="pi pi-arrow-right" size="small" iconPos="right"/> : null}
|
label={__('Conferma i file scelti', 'gepafin')}
|
||||||
</div>
|
icon="pi pi-arrow-right" size="small" iconPos="right"/>
|
||||||
{!isEmpty(optionsTransformed)
|
: <Button
|
||||||
|
severity="success"
|
||||||
|
outlined
|
||||||
|
onClick={doGoBackToListOfFiles}
|
||||||
|
label={__('Torna alla lista dei file selezionati', 'gepafin')}
|
||||||
|
icon="pi pi-arrow-right" size="small" iconPos="right"/>}
|
||||||
|
</div> : null}
|
||||||
|
{!isEmpty(optionsTransformed) && !addNewMode
|
||||||
? <div className="fileselectInner__selectedFiles">
|
? <div className="fileselectInner__selectedFiles">
|
||||||
<p>{__('I file selezionati')}</p>
|
<p>{__('I file selezionati')}</p>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -134,6 +167,12 @@ const FileSelect = ({
|
|||||||
</div>
|
</div>
|
||||||
</li>)}
|
</li>)}
|
||||||
</ul>
|
</ul>
|
||||||
|
<Button
|
||||||
|
severity="success"
|
||||||
|
disabled={loading}
|
||||||
|
onClick={() => setAddNewMode(true)}
|
||||||
|
label={__('Aggiungi i file', 'gepafin')}
|
||||||
|
icon="pi pi-plus" size="small" iconPos="right"/>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
</div>
|
</div>
|
||||||
{isEmpty(optionsTransformed)
|
{isEmpty(optionsTransformed)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
command: () => {
|
command: () => {
|
||||||
navigate('/profilo-aziendale')
|
navigate('/profilo-aziendale')
|
||||||
},
|
},
|
||||||
enable: intersection(permissions, ['APPLY_CALLS']).length && companies.length > 0
|
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length && companies.length > 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __('Seleziona azienda', 'gepafin'),
|
label: __('Seleziona azienda', 'gepafin'),
|
||||||
@@ -67,7 +67,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
command: () => {
|
command: () => {
|
||||||
navigate('/agguingi-azienda')
|
navigate('/agguingi-azienda')
|
||||||
},
|
},
|
||||||
enable: intersection(permissions, ['APPLY_CALLS']).length
|
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
separator: true,
|
separator: true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect} from 'react';
|
import React, { useState, useEffect} from 'react';
|
||||||
import { __, sprintf } from '@wordpress/i18n';
|
import { __, sprintf } from '@wordpress/i18n';
|
||||||
import { is, uniq, isNil, isEmpty } from 'ramda';
|
import { is, uniq, isNil, isEmpty, head } from 'ramda';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
|||||||
|
|
||||||
const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
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);
|
||||||
@@ -45,11 +46,15 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeSet.main.setAsyncRequest();
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
BandoService.getBandi(getCallback, errGetCallbacks, [
|
|
||||||
['companyId', chosenCompanyId],
|
if (existingCompany && !isAsyncRequest) {
|
||||||
['onlyPreferredCall', showOnlyPreferred]
|
storeSet.main.setAsyncRequest();
|
||||||
]);
|
BandoService.getBandi(getCallback, errGetCallbacks, [
|
||||||
|
['companyId', chosenCompanyId],
|
||||||
|
['onlyPreferredCall', showOnlyPreferred]
|
||||||
|
]);
|
||||||
|
}
|
||||||
}, [chosenCompanyId]);
|
}, [chosenCompanyId]);
|
||||||
|
|
||||||
const getCallback = (data) => {
|
const getCallback = (data) => {
|
||||||
|
|||||||
@@ -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, isEmpty } from 'ramda';
|
import { is, uniq, isNil, isEmpty, head } from 'ramda';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
|||||||
|
|
||||||
const AllBandiPreferredAccordion = () => {
|
const AllBandiPreferredAccordion = () => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
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);
|
||||||
@@ -38,12 +39,16 @@ const AllBandiPreferredAccordion = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeSet.main.setAsyncRequest();
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
const userData = storeGet.main.userData();
|
|
||||||
PreferredBandoService.getPreferredCalls(getCallback, errGetCallbacks, [
|
if (existingCompany) {
|
||||||
['companyId', chosenCompanyId],
|
storeSet.main.setAsyncRequest();
|
||||||
['userId', userData.id]
|
const userData = storeGet.main.userData();
|
||||||
]);
|
PreferredBandoService.getPreferredCalls(getCallback, errGetCallbacks, [
|
||||||
|
['companyId', chosenCompanyId],
|
||||||
|
['userId', userData.id]
|
||||||
|
]);
|
||||||
|
}
|
||||||
}, [chosenCompanyId]);
|
}, [chosenCompanyId]);
|
||||||
|
|
||||||
const getCallback = (data) => {
|
const getCallback = (data) => {
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ const BandoApplicationPreview = () => {
|
|||||||
|
|
||||||
if (applId) {
|
if (applId) {
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
const queryParams = 'ROLE_BENEFICIARY' === role
|
const queryParams = ['ROLE_BENEFICIARY', 'ROLE_CONFIDI'].includes(role)
|
||||||
? [
|
? [
|
||||||
['companyId', chosenCompanyId]
|
['companyId', chosenCompanyId]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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, isEmpty } from 'ramda';
|
import { uniq, is, head } from 'ramda';
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
@@ -28,13 +28,16 @@ import { ConfirmPopup, confirmPopup } from 'primereact/confirmpopup';
|
|||||||
|
|
||||||
const MyLatestSubmissionsTable = () => {
|
const MyLatestSubmissionsTable = () => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
const [items, setItems] = useState(null);
|
const [items, setItems] = useState(null);
|
||||||
const [filters, setFilters] = useState(null);
|
const [filters, setFilters] = useState(null);
|
||||||
const [statuses, setStatuses] = useState([]);
|
const [statuses, setStatuses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
|
if (existingCompany) {
|
||||||
setLocalAsyncRequest(true);
|
setLocalAsyncRequest(true);
|
||||||
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
||||||
['companyId', chosenCompanyId],
|
['companyId', chosenCompanyId],
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { head, isEmpty, pathOr } from 'ramda';
|
|||||||
import NumberFlow from '@number-flow/react';
|
import NumberFlow from '@number-flow/react';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { useStore } from '../../store';
|
import { storeSet, useStore } from '../../store';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import DashboardService from '../../service/dashboard-service';
|
import DashboardService from '../../service/dashboard-service';
|
||||||
|
|||||||
@@ -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 { head, is, uniq } from 'ramda';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { useStore } from '../../../../store';
|
import { useStore } from '../../../../store';
|
||||||
@@ -26,13 +26,16 @@ import { confirmPopup, ConfirmPopup } from 'primereact/confirmpopup';
|
|||||||
|
|
||||||
const DocumentsTable = ({ type, reload = 0 }) => {
|
const DocumentsTable = ({ type, reload = 0 }) => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
const [docs, setDocs] = useState([]);
|
const [docs, setDocs] = useState([]);
|
||||||
const [filters, setFilters] = useState(null);
|
const [filters, setFilters] = useState(null);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [statuses, setStatuses] = useState([]);
|
const [statuses, setStatuses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && chosenCompanyId && chosenCompanyId !== 0 && reload !== 0) {
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
|
if (!loading && existingCompany && reload !== 0) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, getCallback, errGetCallbacks, [
|
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, getCallback, errGetCallbacks, [
|
||||||
['documentType', type]
|
['documentType', type]
|
||||||
@@ -41,10 +44,14 @@ const DocumentsTable = ({ type, reload = 0 }) => {
|
|||||||
}, [chosenCompanyId, reload]);
|
}, [chosenCompanyId, reload]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, getCallback, errGetCallbacks, [
|
|
||||||
['documentType', type]
|
if (existingCompany) {
|
||||||
]);
|
setLoading(true);
|
||||||
|
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, getCallback, errGetCallbacks, [
|
||||||
|
['documentType', type]
|
||||||
|
]);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getCallback = (resp) => {
|
const getCallback = (resp) => {
|
||||||
|
|||||||
@@ -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, isEmpty, uniq } from 'ramda';
|
import { head, is, uniq } from 'ramda';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
@@ -27,13 +27,16 @@ import translationStrings from '../../../../translationStringsForComponents';
|
|||||||
|
|
||||||
const BeneficiarioDomandeTable = () => {
|
const BeneficiarioDomandeTable = () => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
const [items, setItems] = useState(null);
|
const [items, setItems] = useState(null);
|
||||||
const [filters, setFilters] = useState(null);
|
const [filters, setFilters] = useState(null);
|
||||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
const [statuses, setStatuses] = useState([]);
|
const [statuses, setStatuses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && !localAsyncRequest) {
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
|
if (existingCompany && !localAsyncRequest) {
|
||||||
setLocalAsyncRequest(true);
|
setLocalAsyncRequest(true);
|
||||||
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
||||||
['companyId', chosenCompanyId],
|
['companyId', chosenCompanyId],
|
||||||
|
|||||||
@@ -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, isEmpty, uniq } from 'ramda';
|
import { head, is, uniq } from 'ramda';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { useStore } from '../../../../store';
|
import { useStore } from '../../../../store';
|
||||||
@@ -21,6 +21,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
|||||||
|
|
||||||
const BeneficiarioUltimeDomandeTable = () => {
|
const BeneficiarioUltimeDomandeTable = () => {
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
const [items, setItems] = useState(null);
|
const [items, setItems] = useState(null);
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const [filters, setFilters] = useState(null);
|
const [filters, setFilters] = useState(null);
|
||||||
@@ -43,7 +44,9 @@ const BeneficiarioUltimeDomandeTable = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && !localAsyncRequest) {
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
|
if (existingCompany && !localAsyncRequest) {
|
||||||
const bodyParams = getPaginationQuery(
|
const bodyParams = getPaginationQuery(
|
||||||
['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT'],
|
['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT'],
|
||||||
1
|
1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { isEmpty, pathOr } from 'ramda';
|
import { head, isEmpty, pathOr } from 'ramda';
|
||||||
import NumberFlow from '@number-flow/react';
|
import NumberFlow from '@number-flow/react';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
@@ -16,6 +16,7 @@ const StatsBeneficiary = () => {
|
|||||||
const [mainStats, setMainStats] = useState({});
|
const [mainStats, setMainStats] = useState({});
|
||||||
const [chartStats, setChartStats] = useState({});
|
const [chartStats, setChartStats] = useState({});
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
|
|
||||||
const getStats = (resp) => {
|
const getStats = (resp) => {
|
||||||
if (resp.status === 'SUCCESS') {
|
if (resp.status === 'SUCCESS') {
|
||||||
@@ -31,7 +32,11 @@ const StatsBeneficiary = () => {
|
|||||||
}, [mainStats]);
|
}, [mainStats]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
DashboardService.getBeneficiaryStatsPage(chosenCompanyId, getStats, errGetStats);
|
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
|
if (existingCompany) {
|
||||||
|
DashboardService.getBeneficiaryStatsPage(chosenCompanyId, getStats, errGetStats);
|
||||||
|
}
|
||||||
}, [chosenCompanyId]);
|
}, [chosenCompanyId]);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|||||||
Reference in New Issue
Block a user