From 60dfd4771cd368ad6e4a6cb302c5f9eb52904249 Mon Sep 17 00:00:00 2001 From: DahmaneYanis Date: Wed, 20 Dec 2023 09:17:35 +0100 Subject: [PATCH] Home page fonctionnelle --- front/style/home.css | 8 +++-- front/views/Home.tsx | 46 ++++++++++++++++++++------- src/App/Controller/UserController.php | 6 +++- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/front/style/home.css b/front/style/home.css index c053198..56fcb8f 100644 --- a/front/style/home.css +++ b/front/style/home.css @@ -5,7 +5,8 @@ border : solid 2px purple; display: flex; flex-direction: column; - font-family: Helvetica,; + font-family: Helvetica; + height: 100%; } .new { @@ -22,7 +23,8 @@ display: flex; flex-direction: row; border : solid 10px violet; - margin:0px + margin:0px; + height: 100%; } #personal-space { @@ -52,7 +54,7 @@ } #sideMenu .title { - font-size: 13px; + font-size: 12px; font-weight: bold; color : #FFFFFF; letter-spacing: 1px; diff --git a/front/views/Home.tsx b/front/views/Home.tsx index 9ddb840..42d85c1 100644 --- a/front/views/Home.tsx +++ b/front/views/Home.tsx @@ -7,11 +7,20 @@ interface Tactic { creation_date : string } -export default function Home({ lastTactics, allTactics } : { lastTactics : Tactic[] , allTactics : Tactic[]}) { +interface Team { + id : number + name : string + picture : string + main_color : string + second_color : string +} + +export default function Home({ lastTactics, allTactics, teams } : { lastTactics : Tactic[] , allTactics : Tactic[], teams : Team[]}) { + console.log(teams); return (
- <Body lastTactics={lastTactics} allTactics={allTactics}/> + <Body lastTactics={lastTactics} allTactics={allTactics} teams={teams}/> </div> ) } @@ -24,25 +33,25 @@ export function Title() { ) } -export function Body({ lastTactics, allTactics } : { lastTactics : Tactic[], allTactics : Tactic[]}) { - const widthPersonalSpace = 67.5; +export function Body({ lastTactics, allTactics, teams } : { lastTactics : Tactic[], allTactics : Tactic[], teams : Team[]}) { + const widthPersonalSpace = 80; const widthSideMenu = 100-widthPersonalSpace return ( <div id="body"> <PersonalSpace width = {widthPersonalSpace} allTactics = {allTactics}/> - <SideMenu width = {widthSideMenu} lastTactics={lastTactics} /> + <SideMenu width = {widthSideMenu} lastTactics={lastTactics} teams={teams} /> </div> ) } -export function SideMenu({ width, lastTactics } : { width : number, lastTactics : Tactic[] }) { +export function SideMenu({ width, lastTactics, teams } : { width : number, lastTactics : Tactic[], teams : Team[]}) { return ( <div id="sideMenu" style={{ width : width + "%", }}> - <Team/> + <Team teams={teams}/> <Tactic lastTactics={lastTactics}/> </div> ) @@ -110,11 +119,24 @@ function BodyPersonalSpace({ allTactics } : { allTactics : Tactic[]}) { ) } -export function Team() { +export function Team({teams} : {teams : Team[]}) { + const listTeam = teams.map((team, rowIndex) => + <li + key={"team" + rowIndex} + > + {team.name} + <button onClick={() => location.pathname="/team/"+team.id}>open</button> + </li> + ); return ( - <div className="titreSideMenu"> - <h2 className="title">Mes équipes</h2> - <button className="new" onClick={() => location.pathname="/tactic/new"}>+</button> + <div id="teams"> + <div className="titreSideMenu"> + <h2 className="title">Mes équipes</h2> + <button className="new" onClick={() => location.pathname="/team/new"}>+</button> + </div> + <ul> + {listTeam} + </ul> </div> ) } @@ -132,7 +154,7 @@ export function Tactic({lastTactics} : { lastTactics : Tactic[]}) { return ( <div id="tactic"> <div className="titreSideMenu"> - <h2 className="title">Mes cinq dernières stratégies</h2> + <h2 className="title">Mes dernières stratégies</h2> <button className="new" id="createTactic" onClick={() => (location.pathname = "/tactic/new")}>+</button> </div> <ul> diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index f2444a5..9dcfad5 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -35,10 +35,14 @@ class UserController { if ($this->teams != NULL) { $teams = $this->teams->getAll($session->getAccount()->getId()); } + else { + $teams = []; + } return ViewHttpResponse::react("views/Home.tsx", [ "lastTactics" => $lastTactics, - "allTactics" => $allTactics + "allTactics" => $allTactics, + "teams" => $teams ]); // return ViewHttpResponse::react("views/Home.tsx", []); }