added some tests
This commit is contained in:
@@ -11,13 +11,13 @@ import {
|
||||
} from "@mui/material";
|
||||
|
||||
interface User {
|
||||
date: string;
|
||||
f_name: string;
|
||||
l_name: string;
|
||||
mail: string;
|
||||
name: string;
|
||||
time: number;
|
||||
user: number;
|
||||
Date: string;
|
||||
FName: string;
|
||||
LName: string;
|
||||
Mail: string;
|
||||
Name: string;
|
||||
Time: number;
|
||||
User: number;
|
||||
}
|
||||
|
||||
//TODO date input should send error when there is no data in the response
|
||||
@@ -47,6 +47,7 @@ const LeftSide = ({
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
const resp = await api.get("/getall", { params });
|
||||
console.log(resp.data);
|
||||
if (resp.data.length) setUsers(resp.data);
|
||||
}
|
||||
async function resetData() {
|
||||
@@ -156,14 +157,14 @@ const LeftSide = ({
|
||||
{users.length > 0 && Array.isArray(users) ? (
|
||||
users.map((post, idx) => (
|
||||
<TableRow key={idx}>
|
||||
<TableCell>{post.f_name} </TableCell>
|
||||
<TableCell>{post.l_name} </TableCell>
|
||||
<TableCell>{post.mail} </TableCell>
|
||||
<TableCell>{post.name} </TableCell>
|
||||
<TableCell>{post.date.slice(0, 10)} </TableCell>
|
||||
<TableCell>{post.time} </TableCell>
|
||||
<TableCell>{post.FName} </TableCell>
|
||||
<TableCell>{post.LName} </TableCell>
|
||||
<TableCell>{post.Mail} </TableCell>
|
||||
<TableCell>{post.Name} </TableCell>
|
||||
<TableCell>{post.Date.slice(0, 10)} </TableCell>
|
||||
<TableCell>{post.Time} </TableCell>
|
||||
<TableCell>
|
||||
<button onClick={() => viewProjectHours(post.user)}>
|
||||
<button onClick={() => viewProjectHours(post.User)}>
|
||||
Hours
|
||||
</button>
|
||||
</TableCell>
|
||||
|
||||
@@ -28,13 +28,13 @@ const RightSide = ({ reset }: { reset: boolean }) => {
|
||||
// turn the data into form suitable to charts
|
||||
if (filter === "project")
|
||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||
resp.data[idx] = [resp.data[idx].name, resp.data[idx].total_time];
|
||||
resp.data[idx] = [resp.data[idx].Name, resp.data[idx].TotalTime];
|
||||
}
|
||||
else if (filter === "user")
|
||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||
resp.data[idx] = [
|
||||
resp.data[idx].f_name + " " + resp.data[idx].l_name,
|
||||
resp.data[idx].total_time,
|
||||
resp.data[idx].FName + " " + resp.data[idx].LName,
|
||||
resp.data[idx].TotalTime,
|
||||
];
|
||||
}
|
||||
setChartData(resp.data);
|
||||
|
||||
Reference in New Issue
Block a user