Merge branch 'dev' into frontend
This commit is contained in:
commit
e839d02cfd
15 changed files with 361 additions and 192 deletions
|
|
@ -7,7 +7,7 @@ import Button from "./Button";
|
|||
|
||||
/**
|
||||
* Tries to add a project to the system
|
||||
* @param props - Project name and description
|
||||
* @param {Object} props - Project name and description
|
||||
* @returns {boolean} True if created, false if not
|
||||
*/
|
||||
function CreateProject(props: { name: string; description: string }): boolean {
|
||||
|
|
@ -34,8 +34,8 @@ function CreateProject(props: { name: string; description: string }): boolean {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tries to add a project to the system
|
||||
* @returns {JSX.Element} UI for project adding
|
||||
* Provides UI for adding a project to the system.
|
||||
* @returns {JSX.Element} - Returns the component UI for adding a project
|
||||
*/
|
||||
function AddProject(): JSX.Element {
|
||||
const [name, setName] = useState("");
|
||||
|
|
|
|||
|
|
@ -7,30 +7,30 @@ import { api } from "../API/API";
|
|||
|
||||
/**
|
||||
* Renders a component that displays all the time reports for a specific project.
|
||||
* @returns JSX.Element representing the component.
|
||||
* @returns {JSX.Element} representing the component.
|
||||
*/
|
||||
function AllTimeReportsInProject(): JSX.Element {
|
||||
const { projectName } = useParams();
|
||||
const [weeklyReports, setWeeklyReports] = useState<WeeklyReport[]>([]);
|
||||
|
||||
const getWeeklyReports = async (): Promise<void> => {
|
||||
const token = localStorage.getItem("accessToken") ?? "";
|
||||
const response = await api.getWeeklyReportsForUser(
|
||||
token,
|
||||
projectName ?? "",
|
||||
);
|
||||
console.log(response);
|
||||
if (response.success) {
|
||||
setWeeklyReports(response.data ?? []);
|
||||
} else {
|
||||
console.error(response.message);
|
||||
}
|
||||
};
|
||||
|
||||
// Call getProjects when the component mounts
|
||||
useEffect(() => {
|
||||
const getWeeklyReports = async (): Promise<void> => {
|
||||
const token = localStorage.getItem("accessToken") ?? "";
|
||||
const response = await api.getWeeklyReportsForUser(
|
||||
projectName ?? "",
|
||||
token,
|
||||
);
|
||||
console.log(response);
|
||||
if (response.success) {
|
||||
setWeeklyReports(response.data ?? []);
|
||||
} else {
|
||||
console.error(response.message);
|
||||
}
|
||||
};
|
||||
|
||||
void getWeeklyReports();
|
||||
});
|
||||
}, [projectName]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue