-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClientPowerPlan.jsx
More file actions
96 lines (87 loc) · 3.06 KB
/
ClientPowerPlan.jsx
File metadata and controls
96 lines (87 loc) · 3.06 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import "./styles.css";
import { useState } from "react";
import { useSelector } from "react-redux";
import ActionButton from "../../../Components/CommonComponents/ActionButton/ActionButton";
import ClientPowerPlanService from "../Services/ClientPowerPlanService/ClientPowerPlanService";
const ClientPowerPlan = () => {
const [reportData, setReportData] = useState(null);
const loading = useSelector((state) => state.loading.loadingState);
const userId = useSelector((state) => state.user.id);
const { fetchPowerPlanReport } = ClientPowerPlanService();
return (
<div className="client-container">
<header className="client-header">
<h1 className="client-title">Monthly Energy Report</h1>
<p className="client-subtitle">
Personalized power optimization plan for your devices
</p>
</header>
{reportData && !loading && (
<div className="client-download-top">
<ActionButton
text="Download Report"
className="client-download-action-button"
color="#FFFFFF"
onClick={() => console.log("Download triggered")}
width="250px"
margin="20px auto"
/>
</div>
)}
{!reportData && !loading && (
<div className="client-generate-card">
<p>
Click below to analyze your past 10 months of usage and receive a
detailed power plan.
</p>
<ActionButton
text="Generate My Plan"
className="client-generate-action-button"
color="#FFFFFF"
onClick={() => fetchPowerPlanReport(userId, setReportData)}
width="250px"
margin="20px auto 0"
/>
</div>
)}
{loading ? (
<div className="client-loading-overlay">
<div className="client-spinner" />
<p>Generating your plan...</p>
</div>
) : (
reportData && (
<div className="client-report-card">
<section className="client-summary-section">
<h3>Summary</h3>
<p>{reportData.summary}</p>
</section>
<section className="client-insight-grid">
<div className="client-insight-box">
<h4>Voltage Insights</h4>
<p>{reportData.voltageInsights}</p>
</div>
<div className="client-insight-box">
<h4>Power Insights</h4>
<p>{reportData.powerInsights}</p>
</div>
<div className="client-insight-box">
<h4>Energy Insights</h4>
<p>{reportData.energyInsights}</p>
</div>
</section>
<section className="client-recommendation-section">
<h4>Recommendations</h4>
<ul>
{reportData.recommendations.split("\n").map((rec, index) => (
<li key={index}>{rec}</li>
))}
</ul>
</section>
</div>
)
)}
</div>
);
};
export default ClientPowerPlan;