diff --git a/front/style/home.css b/front/style/home.css
index ed496dc..19067f8 100644
--- a/front/style/home.css
+++ b/front/style/home.css
@@ -33,7 +33,7 @@
background-color: grey;
}
-#ps-title {
+#titlePersonalSpace h2 {
text-align: center;
}
@@ -57,4 +57,13 @@
background-color: black;
padding : 1.5%;
margin-bottom: 0px;
+}
+
+table {
+ width: 100%;
+}
+
+td {
+ text-align: center;
+ border : 3px solid black;
}
\ No newline at end of file
diff --git a/front/views/Home.tsx b/front/views/Home.tsx
index 43de571..b0442ef 100644
--- a/front/views/Home.tsx
+++ b/front/views/Home.tsx
@@ -7,11 +7,11 @@ interface Tactic {
creation_date : string
}
-export default function Home({ lastTactics } : { lastTactics : Tactic[] }) {
+export default function Home({ lastTactics, allTactics } : { lastTactics : Tactic[] , allTactics : Tactic[]}) {
return (
-
+
)
}
@@ -24,12 +24,12 @@ export function Title() {
)
}
-export function Body({ lastTactics } : { lastTactics : Tactic[] }) {
+export function Body({ lastTactics, allTactics } : { lastTactics : Tactic[], allTactics : Tactic[]}) {
const widthPersonalSpace = 67.5;
const widthSideMenu = 100-widthPersonalSpace
return (
@@ -49,12 +49,63 @@ export function SideMenu({ width, lastTactics } : { width : number, lastTactics
}
-export function PersonalSpace({ width }: { width : number }) {
+export function PersonalSpace({ width, allTactics }: { width : number, allTactics : Tactic[] }) {
return (
-
Espace Personnel
+
+
+
+ )
+}
+
+function TitlePersonalSpace() {
+ return (
+
+
Espace Personnel
+
+ )
+}
+
+function BodyPersonalSpace({ allTactics } : { allTactics : Tactic[]}) {
+ const nbRow = Math.floor(allTactics.length/3)+1;
+ let listTactic = Array(nbRow);
+ for (let i = 0; i < nbRow; i++) {
+ listTactic[i] = Array(0);
+ }
+ let i = 0;
+ let j = 0;
+ allTactics.forEach(tactic => {
+ listTactic[i].push(tactic);
+ j++;
+ if (j === 3) {
+ i++;
+ j = 0;
+ }
+ })
+
+ i = 0;
+ while (i < nbRow) {
+ listTactic[i] = listTactic[i].map((tactic : Tactic) =>
+ {tactic.name} |
+ );
+ i++;
+ }
+
+ const data = listTactic.map((tactic, rowIndex) =>
+
+ {tactic}
+
+ );
+ return (
+
)
}
diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php
index eaa0120..f292cb6 100644
--- a/src/App/Controller/UserController.php
+++ b/src/App/Controller/UserController.php
@@ -22,9 +22,11 @@ class UserController {
*/
public function home(SessionHandle $session): ViewHttpResponse {
$limitNbTactics = 5;
- $lastTactic = $this->tactics->getLast($limitNbTactics, $session->getAccount()->getId());
+ $lastTactics = $this->tactics->getLast($limitNbTactics, $session->getAccount()->getId());
+ $allTactics = $this->tactics->getAll($session->getAccount()->getId());
return ViewHttpResponse::react("views/Home.tsx", [
- "lastTactics" => $lastTactic
+ "lastTactics" => $lastTactics,
+ "allTactics" => $allTactics
]);
// return ViewHttpResponse::react("views/Home.tsx", []);
}
diff --git a/src/Core/Gateway/TacticInfoGateway.php b/src/Core/Gateway/TacticInfoGateway.php
index 5721f6f..a7f1f7b 100644
--- a/src/Core/Gateway/TacticInfoGateway.php
+++ b/src/Core/Gateway/TacticInfoGateway.php
@@ -48,8 +48,8 @@ class TacticInfoGateway {
"SELECT *
FROM Tactic
WHERE owner = :ownerId
- ORDER BY creation_date
- DESC LIMIT :nb",
+ ORDER BY creation_date DESC
+ LIMIT :nb",
[
":ownerId" => [$ownerId, PDO::PARAM_INT],":nb" => [$nb, PDO::PARAM_INT]
]
@@ -60,6 +60,27 @@ class TacticInfoGateway {
return $res;
}
+ /**
+ * Get all the tactics of the owner
+ *
+ * @return array>
+ */
+ public function getAll(int $ownerId): ?array {
+ $res = $this->con->fetch(
+ "SELECT *
+ FROM Tactic
+ WHERE owner = :ownerId
+ ORDER BY name DESC",
+ [
+ ":ownerId" => [$ownerId, PDO::PARAM_INT]
+ ]
+ );
+ if (count($res) == 0) {
+ return [];
+ }
+ return $res;
+ }
+
/**
* @param string $name
* @param int $owner
diff --git a/src/Core/Model/TacticModel.php b/src/Core/Model/TacticModel.php
index d9e783e..f605155 100644
--- a/src/Core/Model/TacticModel.php
+++ b/src/Core/Model/TacticModel.php
@@ -63,6 +63,15 @@ class TacticModel {
return $this->tactics->getLast($nb, $ownerId);
}
+ /**
+ * Get all the tactics of the owner
+ *
+ * @param integer $ownerId
+ * @return array|null
+ */
+ public function getAll(int $ownerId): ?array {
+ return $this->tactics->getAll($ownerId);
+ }
/**
* Update the name of a tactic
* @param int $id the tactic identifier