Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Noxtrah/SE-4910
Browse files Browse the repository at this point in the history
  • Loading branch information
Noxtrah committed May 25, 2024
2 parents e66c0c8 + c8dcbf5 commit 4518b21
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 26 deletions.
2 changes: 1 addition & 1 deletion scripts/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ const displayDashboard = async (recipes) => {
// Function to fetch data from the API
async function fetchData(key = 0) {
const JWTAccessToken = sessionStorage.getItem('accessToken');
let apiUrl = 'https://recipiebeckend.azurewebsites.net/recipes/home';
// let apiUrl = 'https://recipiebeckend.azurewebsites.net/recipes/home';
if (key !== undefined) {
apiUrl += `?key=${key}`;
}
Expand Down
1 change: 1 addition & 0 deletions scripts/recipeDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RecipeDetail {
})
.then(data => {
this.displayRecipeDetails(data);
console.log(data)
const mealNames = this.getMealNames(data.recipe.meal);
setTimeout(() => {
this.getRecommendations(data.recipe.ingredients, data.recipe.title, mealNames);
Expand Down
35 changes: 31 additions & 4 deletions scripts/userEditProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ saveButton.addEventListener("click", async function (event) {

const finalAllergiesString = selectedFoods.map(food => food.trim()).join(',');

const newPassword = document.getElementById('new-password').value;
const confirmPassword = document.getElementById('confirm-password').value;


const photoUpload = document.getElementById('photo-upload');
const photoFile = photoUpload.files[0];

const formData = new FormData();
formData.append('password', newPassword);

formData.append('bio', bio);
formData.append('allergicFoods', finalAllergiesString);
if (photoFile) {
formData.append('profilePhoto', photoFile);

}

console.log('Selected Allergies:', selectedFoods);
Expand All @@ -89,6 +88,7 @@ saveButton.addEventListener("click", async function (event) {
await saveProfile(formData);
} catch (error) {
console.error('Error saving profile:', error);

}
});

Expand Down Expand Up @@ -118,3 +118,30 @@ async function saveProfile(formData) {
throw error;
}
}

function setupBackButton() {
const backButton = document.getElementById('back-arrow-button');

backButton.addEventListener('click', () => {
window.history.back();
});
}
// Call the function to generate user recipe boxes when the page loads
window.onload = function () {
setupBackButton(); // Call setupBackButton after generateUserRecipeBoxes
};

const saveProfileEditButton = document.getElementById('save-button');
// Pop-up elementini seçiyoruz
const savedPopup = document.getElementById('saved-popup');

// Butona tıklama olayı ekliyoruz
saveButton.addEventListener('click', function() {
// Pop-up'ı gösteriyoruz
savedPopup.style.display = 'block';

// 2 saniye sonra pop-up'ı gizliyoruz
setTimeout(function() {
savedPopup.style.display = 'none';
}, 2000);
});
26 changes: 10 additions & 16 deletions scripts/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ async function CreateUserInfoPage() {
// Kullanıcı bilgilerini yerleştir
document.getElementById('userName').textContent = userInfo.name + ' ' + userInfo.lastName;
document.getElementById('userEmail').textContent = userInfo.email;
document.getElementById('userBio').textContent = userInfo.bio || "Type about yourself"; // Bio alanı boşsa "Type about yourself" yazısı
const userPhoto = userInfo.userPhoto;
const profilePhotoContainer = document.getElementById('profilePhotoContainer');

if (userPhoto) {
const imageElement = document.createElement('img');
imageElement.src = userPhoto;
imageElement.alt = "User Photo";
imageElement.id = "userPhoto";
profilePhotoContainer.appendChild(imageElement);
} else {
const iconElement = document.createElement('ion-icon');
iconElement.setAttribute('name', 'person-circle-outline');
iconElement.style.fontSize = '48px'; // Adjust size as needed
profilePhotoContainer.appendChild(iconElement);
if(userInfo.userPhoto)
{
document.getElementById('userPhoto').src = userInfo.userPhoto;
}
else{
document.getElementById('userPhoto').src = "https://static.vecteezy.com/system/resources/thumbnails/005/129/844/small_2x/profile-user-icon-isolated-on-white-background-eps10-free-vector.jpg"
}

// document.getElementById('userPhoto').src = userInfo.userPhoto;
document.getElementById('userBio').textContent = userInfo.bio || "Type about yourself"; // Bio alanı boşsa "Type about yourself" yazısı
// Kullanıcının yayınladığı tarifleri listele
const userPublishedRecipesContainer = document.getElementById('userPublishedRecipes');
userInfo.userPublishedRecipes.forEach(recipe => {
Expand Down Expand Up @@ -118,8 +111,9 @@ async function getUserInfo() {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();

console.log(data)
return data;

} catch (error) {
console.error('Error fetching or displaying data:', error);
return {};
Expand Down
40 changes: 39 additions & 1 deletion styles/userEditProfile.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ body {

.section {
margin-bottom: 20px;
background-color: var(--light_purple);
background-color: rgb(198, 189, 202);
padding: 15px;
border-radius: 10px;
}
Expand Down Expand Up @@ -148,4 +148,42 @@ select {

#save-button:hover {
background-color: var(--dark_purple);
}

#back-arrow-button {
background: transparent;
border: none;
padding: 0;
position: relative;
margin: 35px;
}

.back-arrow {
font-size: 5em;
color: var(--purple);
position: absolute;
top: 50%;
left: 50%;
transform: translate(0%, -50%);
transition: color 0.3s ease-in-out;
}

#back-arrow-button:hover .back-arrow {
color: var(--dark_purple);
/* Change the color on hover */
cursor: pointer;
/* Change the cursor on hover */
}

#saved-popup {
display: none; /* Başlangıçta gizli */
position: fixed; /* Ekranın belirli bir konumunda kalacak */
top: 50%; /* Ortada yerleştirme */
left: 50%; /* Ortada yerleştirme */
transform: translate(-50%, -50%); /* Ortada yerleştirme */
padding: 20px; /* İç boşluk */
background-color: rgb(185, 174, 190); /* Arkaplan rengi */
border: 2px solid #5a4c79; /* Sınır */
box-shadow: 0 0 10px rgba(140, 53, 177, 0.5); /* Gölge efekti */
z-index: 1000; /* Diğer öğelerin üstünde olacak */
}
2 changes: 2 additions & 0 deletions styles/userProfile.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ body {
align-items: center;
justify-content: center;
color: white;
height: 100px;

}

.header-title {
Expand Down
2 changes: 2 additions & 0 deletions styles/userViewProfile.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ body {
align-items: center;
justify-content: center;
color: white;
height: 100px;

}

.header-title {
Expand Down
4 changes: 2 additions & 2 deletions templates/meal_planner.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ <h3>Dinner:</h3>
border: none;
padding: 0;
position: relative;
margin-right: 1400px;
margin-right: 1600px;
}

.back-arrow {
Expand Down Expand Up @@ -304,7 +304,7 @@ <h3>Dinner:</h3>
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
cursor: move; /* Make it draggable */
/* cursor: move; */
}

.day h3 {
Expand Down
17 changes: 15 additions & 2 deletions templates/userEditProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<link rel="stylesheet" href="../styles/userEditProfile.css">
<title>Document</title>
</head>
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
<div class="header">
<header>
<div id="header-container">
<button id="back-arrow-button">
<ion-icon class="back-arrow" name="chevron-back-circle-outline"></ion-icon>
</button>
</div>
</div>
</header>

<body>

<form id="profile-form" enctype="multipart/form-data">
Expand All @@ -32,12 +44,13 @@
<form>
<div class="form-group">
<div id="checkboxAllergy">
<label for="checkbox"></label>
<input type="checkbox" id="checkbox" name="checkbox">

</div>
</div>
</form>
<button type="submit" id="save-button">Save</button>
<div id="saved-popup">Profile Saved</div>

</div>
</form>

Expand Down
2 changes: 2 additions & 0 deletions templates/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
</head>
<body>
<div id="header-container">
<div>
<button id="back-arrow-button">
<ion-icon class="back-arrow" name="chevron-back-circle-outline"></ion-icon>
</button>
</div>
<h1 class="header-title" style="color: #c4bbf0;">MY PROFILE</h1>
</div>
<div class="card-container">
Expand Down

0 comments on commit 4518b21

Please sign in to comment.