Skip to content

Commit

Permalink
adding logged in header
Browse files Browse the repository at this point in the history
  • Loading branch information
EliNygard committed May 22, 2024
1 parent 998122c commit cfd1d26
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions javascript/ui/createPost.mjs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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", () => {
Expand Down
7 changes: 7 additions & 0 deletions javascript/ui/editPost.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -87,3 +88,9 @@ form.addEventListener("submit", function (event) {
alert(error.message); //display error to user
});
});

async function main() {
generateHeaderLoggedInHtml()
}

main();
6 changes: 3 additions & 3 deletions post/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@

</head>
<body>
<header class="bg-color-theme-light">
<nav class="h-f-container header-container font-primary">
<header id="header-logged-in" class="bg-color-theme-light">
<!-- <nav class="h-f-container header-container font-primary">
<div class="content-left">
<a href="../index.html" title="HotView Labs Blog">HotView Labs</a>
</div>
<div class="content-right">
<a href="../account/login.html">Log in</a>
<a href="../account/register.html">Register</a>
</div>
</nav>
</nav> -->
</header>
<main>
<section id="edit-post-wrapper" class="edit-post-wrapper wrapper-padding-2">
Expand Down
6 changes: 3 additions & 3 deletions post/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@

</head>
<body>
<header class="bg-color-theme-light">
<nav class="h-f-container header-container font-primary">
<header id="header-logged-in" class="bg-color-theme-light">
<!-- <nav class="h-f-container header-container font-primary">
<div class="content-left">
<a href="../index.html" title="HotView Labs Blog">HotView Labs</a>
</div>
<div class="content-right">
<a href="../account/login.html">Log in</a>
<a href="../account/register.html">Register</a>
</div>
</nav>
</nav> -->
</header>
<main>
<section id="edit-post-wrapper" class="edit-post-wrapper wrapper-padding-2">
Expand Down

0 comments on commit cfd1d26

Please sign in to comment.