Skip to content

Commit

Permalink
file update
Browse files Browse the repository at this point in the history
  • Loading branch information
woshiJay committed Mar 22, 2024
1 parent 724cb4d commit 428ac71
Show file tree
Hide file tree
Showing 10 changed files with 357 additions and 334 deletions.
2 changes: 1 addition & 1 deletion src/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function submitLoginResponse(event) {
const data = await response.json();
if (data.uid) {
sessionStorage.setItem('userId', data.uid);
window.location.href = '/src/index.html';
window.location.href = '/src/pages/home.html';
} else if (data.alert) {
alert(data.alert);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/userID.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
window.onload = () => {
const userId = sessionStorage.getItem('userId');
if (!userId) {
window.location.href = '/src/login.html';
window.location.href = '/src/pages/login.html';
} else {
fetch(`http://localhost:5501/get-username?uid=${userId}`)
.then(resp => resp.json())
Expand Down
14 changes: 12 additions & 2 deletions src/favourite.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
window.onload = () => {
const userId = sessionStorage.getItem('userId');
if (!userId) {
window.location.href = '/src/login.html';
window.location.href = '/src/pages/login.html';
} else {
fetch(`http://localhost:5501/api/user_restaurants?userID=${userId}`)
fetch(`http://localhost:5501/get-username?uid=${userId}`)
.then(resp => resp.json())
.then(data => {
// Assuming 'data' has a 'username' property with the user's name
const username = data.username;
const usernameElement = document.querySelector('.user-disp');
// Replace the placeholder text with the actual username
usernameElement.textContent = `Welcome Back, ${username}.`;

return fetch(`http://localhost:5501/api/user_restaurants?userID=${userId}`)
})
.then(resp => resp.json())
.then(restaurants => {
const container = document.querySelector('.row.justify-content-center'); // The container where the rows will be appended
Expand Down
67 changes: 67 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/images/fried-egg.png" type="image" />
<link href="/src/styles/styles.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<title>What to Eat</title>
</head>

<body>
<!-- navbar -->
<nav class="navbar navbar-expand-lg py-3 mb-5">
<div class="container">
<div class="col fw-bold">
<div class="d-flex justify-content-between align-items-center fw-light">
<ul class="nav">
<li class="nav-item">
<a class="navbar-brand" href="#">
<img src="/images/fried-egg.png" alt="brand" class="img-fluid" width="35px" height="35px">
</a>
</li>
</ul>
<div class="d-flex justify-content-end">
<ul class="nav">
<li class="nav-item text-decoration-underline">
<a href="./pages/about.html" id="about" class="nav-link link-body-emphasis">About</a>
</li>
</div>
</ul>
</div>
</div>
</div>
</nav>

<div class="cover-container">
<div class="row">
<div class="col">
<div class="spacer"></div>
<div class="d-flex flex-column align-items-center">
<h1 class="mb-3 fs-1 font-monospace">Chi-She-Mo</h1>
<h4 class="mb-5 fw-light">Simplify Food.</h4>
<a href="/src/pages/index.html">
<button class="btn shadow rounded-5 px-5 py-3 fw-semibold" type="button">Try me</button>
</a>
</div>
</div>
</div>
</div>

<footer class="p-3">
<div class="container">
<div class="text-lg-start">
<hr>
<p class="text-muted small mb-4 mb-lg-0">&copy; Chi-She-Mo 2024. All Rights Reserved.</p>
</div>
</div>
</footer>

<script src="/src/main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>

</html>
74 changes: 0 additions & 74 deletions src/landing.html

This file was deleted.

6 changes: 3 additions & 3 deletions src/pages/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="d-flex justify-content-between align-items-center fw-light">
<ul class="nav">
<li class="nav-item">
<a class="navbar-brand" href="./index.html">
<a class="navbar-brand" href="./home.html">
<img src="/images/fried-egg.png" alt="brand" class="img-fluid" width="35px" height="35px">
</a>
</li>
Expand All @@ -30,13 +30,13 @@ <h3 class="font-monospace">Chi_She_Mo</h3>
<div class="d-flex justify-content-end">
<ul class="nav">
<li class="nav-item text-decoration-underline">
<a href="/src/pages/index.html" id="about" class="nav-link link-body-emphasis">Home</a>
<a href="/src/pages/home.html" id="about" class="nav-link link-body-emphasis">Home</a>
</li>
<li class="nav-item text-decoration-underline">
<a href="/src/pages/favourite.html" id="favourites" class="nav-link link-body-emphasis">Favourites</a>
</li>
<li class="nav-item text-decoration-underline">
<a href="/src/landing.html" id="logout" class="nav-link link-body-emphasis">Logout</a>
<a href="/src/index.html" id="logout" class="nav-link link-body-emphasis">Logout</a>
</li>
</ul>
</div>
Expand Down
25 changes: 18 additions & 7 deletions src/pages/favourite.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand All @@ -18,7 +19,7 @@
<div class="d-flex justify-content-between align-items-center fw-light">
<ul class="nav">
<li class="nav-item">
<a class="navbar-brand" href="#">
<a class="navbar-brand" href="/src/pages/index.html">
<img src="/images/fried-egg.png" alt="brand" class="img-fluid" width="35px" height="35px">
</a>
</li>
Expand All @@ -29,16 +30,16 @@ <h3 class="font-monospace">Chi_She_Mo</h3>
<div class="d-flex justify-content-end">
<ul class="nav">
<li class="nav-item text-decoration-underline">
<a href="/src/pages/index.html" id="about" class="nav-link link-body-emphasis">Home</a>
<a href="/src/pages/home.html" id="about" class="nav-link link-body-emphasis">Home</a>
</li>
<li class="nav-item text-decoration-underline">
<a href="/src/pages/about.html" id="favourites" class="nav-link link-body-emphasis">About</a>
</li>
<li class="nav-item text-decoration-underline">
<a href="./landing.html" id="logout" class="nav-link link-body-emphasis">Logout</a>
<a href="/src/index.html" id="logout" class="nav-link link-body-emphasis">Logout</a>
</li>
</div>
</ul>
</ul>
</div>
</div>
</div>
</div>
Expand All @@ -50,7 +51,7 @@ <h3 class="font-monospace">Chi_She_Mo</h3>
<h3 class="user-disp">Hello {user},</h3>
<h4 class="fw-lighter">Revisit your favourite restaurants here:</h4>
</div>
</div>
</div>
</div>

<div class="container">
Expand All @@ -77,6 +78,16 @@ <h4 class="fw-lighter">Revisit your favourite restaurants here:</h4>
</div>
</div>

<script src="/src/favourite.js"></script>
<script src="/src/favourite.js"></script>
</body>

<footer class="p-3">
<div class="container">
<div class="text-lg-start">
<hr>
<p class="text-muted small mb-4 mb-lg-0">&copy; Chi-She-Mo 2024. All Rights Reserved.</p>
</div>
</div>
</footer>

</html>
Loading

0 comments on commit 428ac71

Please sign in to comment.