From cfd1d264e80312895838198627d2b37397b7a879 Mon Sep 17 00:00:00 2001 From: EliNygard Date: Wed, 22 May 2024 10:26:37 +0200 Subject: [PATCH] adding logged in header --- index.mjs | 4 ++-- javascript/ui/createPost.mjs | 9 +++++++++ javascript/ui/editPost.mjs | 7 +++++++ post/create.html | 6 +++--- post/edit.html | 6 +++--- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/index.mjs b/index.mjs index f2a04f1..56b0730 100644 --- a/index.mjs +++ b/index.mjs @@ -22,8 +22,8 @@ async function checkAndRenderPosts() { await renderNewPostsCarousel(API_BASE + API_POSTS + API_NAME); } else { // If user is not logged in, render posts from this account anyway - // await renderPosts(API_BASE + API_POSTS + "/Leli_Nygard") - // await renderNewPostsCarousel(API_BASE + API_POSTS + "/Leli_Nygard") + await renderPosts(API_BASE + API_POSTS + "/Leli_Nygard") + await renderNewPostsCarousel(API_BASE + API_POSTS + "/Leli_Nygard") } } catch (error) { console.error(error); diff --git a/javascript/ui/createPost.mjs b/javascript/ui/createPost.mjs index e1a2af7..a64ffd8 100644 --- a/javascript/ui/createPost.mjs +++ b/javascript/ui/createPost.mjs @@ -1,9 +1,12 @@ import { API_BASE, API_NAME, API_POSTS } from "../api/constantAPI.mjs"; +import { generateHeaderLoggedInHtml } from "../generateHtml/headerLoggedIn.mjs"; // import { // extractErrorMessages, // renderErrorMessageHtml, // } from "../messages/errorMessage.mjs"; + + const form = document.querySelector("form"); form.addEventListener("submit", function (event) { @@ -77,6 +80,12 @@ form.addEventListener("submit", function (event) { }); }); +async function main() { + generateHeaderLoggedInHtml() +} + +main(); + // TRYING TO PUT INTO SEVERAL FUNCTIONS, BUT FAILED. NOT WORKING. TRY LATER // document.addEventListener("DOMContentLoaded", () => { diff --git a/javascript/ui/editPost.mjs b/javascript/ui/editPost.mjs index 2f23d8b..3679a8c 100644 --- a/javascript/ui/editPost.mjs +++ b/javascript/ui/editPost.mjs @@ -1,4 +1,5 @@ import { API_BASE, API_ID, API_NAME, API_POSTS } from "../api/constantAPI.mjs"; +import { generateHeaderLoggedInHtml } from "../generateHtml/headerLoggedIn.mjs"; // import { // extractErrorMessages, // renderErrorMessageHtml, @@ -87,3 +88,9 @@ form.addEventListener("submit", function (event) { alert(error.message); //display error to user }); }); + +async function main() { + generateHeaderLoggedInHtml() +} + +main(); diff --git a/post/create.html b/post/create.html index fe55636..8361322 100644 --- a/post/create.html +++ b/post/create.html @@ -32,8 +32,8 @@ -
-