Add user-specific project list and API integration
This commit is contained in:
parent
711f46f960
commit
5bef01396b
1 changed files with 27 additions and 17 deletions
|
@ -1,25 +1,34 @@
|
||||||
import BasicWindow from "../Components/BasicWindow";
|
import React, { useState } from "react";
|
||||||
import { ProjectListUser } from "../Components/ProjectListUser";
|
|
||||||
import { Project } from "../Types/goTypes";
|
import { Project } from "../Types/goTypes";
|
||||||
|
import { api } from "../API/API";
|
||||||
|
import { Link, useLocation } from "react-router-dom";
|
||||||
|
import BasicWindow from "../Components/BasicWindow";
|
||||||
|
|
||||||
function YourProjectsPage(): JSX.Element {
|
function UserProjectPage(): JSX.Element {
|
||||||
//TODO: Change so that it reads projects from database
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
const projects: Project[] = [];
|
|
||||||
for (let i = 1; i <= 20; i++) {
|
const getProjects = async (): Promise<void> => {
|
||||||
projects.push({
|
const username = "user"; // replace with actual username
|
||||||
id: i,
|
const token = "your_token"; // replace with actual token
|
||||||
name: "Example Project " + i,
|
const response = await api.getUserProjects(username, token);
|
||||||
description: "good",
|
if (response.success) {
|
||||||
created: "now",
|
setProjects(response.data ?? []);
|
||||||
owner: "me",
|
} else {
|
||||||
});
|
console.error(response.message);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<>
|
<>
|
||||||
<h1 className="font-bold text-[30px] mb-[20px]">Your Projects</h1>
|
<h1 className="font-bold text-[30px] mb-[20px]">Your Projects</h1>
|
||||||
<div className="border-4 border-black bg-white flex flex-col items-center h-[65vh] w-[50vw] rounded-3xl content-center overflow-scroll space-y-[10vh] p-[30px]">
|
<div className="border-4 border-black bg-white flex flex-col items-center justify-center min-h-[65vh] h-fit w-[50vw] rounded-3xl content-center overflow-scroll space-y-[10vh] p-[30px]">
|
||||||
<ProjectListUser projects={projects} />
|
{projects.map((project, index) => (
|
||||||
|
<Link key={index} to={`/project/${project.id}`}>
|
||||||
|
<h1 className="font-bold underline text-[30px] cursor-pointer">
|
||||||
|
{project.name}
|
||||||
|
</h1>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -28,4 +37,5 @@ function YourProjectsPage(): JSX.Element {
|
||||||
|
|
||||||
return <BasicWindow username="Admin" content={content} buttons={buttons} />;
|
return <BasicWindow username="Admin" content={content} buttons={buttons} />;
|
||||||
}
|
}
|
||||||
export default YourProjectsPage;
|
|
||||||
|
export default UserProjectPage;
|
||||||
|
|
Loading…
Reference in a new issue