Commit 1aa50229 authored by Andi Staub's avatar Andi Staub
Browse files

Merge branch 'fixes/performance-api-call' into 'master'

Add start and end date to performance api request

See merge request !38
parents 5ca4e80e 3e0425eb
Pipeline #12147 passed with stages
in 2 minutes and 29 seconds
......@@ -22,15 +22,28 @@ class SalariesContainer extends Component {
}
componentDidMount() {
fetchJson(`${baseUrl}/salary`).then((json) => {
this.setState({ salaries: json.salaries.twoYearsBack });
});
const dateToday = this.apiDate(0);
const dateOneYearAgo = this.apiDate(12);
fetchJson(`${baseUrl}/performance`).then((json) => {
this.setState({ performance: json.performance });
Promise.all([
fetchJson(`${baseUrl}/salary`),
fetchJson(`${baseUrl}/performance?start_date=${dateOneYearAgo}&end_date=${dateToday}`),
]).then(([salaryJson, performanceJson]) => {
this.setState({
salaries: salaryJson.salaries.twoYearsBack,
performance: performanceJson.performance,
});
});
}
apiDate(monthsAgo) {
const date = new Date(Date.now());
date.setMonth(date.getMonth() - monthsAgo);
date.toLocaleDateString();
return date.toISOString().split('T')[0];
}
render() {
return (
<div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment