dataBucketObservers.js
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import LemaApi from "./service.js";
import { observer, observe } from 'redux-observers'
import {toast} from 'react-toastify';
// Observer sulla proprietà dataBucketProfilation dello store
export const dataBucketsProfilationObserver = observer(
state => state.ProfilationSelectReducer.dataBucketProfilation,
(dispatch, current, previous) => {
console.log('Databucket aggiornato');
console.log('Previous', previous);
console.log('Current', current);
let request = {
Job: current.job,
Service: current.service,
Expend: current.expend,
Period: current.period,
Light: current.light ? current.light : 0,
Gas: current.gas ? current.gas : 0,
Environment: current.environment,
Flexibility: current.flexibility,
Customizable: current.customizable
};
const lemaApi = new LemaApi();
lemaApi.saveProfilationData(request)
.then((response) => {
toast.success("Update OK", {position: toast.POSITION.BOTTOM_CENTER});
})
.catch((err) => {
toast.error("Update Error", {position: toast.POSITION.BOTTOM_CENTER});
}
);
}
)