Cleanup YourProjectsPage
This commit is contained in:
parent
3b8b9bb3f2
commit
08532444f0
1 changed files with 5 additions and 17 deletions
|
@ -1,13 +1,11 @@
|
||||||
import { useState, createContext } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Project } from "../Types/goTypes";
|
import { Project } from "../Types/goTypes";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import BasicWindow from "../Components/BasicWindow";
|
import BasicWindow from "../Components/BasicWindow";
|
||||||
|
import { api } from "../API/API";
|
||||||
export const ProjectNameContext = createContext("");
|
|
||||||
|
|
||||||
function UserProjectPage(): JSX.Element {
|
function UserProjectPage(): JSX.Element {
|
||||||
const [projects, setProjects] = useState<Project[]>([]);
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
const [selectedProject, setSelectedProject] = useState("");
|
|
||||||
|
|
||||||
const getProjects = async (): Promise<void> => {
|
const getProjects = async (): Promise<void> => {
|
||||||
const token = localStorage.getItem("accessToken") ?? "";
|
const token = localStorage.getItem("accessToken") ?? "";
|
||||||
|
@ -24,29 +22,19 @@ function UserProjectPage(): JSX.Element {
|
||||||
void getProjects();
|
void getProjects();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleProjectClick = (projectName: string): void => {
|
|
||||||
setSelectedProject(projectName);
|
|
||||||
};
|
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<ProjectNameContext.Provider value={selectedProject}>
|
<>
|
||||||
<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 justify-center min-h-[65vh] h-fit 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]">
|
||||||
{projects.map((project, index) => (
|
{projects.map((project, index) => (
|
||||||
<Link
|
<Link to={`/project/${project.name}`} key={index}>
|
||||||
to={`/project/${project.name}`}
|
|
||||||
onClick={() => {
|
|
||||||
handleProjectClick(project.name);
|
|
||||||
}}
|
|
||||||
key={index}
|
|
||||||
>
|
|
||||||
<h1 className="font-bold underline text-[30px] cursor-pointer">
|
<h1 className="font-bold underline text-[30px] cursor-pointer">
|
||||||
{project.name}
|
{project.name}
|
||||||
</h1>
|
</h1>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</ProjectNameContext.Provider>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const buttons = <></>;
|
const buttons = <></>;
|
||||||
|
|
Loading…
Add table
Reference in a new issue