deconnection and fix connection
continuous-integration/drone/push Build is passing Details

pull/39/head
samuel 1 year ago
parent b43eb46638
commit f0faa9b2d2

@ -55,12 +55,7 @@ interface RackedPlayer {
key: string
}
export default function Editor({
id,
name,
courtType,
content,
}: EditorProps) {
export default function Editor({ id, name, courtType, content }: EditorProps) {
const isInGuestMode = id == -1
const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
@ -68,11 +63,16 @@ export default function Editor({
isInGuestMode && storage_content != null ? storage_content : content
const storage_name = localStorage.getItem(GUEST_MODE_TITLE_STORAGE_KEY)
const editorName = isInGuestMode && storage_name != null ? storage_name : name
const editorName =
isInGuestMode && storage_name != null ? storage_name : name
return (
<EditorView
tactic={{ name: editorName, id, content: JSON.parse(editorContent) }}
tactic={{
name: editorName,
id,
content: JSON.parse(editorContent),
}}
onContentChange={async (content: TacticContent) => {
if (isInGuestMode) {
localStorage.setItem(
@ -94,7 +94,8 @@ export default function Editor({
(r) => r.ok,
)
}}
courtType={courtType}/>
courtType={courtType}
/>
)
}

@ -3,7 +3,7 @@ import "../style/new_tactic_panel.css"
import plainCourt from "../assets/court/court.svg"
import halfCourt from "../assets/court/half_court.svg"
import {BASE} from "../Constants";
import { BASE } from "../Constants"
export default function NewTacticPanel() {
return (
@ -45,14 +45,15 @@ function CourtKindButton({
return (
<div
className="court-kind-button"
onClick={() => location.href = BASE + redirect}>
onClick={() => (location.href = BASE + redirect)}>
<div className="court-kind-button-details">{details}</div>
<div className="court-kind-button-top">
<div className="court-kind-button-image-div">
<img
src={image}
alt={name}
className="court-kind-button-image"/>
className="court-kind-button-image"
/>
</div>
</div>
<div className="court-kind-button-bottom">

@ -85,6 +85,8 @@ function getRoutes(): AltoRouter {
$ar->map("GET", "/", Action::auth(fn(SessionHandle $s) => getUserController()->home($s)));
$ar->map("GET", "/home", Action::auth(fn(SessionHandle $s) => getUserController()->home($s)));
$ar->map("GET", "/settings", Action::auth(fn(SessionHandle $s) => getUserController()->settings($s)));
$ar->map("GET", "/disconnect", Action::auth(fn(MutableSessionHandle $s) => getUserController()->disconnect($s)));
//tactic-related
$ar->map("GET", "/tactic/[i:id]/view", Action::auth(fn(int $id, SessionHandle $s) => getVisualizerController()->openVisualizer($id, $s)));

@ -43,7 +43,7 @@ class EditorController {
"id" => -1, //-1 id means that the editor will not support saves
"name" => TacticModel::TACTIC_DEFAULT_NAME,
"content" => '{"players": []}',
"courtType" => $courtType->name()
"courtType" => $courtType->name(),
]);
}

@ -2,8 +2,10 @@
namespace IQBall\App\Controller;
use IQBall\App\Session\MutableSessionHandle;
use IQBall\App\Session\SessionHandle;
use IQBall\App\ViewHttpResponse;
use IQBall\Core\Http\HttpResponse;
use IQBall\Core\Model\TacticModel;
class UserController {
@ -33,4 +35,9 @@ class UserController {
return ViewHttpResponse::twig("account_settings.twig", []);
}
public function disconnect(MutableSessionHandle $session): HttpResponse {
$session->destroy();
return HttpResponse::redirect("/");
}
}

@ -17,4 +17,6 @@ interface MutableSessionHandle extends SessionHandle {
* @param Account $account update the session's account
*/
public function setAccount(Account $account): void;
public function destroy(): void;
}

@ -31,4 +31,8 @@ class PhpSessionHandle implements MutableSessionHandle {
public function setInitialTarget(?string $url): void {
$_SESSION["target"] = $url;
}
public function destroy(): void {
session_destroy();
}
}

@ -40,18 +40,6 @@
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;
}
.error-messages {
color: #ff331a;
@ -68,6 +56,32 @@
;
}
{% endfor %}
.inscr{
font-size: small;
text-align: right;
}
#buttons{
display: flex;
justify-content: space-between;
padding: 10px 20px;
}
.button{
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.button:hover{
background-color: #0056b3;
}
</style>
<div class="container">
@ -82,11 +96,12 @@
<label for="email">Email :</label>
<input type="text" id="email" name="email" required>
<label for="password">Mot de passe :</label>
<input type="password" id="password" name="password" required>
<input type="password" id="password" name="password" required><br><br>
<p class = "inscr">Vous n'avez pas de compte ?</p>
</div>
<div class="form-group">
<input type="submit" value="S'identifier">
<div id = "buttons">
<input class = "button" type="submit" value="S'identifier">
<button class = "button" onclick="location.pathname='{{ path('/register') }}'" >S'inscrire</button>
</div>
</form>
</div>

@ -50,6 +50,7 @@
</head>
<body>
<button onclick="location.pathname='{{ path('/disconnect') }}'"> Se déconnecter</button>
<div id="bandeau">
<h1>IQ Ball</h1>
<div id="account" onclick="location.pathname='{{ path('/settings') }}'">

Loading…
Cancel
Save