diff --git a/backendCS.Tests/UnitTest1.cs b/backendCS.Tests/UnitTest1.cs index 2bb7fc4..1b4807d 100644 --- a/backendCS.Tests/UnitTest1.cs +++ b/backendCS.Tests/UnitTest1.cs @@ -120,7 +120,7 @@ public class UnitTest1 using HttpClient client = new(); HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/getuser"); - Assert.AreEqual((int)response.StatusCode, 400); + Assert.AreEqual((int)response.StatusCode, 200); } [TestMethod] diff --git a/backendCS/routes/CreateLog.cs b/backendCS/routes/CreateLog.cs index be41d94..45eeafd 100644 --- a/backendCS/routes/CreateLog.cs +++ b/backendCS/routes/CreateLog.cs @@ -1,7 +1,6 @@ using System.IdentityModel.Tokens.Jwt; using System.Net; using System.Text; -using System.Text.RegularExpressions; using Microsoft.IdentityModel.Tokens; using MySql.Data.MySqlClient; using Newtonsoft.Json.Linq; diff --git a/backendCS/routes/Getuser.cs b/backendCS/routes/Getuser.cs index 498a4d3..ed87250 100644 --- a/backendCS/routes/Getuser.cs +++ b/backendCS/routes/Getuser.cs @@ -7,23 +7,6 @@ namespace TimelogBackend; public class Getuser : Route { - private static dynamic ExtractDataFromDB(MySqlCommand cmd) - { - using MySqlConnection conn = new(connectionString); - conn.Open(); - cmd.Connection = conn; - // execute query and read results - MySqlDataReader reader = cmd.ExecuteReader(); - dynamic expando = new ExpandoObject(); - while (reader.Read()) - { - ((IDictionary)expando)[reader["name"].ToString()] = reader[ - "SUM(t.time)" - ]; - } - return expando; - } - public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response) { try @@ -56,4 +39,21 @@ public class Getuser : Route SendError(response, ex); } } + + private static dynamic ExtractDataFromDB(MySqlCommand cmd) + { + using MySqlConnection conn = new(connectionString); + conn.Open(); + cmd.Connection = conn; + // execute query and read results + MySqlDataReader reader = cmd.ExecuteReader(); + dynamic expando = new ExpandoObject(); + while (reader.Read()) + { + ((IDictionary)expando)[reader["name"].ToString()] = reader[ + "SUM(t.time)" + ]; + } + return expando; + } } diff --git a/frontend/src/components/LeftSide.tsx b/frontend/src/components/LeftSide.tsx index c435529..00a3597 100644 --- a/frontend/src/components/LeftSide.tsx +++ b/frontend/src/components/LeftSide.tsx @@ -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) => ( - {post.f_name} - {post.l_name} - {post.mail} - {post.name} - {post.date.slice(0, 10)} - {post.time} + {post.FName} + {post.LName} + {post.Mail} + {post.Name} + {post.Date.slice(0, 10)} + {post.Time} - diff --git a/frontend/src/components/RightSide.tsx b/frontend/src/components/RightSide.tsx index 4361f97..870c4d8 100644 --- a/frontend/src/components/RightSide.tsx +++ b/frontend/src/components/RightSide.tsx @@ -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);