Merge branch 'frontend' into gruppDM
This commit is contained in:
commit
f5a4c3d0e5
19 changed files with 410 additions and 45 deletions
|
|
@ -50,8 +50,8 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
}
|
||||
};
|
||||
|
||||
fetchWeeklyReport();
|
||||
}, []);
|
||||
void fetchWeeklyReport();
|
||||
}, [projectName, token, username, week]);
|
||||
|
||||
const handleNewWeeklyReport = async (): Promise<void> => {
|
||||
const newWeeklyReport: NewWeeklyReport = {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export default function Register(): JSX.Element {
|
|||
nav("/"); // Instantly navigate to the login page
|
||||
} else {
|
||||
setErrMessage(response.message ?? "Unknown error");
|
||||
console.error(errMessage);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ export default function Register(): JSX.Element {
|
|||
<InputField
|
||||
label="Username"
|
||||
type="text"
|
||||
value={username}
|
||||
value={username ?? ""}
|
||||
onChange={(e) => {
|
||||
setUsername(e.target.value);
|
||||
}}
|
||||
|
|
@ -55,7 +56,7 @@ export default function Register(): JSX.Element {
|
|||
<InputField
|
||||
label="Password"
|
||||
type="password"
|
||||
value={password}
|
||||
value={password ?? ""}
|
||||
onChange={(e) => {
|
||||
setPassword(e.target.value);
|
||||
}}
|
||||
|
|
|
|||
43
frontend/src/Components/UserProjectListAdmin.tsx
Normal file
43
frontend/src/Components/UserProjectListAdmin.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { api } from "../API/API";
|
||||
import { Project } from "../Types/goTypes";
|
||||
|
||||
const UserProjectListAdmin: React.FC = () => {
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchProjects = async (): Promise<void> => {
|
||||
try {
|
||||
const token = localStorage.getItem("accessToken") ?? "";
|
||||
const username = "NoUser"; // getUsernameFromContext(); // Assuming you have a function to get the username from your context
|
||||
|
||||
const response = await api.getUserProjects(username, token);
|
||||
if (response.success) {
|
||||
setProjects(response.data ?? []);
|
||||
} else {
|
||||
console.error("Failed to fetch projects:", response.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching projects:", error);
|
||||
}
|
||||
};
|
||||
|
||||
void fetchProjects();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>User Projects</h2>
|
||||
<ul>
|
||||
{projects.map((project) => (
|
||||
<li key={project.id}>
|
||||
<span>{project.name}</span>
|
||||
{/* Add any additional project details you want to display */}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserProjectListAdmin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue