Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Edit Profile Feature in Profile Page done ! #994 #1081

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,36 @@ <h2>What type of transportation do you prefer for your travels?</h2>
</div>


<!-- Profile Icon -->
<!-- <a href="./testp.html" class="profile-link" style="display: flex; align-items: center; text-decoration: none;">
<img src="https://i.postimg.cc/tCL5Td4H/gold-membership-icon-default-avatar-profile-icon-membership-icon-social-media-user-image-illustratio.jpg" alt="Profile Icon" style="width: 35px; height: 35px; border-radius: 50%; margin-left: -170px;">
</a>
</li> -->

<!-- Profile Icon -->

<a href="./testp.html" class="profile-link" style="display: flex; align-items: center; text-decoration: none;">
<img id="homeProfileImage" src="https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg"
alt="Profile Icon"
style="width: 35px; height: 35px; border-radius: 50%; margin-left: -170px;">
</a>

</li>



<script>

document.addEventListener("DOMContentLoaded", function() {
// Retrieve the saved avatar from localStorage
const savedAvatar = localStorage.getItem("selectedAvatar");

// If an avatar is saved, update the profile image
if (savedAvatar) {
const homeProfileImage = document.getElementById("homeProfileImage");
if (homeProfileImage) {
homeProfileImage.src = savedAvatar;
}
}
});

</script>


<style>

Expand Down
345 changes: 345 additions & 0 deletions profileedit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Profile</title>

<link rel="stylesheet" href="style.css">

<style>

body {

font-family: 'Arial', sans-serif;
background-color: #1f2937;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;

}

.container {

background: linear-gradient(135deg, #ead6ee, #a0f1ea);
padding: 20px;
border-radius: 8px;
box-shadow: 50px 50px 50px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%;
max-width: 800px;
margin: auto;

}

.edit-profile {

text-align: center;
margin-bottom: 20px;
width: 100%;

}

.edit-profile h3 {

margin-bottom: 10px;
color: #333;
font-size: 24px;

}

.home-link {

display: flex;
align-items: center;
color: rgb(0 0 0);
font-size: 18px;
text-decoration: none;
position: absolute;
margin-left: 20px;

}

.home-link i {

margin-right: 8px;
font-size: 24px;

}

.home-link:hover {

color: #302e2e;

}

.avatar-selection {

text-align: center;
margin-bottom: 20px;

}

.avatars {

display: flex;
justify-content: center;
gap: 20px;
margin-top: 20px;

}

.avatars img {

width: 120px;
height: 120px;
cursor: pointer;
border: 4px solid transparent;
border-radius: 50%;
transition: transform 0.3s ease-in-out, border-color 0.3s ease-in-out;

}

.avatars img:hover {

transform: scale(1.1);

}

.avatars img.selected {

border-color: #077183;

}

.profile-details {

text-align: center;
margin-bottom: 20px;
width: 100%;

}

.profile-details h4 {

margin-bottom: 10px;
color: #333;
font-size: 20px;

}

.profile-details input {

width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;

}

.save-button {

background: linear-gradient(135deg, #079874, #076887);
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
margin-top: 20px;

}

.save-button:hover {

background: linear-gradient(135deg, #079874, #076887);
transform: scale(1.05);

}

.save-button:focus {

outline: none;

}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {

margin: 0;
padding: 0;
box-sizing: border-box;

}

.container {

max-width: 1170px;
margin: auto;

}

.row {

display: flex;
flex-wrap: wrap;

}

ul {

list-style: none;

}

</style>

</head>

<body>

<div class="container">
<div class="edit-profile">
<!-- Home Link -->
<a href="../../index.html" class="home-link">
<i class='bx bx-home'></i> Home
</a>

<h3>Edit Profile</h3>
</div>

<div class="avatar-selection">
<h4>Select Avatar</h4>
<div class="avatars">
<img src="https://i.postimg.cc/VvvM4LLK/4140061.png" onclick="selectAvatar('https://i.postimg.cc/VvvM4LLK/4140061.png')" />
<img src="https://i.postimg.cc/g0yv2TTH/6833605.png" onclick="selectAvatar('https://i.postimg.cc/g0yv2TTH/6833605.png')" />
<img src="https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg" onclick="selectAvatar('https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg')" />
<img src="https://i.postimg.cc/rwKwFnfR/4139967.png" onclick="selectAvatar('https://i.postimg.cc/rwKwFnfR/4139967.png')" />
<img src="https://i.postimg.cc/dQNG3d4p/6997484.png" onclick="selectAvatar('https://i.postimg.cc/dQNG3d4p/6997484.png')" />
</div>
</div>

<div class="profile-details">
<h4>Edit Details</h4>
<input type="text" id="nameInput" placeholder="Enter Name" required required pattern="[a-zA-Z ]+" oninvalid="this.setCustomValidity('Numbers and Symbols are not allowed')" oninput="this.setCustomValidity('')">
<input type="email" id="emailInput" placeholder="Enter Email" required>
<input type="tel" id="phoneInput" placeholder="Enter Phone" required>
<input type="text" id="bioInput" placeholder="Add Bio" maxlength="150" required>
</div>
<button class="save-button" onclick="saveProfile()">Save Profile</button>
</div>

<script>

let selectedAvatar = "";

function selectAvatar(avatarSrc) {

const avatars = document.querySelectorAll('.avatars img');
avatars.forEach(img => {
img.classList.remove('selected');
});
const selectedImg = Array.from(avatars).find(img => img.src === avatarSrc);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = avatarSrc;
}

}

function saveProfile() {

const newName = document.getElementById("nameInput").value.trim();
const newEmail = document.getElementById("emailInput").value.trim();
const newPhone = document.getElementById("phoneInput").value.trim();
const newBio = document.getElementById("bioInput").value.trim();

// Check if all fields are valid before proceeding
if (!nameInput.checkValidity() || !emailInput.checkValidity() || !phoneInput.checkValidity()) {
nameInput.reportValidity();
emailInput.reportValidity();
phoneInput.reportValidity();
bioInput.reportValidity();
return; // Stop function execution if invalid
}

if (newEmail && !validateEmail(newEmail)) {
alert("Invalid email address");
return;
}

if (selectedAvatar) {
localStorage.setItem("selectedAvatar", selectedAvatar);
}
if (newName) {
localStorage.setItem("profileName", newName);
}
if (newEmail) {
localStorage.setItem("profileEmail", newEmail);
}
if (newPhone) {
localStorage.setItem("profilePhone", newPhone);
}
if (newBio) {
localStorage.setItem("profileBio", newBio);
}

// Redirect to the profile page
window.location.href = "testp.html"; // Change made here
}

function validateEmail(email) {
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return re.test(email);
}

document.addEventListener("DOMContentLoaded", () => {
const savedAvatar = localStorage.getItem("selectedAvatar");
if (savedAvatar) {
const selectedImg = Array.from(document.querySelectorAll('.avatars img')).find(img => img.src === savedAvatar);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = savedAvatar;
}
}

const savedName = localStorage.getItem("profileName");
const savedEmail = localStorage.getItem("profileEmail");
const savedPhone = localStorage.getItem("profilePhone");
const savedBio = localStorage.getItem("profileBio");

if (savedName) {
document.getElementById("nameInput").value = savedName;
}
if (savedEmail) {
document.getElementById("emailInput").value = savedEmail;
}
if (savedPhone) {
document.getElementById("phoneInput").value = savedPhone;
}
if (savedBio) {
document.getElementById("bioInput").value = savedBio;
}
});

</script>

</body>

</html>



Loading