Merge pull request #10 from Kitzanos/feature/65-favourite-call
Feature/65 favourite call
This commit is contained in:
@@ -372,8 +372,8 @@
|
|||||||
|
|
||||||
.appPageSection__tableActions {
|
.appPageSection__tableActions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 24px;
|
gap: 10px;
|
||||||
padding: 0;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
&.lessGap {
|
&.lessGap {
|
||||||
@@ -389,12 +389,18 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border: none;
|
border: none;
|
||||||
background-color: var(--message-info-color);
|
background-color: transparent;
|
||||||
color: white;
|
color: var(--global-textColor);
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
color: var(--message-info-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-active="true"] {
|
||||||
|
background-color: var(--message-info-color);
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[disabled] {
|
&[disabled] {
|
||||||
|
|||||||
@@ -2,14 +2,18 @@ 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 } from 'ramda';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../../../store';
|
import { storeGet, storeSet, useStore } from '../../../../store';
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
|
import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
|
||||||
|
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||||
|
import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency';
|
||||||
|
import renderHtmlContent from '../../../../helpers/renderHtmlContent';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
@@ -20,11 +24,8 @@ import { Column } from 'primereact/column';
|
|||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency';
|
|
||||||
import renderHtmlContent from '../../../../helpers/renderHtmlContent';
|
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import PreferredBandoService from '../../../../service/preferred-bando-service';
|
||||||
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
|
||||||
|
|
||||||
|
|
||||||
const AllBandiAccordion = () => {
|
const AllBandiAccordion = () => {
|
||||||
@@ -38,8 +39,10 @@ const AllBandiAccordion = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
BandoService.getBandi(getCallback, errGetCallbacks);
|
BandoService.getBandi(getCallback, errGetCallbacks, [
|
||||||
}, []);
|
['companyId', chosenCompanyId]
|
||||||
|
]);
|
||||||
|
}, [chosenCompanyId]);
|
||||||
|
|
||||||
const getCallback = (data) => {
|
const getCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
@@ -93,21 +96,68 @@ const AllBandiAccordion = () => {
|
|||||||
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)} />;
|
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*const addToFavourites = () => {
|
const addToFavourites = (id, preferredId) => {
|
||||||
console.log('addToFavourites');
|
const companyId = storeGet.main.chosenCompanyId()
|
||||||
}*/
|
const data = {
|
||||||
|
companyId,
|
||||||
|
callId: id
|
||||||
|
}
|
||||||
|
if (preferredId && preferredId !== 0) {
|
||||||
|
PreferredBandoService.deleteFromPreferred(preferredId, (data) => removeFavCallback(data, id), errToggleFavCallback);
|
||||||
|
} else {
|
||||||
|
PreferredBandoService.addToPreferred(data, addFavCallback, errToggleFavCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeFavCallback = (data, id) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
const newItems = items.map((o) => {
|
||||||
|
if (o.id === id) {
|
||||||
|
return {
|
||||||
|
...o,
|
||||||
|
preferredCallId: null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setItems(newItems)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const errToggleFavCallback = (data) => {
|
||||||
|
set404FromErrorResponse(data);
|
||||||
|
}
|
||||||
|
|
||||||
const goToBandoPage = (id) => {
|
const goToBandoPage = (id) => {
|
||||||
navigate(`/bandi/${id}`)
|
navigate(`/bandi/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*const actionsBodyTemplate = (rowData) => {
|
const actionsBodyTemplate = (rowData) => {
|
||||||
return <div className="appPageSection__tableActions">
|
return <div className="appPageSection__tableActions">
|
||||||
<button type="button" className="appPageSection__addToFavourites" onClick={addToFavourites} disabled={true}>
|
<button type="button"
|
||||||
|
className="appPageSection__addToFavourites"
|
||||||
|
data-active={!isNil(rowData.preferredCallId)}
|
||||||
|
onClick={() => addToFavourites(rowData.id, rowData.preferredCallId)}>
|
||||||
<i className="pi pi-heart" style={{ fontSize: '1rem' }}></i>
|
<i className="pi pi-heart" style={{ fontSize: '1rem' }}></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
}*/
|
}
|
||||||
|
|
||||||
const rowExpansionTemplate = (data) => {
|
const rowExpansionTemplate = (data) => {
|
||||||
return (
|
return (
|
||||||
@@ -150,10 +200,12 @@ const AllBandiAccordion = () => {
|
|||||||
<Column header={__('Importo totale', 'gepafin')} filterField="amount"
|
<Column header={__('Importo totale', 'gepafin')} filterField="amount"
|
||||||
style={{ minWidth: '10rem' }} body={amountBodyTemplate} sortable/>
|
style={{ minWidth: '10rem' }} body={amountBodyTemplate} sortable/>
|
||||||
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
|
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
|
||||||
style={{ width: '120px' }} body={statusBodyTemplate} filter sortable
|
style={{ width: '8rem' }} body={statusBodyTemplate} filter sortable
|
||||||
filterElement={statusFilterTemplate}/>
|
filterElement={statusFilterTemplate}/>
|
||||||
{/*<Column header={__('Azioni', 'gepafin')}
|
{!isEmpty(chosenCompanyId) && chosenCompanyId !== 0
|
||||||
body={actionsBodyTemplate}/>*/}
|
? <Column header={__('Azioni', 'gepafin')}
|
||||||
|
style={{ width: '8rem' }}
|
||||||
|
body={actionsBodyTemplate}/> : null}
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { is, isEmpty, isNil } from 'ramda';
|
|||||||
import "quill/dist/quill.core.css";
|
import "quill/dist/quill.core.css";
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../store';
|
import { storeGet, storeSet, useStore } from '../../store';
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||||
@@ -28,6 +28,7 @@ import { Message } from 'primereact/message';
|
|||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import { Editor } from 'primereact/editor';
|
import { Editor } from 'primereact/editor';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import PreferredBandoService from '../../service/preferred-bando-service';
|
||||||
|
|
||||||
const BandoViewBeneficiario = () => {
|
const BandoViewBeneficiario = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
@@ -246,11 +247,50 @@ const BandoViewBeneficiario = () => {
|
|||||||
|
|
||||||
const header = renderHeader();
|
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(() => {
|
useEffect(() => {
|
||||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
|
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, [
|
||||||
|
['companyId', chosenCompanyId]
|
||||||
|
]);
|
||||||
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
||||||
['callId', bandoId],
|
['callId', bandoId],
|
||||||
['companyId', chosenCompanyId]
|
['companyId', chosenCompanyId]
|
||||||
@@ -445,14 +485,15 @@ const BandoViewBeneficiario = () => {
|
|||||||
onClick={submitApplication}
|
onClick={submitApplication}
|
||||||
label={submitBtnLabel()}
|
label={submitBtnLabel()}
|
||||||
icon={submitBtnIcon()} iconPos="right"/>
|
icon={submitBtnIcon()} iconPos="right"/>
|
||||||
{/*<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
outlined
|
outlined={isNil(data.preferredCallId)}
|
||||||
rounded
|
rounded
|
||||||
disabled={true}
|
onClick={addToFavourites}
|
||||||
onClick={saveToFavourites}
|
label={isNil(data.preferredCallId)
|
||||||
label={__('Aggiungi a preferiti', 'gepafin')}
|
? __('Aggiungi a preferiti', 'gepafin')
|
||||||
icon="pi pi-heart" iconPos="left"/>*/}
|
: __('Rimuovi dai preferiti', 'gepafin')}
|
||||||
|
icon="pi pi-heart" iconPos="left"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -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, isEmpty } from 'ramda';
|
import { uniq, isEmpty, isNil } from 'ramda';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../../../store';
|
import { storeGet, useStore } from '../../../../store';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
@@ -19,6 +19,8 @@ import { InputIcon } from 'primereact/inputicon';
|
|||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { Calendar } from 'primereact/calendar';
|
import { Calendar } from 'primereact/calendar';
|
||||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
|
import PreferredBandoService from '../../../../service/preferred-bando-service';
|
||||||
|
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||||
|
|
||||||
|
|
||||||
const LatestBandiTable = () => {
|
const LatestBandiTable = () => {
|
||||||
@@ -30,9 +32,11 @@ const LatestBandiTable = () => {
|
|||||||
const [statuses, setStatuses] = useState([]);
|
const [statuses, setStatuses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeSet.main.setAsyncRequest();
|
setLoading(true);
|
||||||
BandoService.getBandi(getCallback, errGetCallbacks);
|
BandoService.getBandi(getCallback, errGetCallbacks, [
|
||||||
}, []);
|
['companyId', chosenCompanyId]
|
||||||
|
]);
|
||||||
|
}, [chosenCompanyId]);
|
||||||
|
|
||||||
const getCallback = (data) => {
|
const getCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
@@ -41,12 +45,64 @@ const LatestBandiTable = () => {
|
|||||||
setStatuses(uniq(data.data.map(o => o.status)))
|
setStatuses(uniq(data.data.map(o => o.status)))
|
||||||
initFilters();
|
initFilters();
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const errGetCallbacks = (data) => {
|
const errGetCallbacks = (data) => {
|
||||||
console.log('errGetCallbacks', data)
|
set404FromErrorResponse(data);
|
||||||
storeSet.main.unsetAsyncRequest();
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const addToFavourites = (id, preferredId) => {
|
||||||
|
const companyId = storeGet.main.chosenCompanyId()
|
||||||
|
const data = {
|
||||||
|
companyId,
|
||||||
|
callId: id
|
||||||
|
}
|
||||||
|
setLoading(true);
|
||||||
|
if (preferredId && preferredId !== 0) {
|
||||||
|
PreferredBandoService.deleteFromPreferred(preferredId, (data) => removeFavCallback(data, id), errToggleFavCallback);
|
||||||
|
} else {
|
||||||
|
PreferredBandoService.addToPreferred(data, addFavCallback, errToggleFavCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeFavCallback = (data, id) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
const newItems = items.map((o) => {
|
||||||
|
if (o.id === id) {
|
||||||
|
return {
|
||||||
|
...o,
|
||||||
|
preferredCallId: null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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) => {
|
const getFormattedData = (data) => {
|
||||||
@@ -83,9 +139,18 @@ const LatestBandiTable = () => {
|
|||||||
const initFilters = () => {
|
const initFilters = () => {
|
||||||
setFilters({
|
setFilters({
|
||||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||||
name: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] },
|
name: {
|
||||||
start_date: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] },
|
operator: FilterOperator.AND,
|
||||||
end_date: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] },
|
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 }] }
|
status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] }
|
||||||
});
|
});
|
||||||
setGlobalFilterValue('');
|
setGlobalFilterValue('');
|
||||||
@@ -94,10 +159,12 @@ const LatestBandiTable = () => {
|
|||||||
const renderHeader = () => {
|
const renderHeader = () => {
|
||||||
return (
|
return (
|
||||||
<div className="appTableHeader">
|
<div className="appTableHeader">
|
||||||
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined onClick={clearFilter} />
|
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined
|
||||||
|
onClick={clearFilter}/>
|
||||||
<IconField iconPosition="left">
|
<IconField iconPosition="left">
|
||||||
<InputIcon className="pi pi-search" />
|
<InputIcon className="pi pi-search"/>
|
||||||
<InputText value={globalFilterValue} onChange={onGlobalFilterChange} placeholder={__('Cerca', 'gepafin')} />
|
<InputText value={globalFilterValue} onChange={onGlobalFilterChange}
|
||||||
|
placeholder={__('Cerca', 'gepafin')}/>
|
||||||
</IconField>
|
</IconField>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -112,7 +179,8 @@ const LatestBandiTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dateFilterTemplate = (options) => {
|
const dateFilterTemplate = (options) => {
|
||||||
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)} dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999" />;
|
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
|
dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusBodyTemplate = (rowData) => {
|
const statusBodyTemplate = (rowData) => {
|
||||||
@@ -120,10 +188,17 @@ const LatestBandiTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionsBodyTemplate = (rowData) => {
|
const actionsBodyTemplate = (rowData) => {
|
||||||
return <Link to={`/bandi/${rowData.id}`}>
|
return <div className="appPageSection__tableActions">
|
||||||
<Button severity="info" label={__('Partecipa', 'gepafin')} icon="pi pi-arrow-right" size="small"
|
<button type="button"
|
||||||
iconPos="right"/>
|
className="appPageSection__addToFavourites"
|
||||||
</Link>
|
data-active={!isNil(rowData.preferredCallId)}
|
||||||
|
onClick={() => addToFavourites(rowData.id, rowData.preferredCallId)}>
|
||||||
|
<i className="pi pi-heart" style={{ fontSize: '1rem' }}></i>
|
||||||
|
</button>
|
||||||
|
<Link to={`/bandi/${rowData.id}`}>
|
||||||
|
<Button severity="info" label={__('Partecipa', 'gepafin')} icon="pi pi-arrow-right" size="small"
|
||||||
|
iconPos="right"/>
|
||||||
|
</Link></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = renderHeader();
|
const header = renderHeader();
|
||||||
@@ -136,7 +211,8 @@ const LatestBandiTable = () => {
|
|||||||
header={header}
|
header={header}
|
||||||
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
|
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
|
||||||
onFilter={(e) => setFilters(e.filters)}>
|
onFilter={(e) => setFilters(e.filters)}>
|
||||||
<Column field="name" header={__('Nome Bando', 'gepafin')} filter filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
<Column field="name" header={__('Nome Bando', 'gepafin')} filter
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
style={{ minWidth: '8rem' }}/>
|
style={{ minWidth: '8rem' }}/>
|
||||||
<Column header={__('Data Pubblicazione', 'gepafin')} filterField="start_date" dataType="date"
|
<Column header={__('Data Pubblicazione', 'gepafin')} filterField="start_date" dataType="date"
|
||||||
style={{ minWidth: '8rem' }}
|
style={{ minWidth: '8rem' }}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
|
|||||||
|
|
||||||
export default class BandoService {
|
export default class BandoService {
|
||||||
|
|
||||||
static getBandi = (callback, errCallback) => {
|
static getBandi = (callback, errCallback, queryParams) => {
|
||||||
NetworkService.get(`${API_BASE_URL}/call`, callback, errCallback);
|
NetworkService.get(`${API_BASE_URL}/call`, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
static getBando = (id, callback, errCallback) => {
|
static getBando = (id, callback, errCallback, queryParams) => {
|
||||||
NetworkService.get(`${API_BASE_URL}/call/${id}`, callback, errCallback);
|
NetworkService.get(`${API_BASE_URL}/call/${id}`, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
static validateBando = (id, callback, errCallback) => {
|
static validateBando = (id, callback, errCallback) => {
|
||||||
|
|||||||
14
src/service/preferred-bando-service.js
Normal file
14
src/service/preferred-bando-service.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
static deleteFromPreferred = (id, callback, errCallback) => {
|
||||||
|
NetworkService.delete(`${API_BASE_URL}/beneficiaryPreferredCall/${id}`, {}, callback, errCallback);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user