lint bro happ + test for getUserProject
This commit is contained in:
parent
4392b68397
commit
8eb23bf7f9
6 changed files with 22 additions and 13 deletions
|
@ -150,7 +150,10 @@ export const api: API = {
|
|||
}
|
||||
},
|
||||
|
||||
async getUserProjects(token: string): Promise<APIResponse<Project[]>> {
|
||||
async getUserProjects(
|
||||
username: string,
|
||||
token: string,
|
||||
): Promise<APIResponse<Project[]>> {
|
||||
try {
|
||||
const response = await fetch("/api/getUserProjects", {
|
||||
method: "GET",
|
||||
|
@ -158,6 +161,7 @@ export const api: API = {
|
|||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + token,
|
||||
},
|
||||
body: JSON.stringify({ username }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useState, useContext } from "react";
|
||||
import { NewWeeklyReport } from "../Types/goTypes";
|
||||
import type { NewWeeklyReport } from "../Types/goTypes";
|
||||
import { api } from "../API/API";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import Button from "./Button";
|
||||
|
|
|
@ -9,7 +9,7 @@ const UserProjectListAdmin: React.FC = () => {
|
|||
const fetchProjects = async (): Promise<void> => {
|
||||
try {
|
||||
const token = localStorage.getItem("accessToken") ?? "";
|
||||
const username = getUsernameFromContext(); // Assuming you have a function to get the username from your context
|
||||
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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState, createContext, useEffect } from "react";
|
||||
import { useState, createContext, useEffect } from "react";
|
||||
import { Project } from "../Types/goTypes";
|
||||
import { api } from "../API/API";
|
||||
import { Link } from "react-router-dom";
|
||||
|
@ -23,7 +23,7 @@ function UserProjectPage(): JSX.Element {
|
|||
};
|
||||
// Call getProjects when the component mounts
|
||||
useEffect(() => {
|
||||
getProjects();
|
||||
void getProjects();
|
||||
}, []);
|
||||
|
||||
const handleProjectClick = (projectName: string): void => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue