Added a view for the creation of a team, started the list by name action
continuous-integration/drone/push Build is passing Details

pull/16/head
Maël DAIM 2 years ago
parent c8df556699
commit d08defaf65

@ -20,16 +20,22 @@ class TeamController /* verif si les camp sont assignés, sinon erreur 400*/
public function submitTeam(array $request){
$errors = [];
if(isset($request['name']) && isset($request["picture"]) && isset($request["mainColor"]) && isset($request["secondColor"])){
$errors = $this->model->createTeam($request['name'],$request['picture'],$request['mainColor'],$request["secondColor"]);
/*todo gestion des erreurs grace au tableau*/
$this->model->createTeam($request['name'],$request['picture'],$request['mainColor'],$request["secondColor"],$errors);
if(!empty($errors)){
/*todo appelle vue avec param*/
}
}
public function listTeamByName(array $request){
$errors = [];
$this->model->listByName($request['name'],$errors);
if(!empty($errors)){
/*todo appelle vue avec param*/
}
else{
http_response_code(400);
/*todo rappeler vue avec parametre pour signaler les pb */
/*todo appelle bonne vue*/
}
}
}

@ -27,7 +27,12 @@ class TeamGateway /* retourne exception par rapport à la validité du paramètr
}
public function listByName($name): array {
/*todo*/
return $this->con->fetch(
"SELECT name,picture,mainColor,secondColor FROM Team WHERE name LIKE '% :thing %' ",
[
":thing" => [$name, PDO::PARAM_STR]
]
);
}
}

@ -16,6 +16,7 @@ class TeamModel /* throw des exceptions(ex validation des champs, filtre etc) po
public const ERROR_INVALID_NAME = 1;
public const ERROR_INVALID_PICTURE = 2;
public const ERROR_INVALID_SEARCH = 3;
public const ERROR_NO_DATA_FOUND = 4;
private TeamGateway $gateway;
@ -49,9 +50,17 @@ class TeamModel /* throw des exceptions(ex validation des champs, filtre etc) po
}
public function list(string $search,array $errors):array {
if(Validation::hasHTMLInjection($search)){
public function listByName(string $name,array $errors):?array {
if(Validation::hasHTMLInjection($name)){
$errors = self::ERROR_INVALID_SEARCH;
}
$results = $this->gateway->listByName($name);
if(empty($results)){
$errors = self::ERROR_NO_DATA_FOUND;
}
if(!empty($errors)){
return $results;
}
return null;
}
}

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Insertion view</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f1f1f1;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="submit"] {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h2>Créer une équipe</h2>
<form action="/team/new" method="post">
<div class="form-group">
<label for="name">Nom de l'équipe :</label>
<input type="text" id="name" name="name" required>
<label for= "picture">Logo:</label>
<input type="text" id="picture" name="picture" required >
<label for="mainColor">Couleur principale</label>
<input type="text" id="mainColor" name="mainColor" required>
<label for="secondColor">Couleur secondaire</label>
<input type="text" id="secondColor" name="secondColor" required>
</div>
<div class="form-group">
<input type="submit" value="Confirmer">
</div>
</form>
</div>
</body>
</html>
Loading…
Cancel
Save