Add a basic react view with html component

pull/81/head
d_yanis 1 year ago
parent a472a4d0b7
commit eb154aaec0

@ -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
}
]
}

@ -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. * 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 * @param string $assetURI relative uri path from `/front` folder
* @return string valid url that points to the given uri
*/ */
function asset(string $assetURI): string { function asset(string $assetURI): string {
return _asset($assetURI); return _asset($assetURI);
@ -19,4 +18,4 @@ function asset(string $assetURI): string {
global $_data_source_name; global $_data_source_name;
$data_source_name = $_data_source_name; $data_source_name = $_data_source_name;
const DATABASE_USER = _DATABASE_USER; const DATABASE_USER = _DATABASE_USER;
const DATABASE_PASSWORD = _DATABASE_PASSWORD; const DATABASE_PASSWORD = _DATABASE_PASSWORD;

@ -0,0 +1,7 @@
export default function Home(){
return (
<div>
<h1>Home</h1>
</div>
)
}

@ -1,6 +1,5 @@
<?php <?php
require "../vendor/autoload.php"; require "../vendor/autoload.php";
require "../config.php"; require "../config.php";
require "../sql/database.php"; require "../sql/database.php";
@ -122,8 +121,7 @@ function runMatch($match, MutableSessionHandle $session): HttpResponse {
return App::runAction($basePath . '/login', $match['target'], $match['params'], $session); return App::runAction($basePath . '/login', $match['target'], $match['params'], $session);
} }
//this is a global variable //this is a global variable
$basePath = get_public_path(__DIR__); $basePath = get_public_path(__DIR__);
App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig()); App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig());

@ -23,9 +23,7 @@ class UserController {
* @return ViewHttpResponse the home page view * @return ViewHttpResponse the home page view
*/ */
public function home(SessionHandle $session): ViewHttpResponse { public function home(SessionHandle $session): ViewHttpResponse {
//TODO use session's account to get the last 5 tactics of the logged-in account return ViewHttpResponse::react("views/Home.tsx", []);
$listTactic = $this->tactics->getLast(5);
return ViewHttpResponse::twig("home.twig", ["recentTactic" => $listTactic]);
} }
/** /**

Loading…
Cancel
Save