Skip to content

Commit 56e3e22

Browse files
authored
Additional profile schema setup( #59)
user Auth and DB schema updated
2 parents f134376 + 7d4e1da commit 56e3e22

16 files changed

+584
-158
lines changed

client/src/js/api.js

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ export async function login(userData) {
4242
localStorage.setItem('accessToken', data.accessToken)
4343
document.cookie = `refreshToken=${data.refreshToken}; HttpOnly`
4444
alert('Login successful!')
45+
46+
// checks for new profile creation
47+
let profCreated = false; // need to feteched and verified from the backend
48+
if (!profCreated) {
49+
window.location.href = 'profile_creation.html'
50+
}
51+
else {
52+
window.location.href = 'user_dashboard.html'
53+
}
54+
4555
} else {
4656
alert(data.message)
4757
}

client/src/js/config.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Development configuration
2-
// export const CONFIG = {
3-
// API_ENDPOINT: 'http://localhost:5000'
4-
// }
2+
export const CONFIG = {
3+
API_ENDPOINT: 'http://localhost:5000'
4+
}
55

66

77
// Production configuration
8-
export const CONFIG = {
9-
API_ENDPOINT: 'https://student-zynergy.vercel.app'
10-
}
8+
// export const CONFIG = {
9+
// API_ENDPOINT: 'https://student-zynergy.vercel.app'
10+
// }

client/src/js/profile_creation.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,21 @@ document.addEventListener('DOMContentLoaded', function () {
2727

2828
function validateForm() {
2929
let isValid = true;
30-
const fullName = document.getElementById('fullName');
31-
const email = document.getElementById('email');
30+
31+
// username check is required for existing users to be fetched from the backend
32+
33+
const username = document.getElementById('username');
34+
// const email = document.getElementById('email');
3235
const phone = document.getElementById('phone');
3336

3437
// Clear previous error messages
3538
clearErrors();
3639

37-
if (fullName.value.trim() === '') {
38-
showError(fullName, 'Full name is required');
40+
if (username.value.trim() === '') {
41+
showError(username, 'Full name is required');
3942
isValid = false;
4043
}
4144

42-
if (email.value.trim() === '') {
43-
showError(email, 'Email is required');
44-
isValid = false;
45-
} else if (!isValidEmail(email.value)) {
46-
showError(email, 'Please enter a valid email address');
47-
isValid = false;
48-
}
4945

5046
if (phone.value.trim() !== '' && !isValidPhone(phone.value)) {
5147
showError(phone, 'Please enter a valid phone number');

client/src/js/register.js

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ document.addEventListener('DOMContentLoaded', function () {
2525

2626
try {
2727
const response = await sendUserData(userData)
28+
console.log(response)
29+
30+
if (response.message === 'Registration successful') {
31+
// showCustomAlert('Registration successful')
32+
// checks for new profile creation
33+
let profCreated = false; // need to feteched and verified from the backend
34+
if (!profCreated) {
35+
window.location.href = 'profile_creation.html'
36+
}
37+
else {
38+
window.location.href = 'user_dashboard.html'
39+
}
40+
41+
}
2842

2943
// form.reset()
3044
} catch (error) {

client/src/js/user_dashboard..js

-25
This file was deleted.

client/src/js/user_dashboard.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// DOM Elements
2+
const profileBanner = document.getElementById('profile-banner');
3+
const updateBannerBtn = document.getElementById('update-banner');
4+
const postForm = document.querySelector('.post-form textarea');
5+
const postButton = document.querySelector('.btn-post');
6+
const photoButton = document.querySelector('.btn-photo');
7+
const postsContainer = document.querySelector('.posts');
8+
const logoutBtn = document.getElementById('logout-btn');
9+
10+
// Update banner functionality
11+
updateBannerBtn.addEventListener('click', () => {
12+
const newBannerUrl = prompt('Enter the URL for the new banner image:');
13+
if (newBannerUrl) {
14+
profileBanner.src = newBannerUrl;
15+
}
16+
});
17+
18+
// Post creation functionality
19+
postButton.addEventListener('click', createPost);
20+
21+
function createPost() {
22+
const postContent = postForm.value.trim();
23+
if (postContent) {
24+
const newPost = document.createElement('article');
25+
newPost.classList.add('post');
26+
newPost.innerHTML = `
27+
<header class="post-header">
28+
<img src="https://i.pinimg.com/236x/41/7b/67/417b67c2c946c28e2cca22d777b84df8.jpg" alt="Muskan Ai" class="post-avatar">
29+
<div>
30+
<h3>Muskan Ai</h3>
31+
<time>Just now</time>
32+
</div>
33+
</header>
34+
<p>${postContent}</p>
35+
<div class="post-actions">
36+
<button><i class="fas fa-thumbs-up"></i> Like</button>
37+
<button><i class="fas fa-comment"></i> Comment</button>
38+
<button><i class="fas fa-share"></i> Share</button>
39+
</div>
40+
`;
41+
postsContainer.prepend(newPost);
42+
postForm.value = '';
43+
}
44+
}
45+
46+
// Photo upload functionality (simulated)
47+
photoButton.addEventListener('click', () => {
48+
alert('Photo upload functionality would be implemented here. This would typically involve opening a file dialog and handling the selected image.');
49+
});
50+
51+
// Like, Comment, Share functionality (simulated)
52+
postsContainer.addEventListener('click', (e) => {
53+
if (e.target.closest('button')) {
54+
const action = e.target.closest('button').textContent.trim();
55+
alert(`${action} functionality would be implemented here.`);
56+
}
57+
});
58+
59+
// Follow and Contact button functionality (simulated)
60+
document.querySelectorAll('.profile-actions button').forEach(button => {
61+
button.addEventListener('click', () => {
62+
alert(`${button.textContent} functionality would be implemented here.`);
63+
});
64+
});
65+
66+
// Navigation functionality
67+
document.querySelectorAll('.profile-nav a').forEach(link => {
68+
link.addEventListener('click', (e) => {
69+
e.preventDefault();
70+
document.querySelectorAll('.profile-nav a').forEach(a => a.classList.remove('active'));
71+
link.classList.add('active');
72+
alert(`Navigating to ${link.textContent} section`);
73+
});
74+
});
75+
76+
// People You May Know - Connect button functionality
77+
document.querySelectorAll('.people-you-may-know .btn-connect').forEach(button => {
78+
button.addEventListener('click', () => {
79+
const personName = button.closest('li').querySelector('h4').textContent;
80+
alert(`Connection request sent to ${personName}`);
81+
});
82+
});
83+
84+
// Logout functionality (simulated)
85+
logoutBtn.addEventListener('click', (e) => {
86+
e.preventDefault();
87+
if (confirm('Are you sure you want to log out?')) {
88+
alert('Logout successful. Redirecting to login page...');
89+
// In a real application, you would redirect to the login page or perform actual logout logic here
90+
}
91+
});
92+
93+
// Initialize any necessary data or state
94+
function initializeProfile() {
95+
// Fetch and display user data, posts, etc.
96+
console.log('Initializing profile data...');
97+
// This would typically involve API calls to get user data, recent posts, etc.
98+
}
99+
100+
// Call initialization function when the page loads
101+
window.addEventListener('load', initializeProfile);

client/src/pages/login.html

+58-53
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
76
<title>Login</title>
8-
<link rel="stylesheet" href="../css/login.css">
9-
<link rel="stylesheet"
10-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
11-
</head>
7+
<link rel="stylesheet" href="../css/login.css" />
8+
<link
9+
rel="stylesheet"
10+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
11+
/>
12+
</head>
1213

13-
<body>
14+
<body>
1415
<div class="login-container">
15-
<div class="top-section">
16-
<div class="back-btn">
17-
<span class="material-symbols-outlined">
18-
arrow_circle_left
19-
</span>Go Back
20-
</div>
21-
22-
</div>
23-
<div class="bottom-section">
24-
<form class="login-box" id="login-form">
25-
<h1 class="input-box-heading">Login</h1>
26-
<img src="https://static.vecteezy.com/system/resources/previews/002/318/271/non_2x/user-profile-icon-free-vector.jpg"
27-
alt="profile-picture-icon" class="profile-picture">
28-
<div class="input-box-div">
29-
<div class="input-box-text-div">
30-
<span class="material-symbols-outlined login-form-icon">
31-
person
32-
</span>
33-
<p>Email</p>
34-
</div>
35-
<input class="input-box" name="email" autocomplete="off" />
36-
</div>
37-
<div class="input-box-div">
38-
<input class="input-box" name="password" autocomplete="off" />
39-
<div class="input-box-text-div">
40-
<span class="material-symbols-outlined login-form-icon">
41-
lock
42-
</span>
43-
<p>Password</p>
44-
</div>
45-
</div>
46-
<div class="button-div">
47-
48-
<a href="register.html" class="blue-border-btn">Sign up</a>
49-
<button class="blue-btn" type="submit">Sign in</button>
50-
</div>
51-
<div>
52-
<p>Forgot Password?</p>
53-
</div>
54-
</form>
55-
<img src="../assets/img/login1-img.png" alt="cartoon-login" class="login-image">
16+
<div class="top-section">
17+
<div class="back-btn">
18+
<a href="index.html" class="material-symbols-outlined">
19+
arrow_circle_left </a
20+
>Go Back
5621
</div>
22+
</div>
23+
<div class="bottom-section">
24+
<form class="login-box" id="login-form">
25+
<h1 class="input-box-heading">Login</h1>
26+
<img
27+
src="https://static.vecteezy.com/system/resources/previews/002/318/271/non_2x/user-profile-icon-free-vector.jpg"
28+
alt="profile-picture-icon"
29+
class="profile-picture"
30+
/>
31+
<div class="input-box-div">
32+
<div class="input-box-text-div">
33+
<span class="material-symbols-outlined login-form-icon">
34+
person
35+
</span>
36+
<p>Email</p>
37+
</div>
38+
<input class="input-box" name="email" autocomplete="off" />
39+
</div>
40+
<div class="input-box-div">
41+
<input class="input-box" name="password" autocomplete="off" />
42+
<div class="input-box-text-div">
43+
<span class="material-symbols-outlined login-form-icon">
44+
lock
45+
</span>
46+
<p>Password</p>
47+
</div>
48+
</div>
49+
<div class="button-div">
50+
<a href="register.html" class="blue-border-btn">Sign up</a>
51+
<button class="blue-btn" type="submit">Sign in</button>
52+
</div>
53+
<div>
54+
<p>Forgot Password?</p>
55+
</div>
56+
</form>
57+
<img
58+
src="../assets/img/login1-img.png"
59+
alt="cartoon-login"
60+
class="login-image"
61+
/>
62+
</div>
5763
</div>
5864
<script type="module" src="../js/login.js"></script>
59-
</body>
60-
61-
</html>
65+
</body>
66+
</html>

client/src/pages/profile_creation.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ <h1>Create Your Profile</h1>
7575
<input type="file" id="profileImage" accept="image/*" hidden />
7676
</div>
7777
<div class="form-group">
78-
<label for="fullName">Full Name</label>
79-
<input type="text" id="fullName" name="fullName" required />
78+
<label for="username">Username</label>
79+
<input type="text" id="username" name="username" required />
8080
</div>
8181
<!-- <div class="form-group">
8282
<label for="location">Location</label>

0 commit comments

Comments
 (0)