diff --git a/front/style/team_panel.css b/front/style/team_panel.css
index d9104a6..935ed96 100644
--- a/front/style/team_panel.css
+++ b/front/style/team_panel.css
@@ -1,8 +1,22 @@
#mainDiv {
- background-color: lightblue;
display: flex;
flex-direction: column;
align-items: center;
+ height: 100%;
+}
+
+header{
+ display: flex;
+ justify-content: center;
+ background-color: #525252;
+ width: 100%;
+ margin-bottom: 5px;
+}
+
+header h1 a{
+ color: orange;
+ text-decoration: none;
+ font-size: 1.5em;
}
.square {
@@ -14,23 +28,51 @@
border: solid;
}
-section {
- background-color: #fff;
+#teamInfo{
display: flex;
flex-direction: column;
align-items: center;
width: 60%;
+ background-color: #8F8F8F;
+ padding-bottom: 10px;
+ border-radius: 10px;
+}
+
+#firstPart{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
+#teamName{
+ font-size: 2.8em;
}
#colors{
display: flex;
- flex-direction: row;
+ flex-direction: column;
}
.color {
flex-direction: row;
justify-content: space-between;
}
+#colorsTitle{
+ width: 110%;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ font-size: 1.3em;
+ color: white;
+}
+
+
+#actualColors{
+ display: flex;
+ flex-direction: row;
+ justify-content: space-around;
+}
+
#logo {
width: 90%;
aspect-ratio: 3/2;
@@ -42,84 +84,49 @@ section {
border-radius:10px ;
background-color: red;
color: white;
+ margin-top: 10px;
+ margin-bottom: 10px;
}
-.player{
+#headMembers{
+ width: 33%;
+ display: flex;
flex-direction: row;
justify-content: space-evenly;
}
-#profilePicture{
- height:40px;
- width:40px;
+#addMember{
+ height: 30px;
+ aspect-ratio: 1/1;
+ border-radius: 100%;
+ align-self: center;
}
#Members{
display: flex;
flex-direction: column;
- background-color: lightcoral;
+ background-color: #BCBCBC;
width: 60%;
align-items: center;
- justify-content: space-between;
-
+ justify-content: space-around;
+ border-radius: 10px;
}
.Member{
width: 60%;
- background-color: red;
+ background-color: white;
display: flex;
flex-direction: row;
justify-content: space-evenly;
-}
-
-#teamInfo{
- display: flex;
- flex-direction: column;
align-items: center;
+ border-radius: 10px;
+ margin-top: 5px;
+ margin-bottom: 5px;
- width: 60%;
- align-items: center;
- background-color: #666666;
}
-#headMembers{
- width: 33%;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
-}
-
-#addMember{
- height: 30px;
- aspect-ratio: 1/1;
- border-radius: 100%;
- align-self: center;
+#profilePicture{
+ height:40px;
+ width:40px;
}
-.popup {
- display: none;
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0,0,0,0.7);
-}
-
-.popup-content {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: #fff;
- padding: 20px;
- text-align: center;
-}
-
-.close {
- position: absolute;
- top: 10px;
- right: 10px;
- font-size: 20px;
- cursor: pointer;
-}
\ No newline at end of file
diff --git a/front/views/TeamPanel.tsx b/front/views/TeamPanel.tsx
index 9b28097..2211145 100644
--- a/front/views/TeamPanel.tsx
+++ b/front/views/TeamPanel.tsx
@@ -2,7 +2,7 @@ import '../style/team_panel.css';
import {BASE} from "../Constants";
import {Team,TeamInfo,Color,User,Member} from "../model/Team/Team"
-export default function TeamPanel({isCoach, team}: {isCoach: boolean, team: Team }){
+export default function TeamPanel({isCoach, team,currentUserId}: {isCoach: boolean, team: Team,currentUserId:number}){
return (
@@ -13,7 +13,7 @@ export default function TeamPanel({isCoach, team}: {isCoach: boolean, team: Team
{isCoach && }
-
+
)
}
@@ -21,15 +21,19 @@ export default function TeamPanel({isCoach, team}: {isCoach: boolean, team: Team
function TeamDisplay({ team}: {team : TeamInfo}) {
return (
-
-
{team.name}
+
+
{team.name}
-
Couleur principale
-
- Couleur secondaire
-
+
+
Couleur principale
+
Couleur secondaire
+
+
+
+
+
)
@@ -49,28 +53,31 @@ function CoachOptions ({id}:{id:number}){
)
}
-function MembersDisplay({members,isCoach}:{members : Member[], isCoach : boolean}){
+function MembersDisplay({members,isCoach,idTeam,currentUserId}:{members : Member[], isCoach : boolean,idTeam : number,currentUserId:number}){
const listMember = members.map((member) =>
-
+
);
return (
Membres :
-
+ {isCoach && }
{listMember}
)
}
-function MemberDisplay({member}: {member : Member}){
+function MemberDisplay({member,isCoach,idTeam,currentUserId}: {member : Member,isCoach : boolean,idTeam:number,currentUserId:number}){
return (
{member.user.name}
{member.role}
{member.user.email}
+ {isCoach && currentUserId !== member.user.id &&
}
+ {isCoach && currentUserId == member.user.id &&
}
+
)
}
diff --git a/public/index.php b/public/index.php
index afe7cd6..46da6c5 100644
--- a/public/index.php
+++ b/public/index.php
@@ -104,10 +104,9 @@ function getRoutes(): AltoRouter {
$ar->map("POST", "/team/search", Action::auth(fn(SessionHandle $s) => getTeamController()->listTeamByName($_POST, $s)));
$ar->map("GET", "/team/[i:id]", Action::auth(fn(int $id, SessionHandle $s) => getTeamController()->displayTeam($id, $s)));
$ar->map("GET", "/team/[i:id]/delete", Action::auth(fn(int $id,SessionHandle $s) => getTeamController()->deleteTeamById($id,$s)));
- $ar->map("GET", "/team/members/add", Action::auth(fn(SessionHandle $s) => getTeamController()->displayAddMember($s)));
+ $ar->map("GET", "/team/[i:id]/addMember", Action::auth(fn(int $id,SessionHandle $s) => getTeamController()->displayAddMember($id,$s)));
$ar->map("POST", "/team/[i:id]/addMember", Action::auth(fn(int $id,SessionHandle $s) => getTeamController()->addMember($id,$_POST, $s)));
- $ar->map("GET", "/team/members/remove", Action::auth(fn(SessionHandle $s) => getTeamController()->displayDeleteMember($s)));
- $ar->map("POST", "/team/members/remove", Action::auth(fn(SessionHandle $s) => getTeamController()->deleteMember($_POST, $s)));
+ $ar->map("POST", "/team/[i:idTeam]/remove/[i:idMember]", Action::auth(fn(int $idTeam,int $idMember,SessionHandle $s) => getTeamController()->deleteMember($idTeam,$idMember, $s)));
return $ar;
}
diff --git a/src/App/Controller/TeamController.php b/src/App/Controller/TeamController.php
index 56ac482..45b14a2 100644
--- a/src/App/Controller/TeamController.php
+++ b/src/App/Controller/TeamController.php
@@ -31,10 +31,6 @@ class TeamController {
return ViewHttpResponse::twig("insert_team.html.twig", []);
}
-
-
-
-
/**
* @param SessionHandle $session
* @return ViewHttpResponse the team panel to delete a member
@@ -137,7 +133,10 @@ class TeamController {
'team' => [
"info" => $result->getInfo(),
"members" => $result->listMembers()
- ], 'isCoach' => $role]);
+ ],
+ 'isCoach' => $role,
+ 'currentUserId'=>$session->getAccount()->getUser()->getId()]
+ );
}
}
@@ -145,8 +144,8 @@ class TeamController {
* @param SessionHandle $session
* @return ViewHttpResponse the team panel to add a member
*/
- public function displayAddMember(SessionHandle $session): ViewHttpResponse {
- return ViewHttpResponse::twig("add_member.html.twig", []);
+ public function displayAddMember(int $idTeam,SessionHandle $session): ViewHttpResponse {
+ return ViewHttpResponse::twig("add_member.html.twig", ['idTeam'=> $idTeam]);
}
/**
@@ -159,12 +158,21 @@ class TeamController {
$errors = [];
$request = HttpRequest::from($request, $errors, [
- "team" => [Validators::isInteger()],
"email" => [Validators::email(), Validators::lenBetween(5, 256)],
]);
-
- $this->model->addMember($request['email'], $idTeam, $request['role']);
- return ViewHttpResponse::redirect('/team/'.$idTeam);
+ if(!empty($errors)){
+ return ViewHttpResponse::twig('add_member.html.twig',['badEmail' => true,'idTeam'=> $idTeam]);
+ }
+ $ret = $this->model->addMember($request['email'], $idTeam, $request['role']);
+
+ switch($ret){
+ case -1:
+ return ViewHttpResponse::twig('add_member.html.twig',['notFound' => true,'idTeam'=> $idTeam]);
+ case -2:
+ return ViewHttpResponse::twig('add_member.html.twig',['alreadyExisting' => true,'idTeam'=> $idTeam]);
+ default:
+ return ViewHttpResponse::redirect('/team/'.$idTeam);
+ }
}
/**
@@ -173,13 +181,12 @@ class TeamController {
* @param SessionHandle $session
* @return HttpResponse
*/
- public function deleteMember(array $request, SessionHandle $session): HttpResponse {
- $errors = [];
- $request = HttpRequest::from($request, $errors, [
- "team" => [Validators::isInteger()],
- "email" => [Validators::email(), Validators::lenBetween(5, 256)],
- ]);
- return $this->displayTeam($this->model->deleteMember($request['email'], intval($request['team'])), $session);
+ public function deleteMember(int $idTeam,int $idMember, SessionHandle $session): HttpResponse {
+ $ret = $this->model->deleteMember($idMember,$idTeam);
+ if($ret == -1 || $session->getAccount()->getUser()->getId() == $idMember ){
+ return ViewHttpResponse::redirect('/');
+ }
+ return $this->displayTeam($ret,$session);
}
}
diff --git a/src/App/Views/add_member.html.twig b/src/App/Views/add_member.html.twig
index 2cc9811..cfee16d 100644
--- a/src/App/Views/add_member.html.twig
+++ b/src/App/Views/add_member.html.twig
@@ -67,26 +67,43 @@
display: flex;
justify-content: space-between;
}
+
+ .failed{
+ color: red;
+ }
+
Ajouter un membre à votre équipe
-