-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor file structure and imports for UserWorkRatioChart component
- Loading branch information
1 parent
9052df6
commit a669460
Showing
12 changed files
with
276 additions
and
441 deletions.
There are no files selected for viewing
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../pages/visitations/UserWorkRatioChart.tsx → ...c/components/modal/UserWorkRatioChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
frontend/occupi-web/src/components/userStats/UserStatsComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { AI_loader } from "@assets/index"; | ||
import { useEffect, useState } from "react"; | ||
import * as userStatsService from "userStatsService"; | ||
// import WorkerStatsComponent from "WorkerStatsService"; | ||
|
||
const UserStatsComponent = ({ email }: { email: string }) => { | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState<string | null>(null); | ||
const [stats, setStats] = useState<any>(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
setLoading(true); | ||
setError(null); | ||
|
||
const params = { | ||
email: email, | ||
timeFrom: "2024-01-01T00:00:00.000Z", | ||
timeTo: "2024-09-11T00:00:00.000Z", | ||
}; | ||
|
||
try { | ||
const userHours = await userStatsService.getUserHours(params); | ||
const userWorkRatio = await userStatsService.getUserWorkRatio(params); | ||
const userArrivalDepartureAverage = | ||
await userStatsService.getUserArrivalDepartureAverage(params); | ||
|
||
setStats({ | ||
averageHours: userHours.data[0].overallTotal / userHours.data.length, | ||
workRatio: userWorkRatio.data[0].ratio, | ||
averageArrival: userArrivalDepartureAverage.data[0].overallavgArrival, | ||
averageDeparture: | ||
userArrivalDepartureAverage.data[0].overallavgDeparture, | ||
}); | ||
} catch (err) { | ||
setError("Failed to fetch user statistics"); | ||
console.error("Error:", err); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, [email]); | ||
|
||
if (loading) | ||
return ( | ||
<div className="font-bold "> | ||
Loading... | ||
<img className=" h-96 w-62" src={AI_loader} alt="" /> | ||
</div> | ||
); | ||
if (error) return <div className="text-text_col_red_salmon">Error: {error}</div>; | ||
|
||
return ( | ||
<div className="p-4 text-text_col_secondary_alt rounded-lg shadow-md"> | ||
<h1 className="text-2xl font-bold mb-4 text-white">Occubot User Statistics</h1> | ||
{stats && ( | ||
<div className="space-y-2 text-white"> | ||
<p className="text-text_col_secondary_alt"> | ||
<strong>Average Daily Hours:</strong>{" "} | ||
{stats.averageHours.toFixed(2)} hours | ||
</p> | ||
<p className="text-text_col_secondary_alt"> | ||
<strong>Work Ratio:</strong> {stats.workRatio.toFixed(2)} | ||
</p> | ||
<p className="text-text_col_secondary_alt"> | ||
<strong>Average Arrival Time:</strong> {stats.averageArrival} | ||
</p> | ||
<p className="text-text_col_secondary_alt"> | ||
<strong>Average Departure Time:</strong> {stats.averageDeparture} | ||
</p> | ||
{/* <WorkerService /> */} | ||
|
||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserStatsComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
frontend/occupi-web/src/pages/visitations/BarChartComponent.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
frontend/occupi-web/src/pages/visitations/PieChartComponent.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
frontend/occupi-web/src/pages/visitations/PieChartPeakHoursComponent.tsx
This file was deleted.
Oops, something went wrong.
102 changes: 0 additions & 102 deletions
102
frontend/occupi-web/src/pages/visitations/UserPeakOfficeHoursChart.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.