From eb154aaec0eaef5450c05bd8ca0c63b1d2ff9d10 Mon Sep 17 00:00:00 2001 From: d_yanis Date: Mon, 4 Dec 2023 16:17:49 +0100 Subject: [PATCH] Add a basic react view with html component --- .vscode/launch.json | 38 +++++++++++++++++++++++++++ config.php | 3 +-- front/views/Home.tsx | 7 +++++ public/index.php | 4 +-- src/App/Controller/UserController.php | 4 +-- 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 front/views/Home.tsx diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0aaa092 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,38 @@ +{ + // Utilisez IntelliSense pour en savoir plus sur les attributs possibles. + // Pointez pour afficher la description des attributs existants. + // Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch built-in server and debug", + "type": "php", + "request": "launch", + "runtimeArgs": [ + "-S", + "localhost:8080", + "-t", + "./public" + ], + "port": 8080, + "serverReadyAction": { + "action": "openExternally" + } + }, + { + "name": "Debug current script in console", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "externalConsole": false, + "port": 9003 + }, + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003 + } + ] +} \ No newline at end of file diff --git a/config.php b/config.php index 6e510c8..c65c3db 100644 --- a/config.php +++ b/config.php @@ -10,7 +10,6 @@ const SUPPORTS_FAST_REFRESH = _SUPPORTS_FAST_REFRESH; /** * Maps the given relative source uri (relative to the `/front` folder) to its actual location depending on imported profile. * @param string $assetURI relative uri path from `/front` folder - * @return string valid url that points to the given uri */ function asset(string $assetURI): string { return _asset($assetURI); @@ -19,4 +18,4 @@ function asset(string $assetURI): string { global $_data_source_name; $data_source_name = $_data_source_name; const DATABASE_USER = _DATABASE_USER; -const DATABASE_PASSWORD = _DATABASE_PASSWORD; +const DATABASE_PASSWORD = _DATABASE_PASSWORD; \ No newline at end of file diff --git a/front/views/Home.tsx b/front/views/Home.tsx new file mode 100644 index 0000000..9e506fa --- /dev/null +++ b/front/views/Home.tsx @@ -0,0 +1,7 @@ +export default function Home(){ + return ( +
+

Home

+
+ ) +} \ No newline at end of file diff --git a/public/index.php b/public/index.php index 8c9a62b..27bd935 100644 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,5 @@ match(), PhpSessionHandle::init()), fn() => getTwig()); +App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig()); \ No newline at end of file diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index 5ce1318..920993a 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -23,9 +23,7 @@ class UserController { * @return ViewHttpResponse the home page view */ public function home(SessionHandle $session): ViewHttpResponse { - //TODO use session's account to get the last 5 tactics of the logged-in account - $listTactic = $this->tactics->getLast(5); - return ViewHttpResponse::twig("home.twig", ["recentTactic" => $listTactic]); + return ViewHttpResponse::react("views/Home.tsx", []); } /**