diff --git a/front/views/Home.tsx b/front/views/Home.tsx index 72643ab..de4eb87 100644 --- a/front/views/Home.tsx +++ b/front/views/Home.tsx @@ -44,7 +44,7 @@ export function Tactic() {

Mes stratégies

- +
) diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index 37aae73..e5679d3 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -21,7 +21,23 @@ class UserController { * @return ViewHttpResponse the home page view */ public function home(SessionHandle $session): ViewHttpResponse { - return ViewHttpResponse::react("views/Home.tsx", []); + $lastTactic = $this->tactics->getLast(5); + return ViewHttpResponse::react("views/Home.tsx", $this->listTacticToJson($lastTactic)); + } + + private function listTacticToJson(array $listTactic) : array { + $jsonReturn = []; + foreach ($listTactic as $tactic){ + //var_dump($tactic); + $jsonTactic = [ + "id" => $tactic["id"], + "name" => $tactic["name"], + "creationDate" => $tactic["creation_date"] + ]; + array_push($jsonReturn, $jsonTactic); + } + var_dump($jsonReturn); + return $jsonReturn; } public function homeTwig(SessionHandle $session): ViewHttpResponse { diff --git a/src/Core/Model/TacticModel.php b/src/Core/Model/TacticModel.php index 136b27d..9a71f4f 100644 --- a/src/Core/Model/TacticModel.php +++ b/src/Core/Model/TacticModel.php @@ -54,6 +54,10 @@ class TacticModel { * @param integer $nb * @return array> */ + + /** + * Return the nb last tactics + */ public function getLast(int $nb): ?array { return $this->tactics->getLast($nb); }