Skip to content

Commit d2af330

Browse files
committed
Adding a standby state to the homepage
1 parent 6f57ea5 commit d2af330

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/api/authServices.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
export const BASE_API_URL = "https://v2.api.noroff.dev";
44

55
const AUTH_REGISTER_URL = `${BASE_API_URL}/auth/register`;
6-
const AUTH_LOGIN_URL = `${BASE_API_URL}/auth/login`;
6+
77
const registerForm = document.querySelector(`#register-form`);
8-
const loginForm = document.querySelector(`#login-form`);
98

109
async function registerUser(userDetails) {
1110
try {

src/main.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,23 @@ async function generatePosts(posts) {
3636
}
3737
}
3838
async function main() {
39-
const posts = await fetchPosts();
40-
generatePosts(posts);
41-
console.log(posts);
39+
if (!localStorage.getItem("accessToken")) {
40+
displayContainer.innerHTML = `
41+
<h1>Still</h1>
42+
<p>Get started at Still!</p>
43+
<div class="index-button-container">
44+
<button>Log in</button>
45+
<p>Or</p>
46+
<button>Create new profile</button>
47+
</div>`;
48+
} else {
49+
try {
50+
const posts = await fetchPosts();
51+
generatePosts(posts);
52+
} catch (error) {
53+
console.log(error);
54+
alert("Something wnt wrong, please return later!");
55+
}
56+
}
4257
}
4358
main();

0 commit comments

Comments
 (0)