- implemnted functionality adding to preferred calls;
This commit is contained in:
@@ -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') {
|
||||
|
||||
@@ -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"/>
|
||||
{/*<Button
|
||||
<Button
|
||||
type="button"
|
||||
outlined
|
||||
outlined={isNil(data.preferredCallId)}
|
||||
rounded
|
||||
disabled={true}
|
||||
onClick={saveToFavourites}
|
||||
label={__('Aggiungi a preferiti', 'gepafin')}
|
||||
icon="pi pi-heart" iconPos="left"/>*/}
|
||||
onClick={addToFavourites}
|
||||
label={isNil(data.preferredCallId)
|
||||
? __('Aggiungi a preferiti', 'gepafin')
|
||||
: __('Rimuovi dai preferiti', 'gepafin')}
|
||||
icon="pi pi-heart" iconPos="left"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user