-
Notifications
You must be signed in to change notification settings - Fork 0
/
revenue_sheet.js
42 lines (32 loc) · 1.01 KB
/
revenue_sheet.js
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
38
39
40
41
42
import React, { useState, useEffect } from "react";
import Chart from "react-apexcharts";
import axios from "axios";
import BarChart from "./graph";
function Revenue() {
const [routeSuffix, setRouteSuffix] = useState('')
const [chartData, setChartData] = useState({
categories: [],
series: [{ name: "Sales on this day", data: [] }],
});
const handleDailyRevenue = async () => {
const response = await axios.get('http://localhost:5000/revenueday')
}
const handleMonthlyRevenue = async () => {
const response = await axios.get('http://localhost:5000/revenuemonth')
}
return (
<div>
<button onClick={handleDailyRevenue}>Daily Revenue</button>
<button onClick={handleMonthlyRevenue}>Monthly Revenue</button>
<input
type="text"
value={routeSuffix}
onChange = {(e) => setRouteSuffix(e.target.value)}
/>
{routeSuffix && routeSuffix.trim() !== '' && (
<BarChart id={routeSuffix} />
)}
</div>
);
}
export default Revenue;