Skip to content

Commit 1f86cf5

Browse files
Edit button on user page when logged in
2 parents 54ac892 + d73caea commit 1f86cf5

File tree

5 files changed

+31
-46
lines changed

5 files changed

+31
-46
lines changed

public/pages/user-profile.ejs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,18 @@
8888
<p>Created with <code class="text-theme">FetchCV</code></p>
8989

9090
</div>
91-
<!-- future settings panel (for use with customizing profile card and accessing account settings) -->
92-
<div class="settings-toolbar hidden flex fixed bottom-0 w-screen px-0 py-1 bg-zinc-700 border-[1px] border-zinc-700 border-t-zinc-600">
91+
</div>
92+
<!-- future settings panel (for use with customizing profile card and accessing account settings) -->
93+
<div
94+
class="settings-toolbar hidden flex fixed bottom-0 w-screen px-0 py-1 bg-zinc-700 border-[1px] border-zinc-700 border-t-zinc-600">
9395
<div class="absolute bottom-0 -z-10 -left-40 w-[140%] h-full caution-tape"></div>
94-
<div class="inline-flex justify-center transition-all p-2 mx-1 shadow-lg bg-zinc-800 border-[1px] border-zinc-700 border-t-zinc-600 rounded-md text-black">
95-
<span class="material-symbols-rounded text-private" onclick="toggleEditMode()">settings</span>
96+
<div
97+
class="inline-flex justify-center transition-all p-2 mx-1 shadow-lg bg-zinc-800 border-[1px] border-zinc-700 border-t-zinc-600 rounded-md text-black">
98+
<span class="material-symbols-rounded text-private" onclick="
99+
window.location.href = window.location.origin + '/edit-profile';
100+
">settings</span>
96101
</div>
97102
</div>
98-
99-
</div>
100103
</body>
101104
<style>
102105
p {
@@ -112,4 +115,5 @@
112115
<script src="/scripts/github/displayData.js"></script>
113116
<script src="/scripts/userProfile.js"></script>
114117
<script src="/scripts/showEditProfile.js"></script>
115-
</html>
118+
119+
</html>

public/scripts-src/editProfile.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
// functions
2-
function toggleEditMode() {
3-
let editPanel = document.querySelector(".edit-controls");
4-
if (editPanel?.classList.contains("hidden")) {
5-
editPanel?.classList.remove("hidden");
6-
prepareEditMode();
7-
}
8-
else {
9-
editPanel?.classList.add("hidden");
10-
}
11-
}
12-
131
function showChangesBanner() {
142
let banner = document.querySelector(".changes-saved-banner");
153
toggleVisibility(banner);

public/scripts-src/showEditProfile.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
async function isLoggedIn() {
2-
let loggedIn;
3-
fetch("/is-logged-in")
4-
.then(response => {
5-
if (!response.ok) {
6-
throw new Error("Network error");
7-
}
8-
return response.json();
9-
})
10-
.then(data => {
11-
loggedIn = data.loggedIn;
12-
})
13-
.catch(console.error);
14-
return loggedIn;
2+
let loggedIn = "no";
3+
await fetch("/is-logged-in")
4+
.then(response => {
5+
if (!response.ok) {
6+
throw new Error("Network error");
7+
}
8+
return response.json();
9+
})
10+
.then(data => {
11+
loggedIn = data.loggedIn;
12+
})
13+
.catch(error => {
14+
console.error(error);
15+
});
16+
return loggedIn
1517
}
1618

1719
async function checkUser() {

public/scripts/editProfile.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
// functions
2-
function toggleEditMode() {
3-
let editPanel = document.querySelector(".edit-controls");
4-
if (editPanel?.classList.contains("hidden")) {
5-
editPanel?.classList.remove("hidden");
6-
prepareEditMode();
7-
}
8-
else {
9-
editPanel?.classList.add("hidden");
10-
}
11-
}
121
function showChangesBanner() {
132
let banner = document.querySelector(".changes-saved-banner");
143
toggleVisibility(banner);

public/scripts/showEditProfile.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
async function isLoggedIn() {
2-
let loggedIn;
3-
fetch("/is-logged-in")
2+
let loggedIn = "no";
3+
await fetch("/is-logged-in")
44
.then(response => {
55
if (!response.ok) {
66
throw new Error("Network error");
@@ -10,7 +10,9 @@ async function isLoggedIn() {
1010
.then(data => {
1111
loggedIn = data.loggedIn;
1212
})
13-
.catch(console.error);
13+
.catch(error => {
14+
console.error(error);
15+
});
1416
return loggedIn;
1517
}
1618
async function checkUser() {

0 commit comments

Comments
 (0)