From 25721bdda8675e517152d1cbc47b2ff56dcc64bc Mon Sep 17 00:00:00 2001 From: starnakin Date: Mon, 27 Nov 2023 19:15:15 +0100 Subject: [PATCH] add: home --- frontend/static/js/index.js | 6 ++++-- frontend/static/js/views/HomeView.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 frontend/static/js/views/HomeView.js diff --git a/frontend/static/js/index.js b/frontend/static/js/index.js index 20380ea..62af827 100644 --- a/frontend/static/js/index.js +++ b/frontend/static/js/index.js @@ -4,9 +4,10 @@ import Posts from "./views/Posts.js"; import PostView from "./views/PostView.js"; import Settings from "./views/Settings.js"; import Chat from "./views/Chat.js"; +import HomeView from "./views/HomeView.js"; +import RegisterView from "./views/accounts/RegisterView.js"; import { Client } from "./api/client.js"; -import RegisterView from "./views/accounts/RegisterView.js"; let client = new Client(location.protocol + "//" + location.host) @@ -35,6 +36,7 @@ const router = async () => { { path: "/login", view: LoginView }, { path: "/register", view: RegisterView }, { path: "/chat", view: Chat }, + { path: "/home", view: HomeView }, ]; // Test each route for potential match @@ -74,4 +76,4 @@ document.addEventListener("DOMContentLoaded", () => { router(); }); -export { client } +export { client, navigateTo } diff --git a/frontend/static/js/views/HomeView.js b/frontend/static/js/views/HomeView.js new file mode 100644 index 0000000..89ad19a --- /dev/null +++ b/frontend/static/js/views/HomeView.js @@ -0,0 +1,17 @@ +import AbstractView from "./AbstractView.js"; +import { client, navigateTo } from "../index.js"; + +export default class extends AbstractView { + constructor(params) { + super(params); + if (client.isAuthentificate() == false) + navigateTo("/home"); + this.setTitle("register"); + } + + async getHtml() { + return ` +

HOME

+ `; + } +} \ No newline at end of file