Conversation
guilherme-d-souza
left a comment
There was a problem hiding this comment.
Please, test your application and see with is running, have no errors and it's able to do every requested requirement.
src/index.html
Outdated
| <p class="modal__title">Golden Gate Bridge</p> | ||
| </div> | ||
| </div> | ||
| <div class="modal" id="delete-modal"> |
There was a problem hiding this comment.
In line 139, your webpack is giving an error. You shouldn't use the require for https images. You can remove this
src/pages/index.js
Outdated
|
|
||
| const api = new Api({ | ||
| baseUrl: "https://around-api.en.tripleten-services.com/v1", | ||
| token: "f18dafb7-fd93-4a29-8bad-28626515cfd2", // <-- keep your token here |
There was a problem hiding this comment.
This token is not working to call the API for me. Did you added a fake to be edited?
src/pages/index.js
Outdated
| import { enableValidation, settings } from "../scripts/validation.js"; | ||
| import Api from "../utils/Api.js"; | ||
|
|
||
| const initialCards = [ |
There was a problem hiding this comment.
You don't need the initialCards anymore. You can delete that.
src/pages/index.js
Outdated
| deleteForm.addEventListener("submit", handleDeleteSubmit); | ||
| } | ||
|
|
||
| const cardDeleteBtnEL = cardElement.querySelector(".card__delete-btn"); |
There was a problem hiding this comment.
cardElement is not defined. Do you need this code?
src/pages/index.js
Outdated
| cardDeleteBtnEl.addEventListener("click", () => { | ||
| if (!data._id) { | ||
| cardElement.remove(); | ||
| return; | ||
| } | ||
|
|
||
| api | ||
| .deleteCard(data._id) | ||
| .then(() => { | ||
| cardElement.remove(); | ||
| }) | ||
| .catch((err) => { | ||
| console.error("Failed to delete card:", err); | ||
| alert("Could not delete the card. Please try again."); | ||
| cardDeleteBtnEl.disabled = false; | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Do you need this code? Looks like it's duplicated.
src/pages/index.js
Outdated
| const deleteSubmitBtn = deleteModal | ||
| ? deleteModal.querySelector(".modal__submit-btn") | ||
| : null; | ||
| const deleteCloseBtn = deleteModal |
There was a problem hiding this comment.
All your global variable declarations (line 255 until line 284) should be on the beginning of the file. This is making many script errors occur.
| function handleProfileFormSubmit(evt) { | ||
| evt.preventDefault(); | ||
|
|
||
| const name = editProfileNameInput.value.trim(); | ||
| const about = editProfileDescriptionInput.value.trim(); | ||
| const submitBtn = editProfileFormEl.querySelector(".modal__submit-btn"); | ||
|
|
||
| setButtonLoading(submitBtn, true, "Saving...", "Save"); | ||
|
|
||
| api | ||
| .editUserInfo({ name, about }) | ||
| .then((user) => { | ||
| profileNameEl.textContent = user.name; | ||
| profileDescriptionEl.textContent = user.about; | ||
| closeModal(editProfileModal); | ||
| }) | ||
| .catch((err) => { | ||
| console.error("Failed to update profile:", err); | ||
| alert("Could not save profile changes. Please try again."); | ||
| }) | ||
| .finally(() => setButtonLoading(submitBtn, false, "Saving...", "Save")); | ||
| } |
There was a problem hiding this comment.
This function is duplicated (have another function with the same name). Which one you should keep?
| function handleDeleteCard(cardElement, data) { | ||
| selectedCard = cardElement; | ||
| selectedCardId = data?._id || null; | ||
| openModal(deleteModal); | ||
| } |
There was a problem hiding this comment.
This function is duplicated (have another function with the same name). Which one you should keep?
| function handleDeleteSubmit(evt) { | ||
| evt.preventDefault(); | ||
| if (!selectedCard) { | ||
| closeModal(deleteModal); | ||
| return; | ||
| } | ||
| closeModal(newPostModal); | ||
|
|
||
| const submitBtn = deleteSubmitBtn; | ||
| setButtonLoading(submitBtn, true, "Deleting...", "Yes, delete"); | ||
|
|
||
| const promise = selectedCardId | ||
| ? api.deleteCard(selectedCardId) | ||
| : Promise.resolve(); | ||
|
|
||
| promise | ||
| .then(() => { | ||
| selectedCard.remove(); | ||
| selectedCard = null; | ||
| selectedCardId = null; | ||
| closeModal(deleteModal); | ||
| }) | ||
| .catch((err) => { | ||
| console.error("Failed to delete card:", err); | ||
| alert("Could not delete the card. Please try again."); | ||
| }) | ||
| .finally(() => | ||
| setButtonLoading(submitBtn, false, "Deleting...", "Yes, delete") | ||
| ); |
There was a problem hiding this comment.
This function is duplicated (have another function with the same name). Which one you should keep?
src/pages/index.js
Outdated
| .finally(() => setButtonLoading(submitBtn, false, "Saving...", "Save")); | ||
| } | ||
|
|
||
| const cardElement = getCardElement(inputValues); |
There was a problem hiding this comment.
inputValues variable is not defined. Where should this data come from?
guilherme-d-souza
left a comment
There was a problem hiding this comment.
Please, test your application before submit
src/pages/index.js
Outdated
| ]; | ||
| const api = new Api({ | ||
| baseUrl: "https://around-api.en.tripleten-services.com/v1", | ||
| token: "d41c5de4-a60c-4cba-8b57-bb0d7fcd07f2", |
There was a problem hiding this comment.
This is breaking your API even that the token is valid. Make sure to check the parameters that you are expecting on the Api class. Check the Instantiate the class topic on the project description to get more details.
src/index.html
Outdated
| <button | ||
| class="profile__avatar-edit" | ||
| type="button" | ||
| aria-label="Edit avatar" | ||
| ></button> |
There was a problem hiding this comment.
This button doesn't have the proper style. Make sure to check the Figma design, and the behaviour for this button.
| <img | ||
| src="<%=require('https://practicum-content.s3.us-west-1.amazonaws.com/software-engineer/spots/7-photo-by-griffin-wooldridge-from-pexels.jpg')%>" | ||
| alt="" | ||
| class="modal__image" | ||
| /> |
There was a problem hiding this comment.
You should not remove the whole img tag, only remove the require webpack syntax on the src property
| newPostImageInput.value = ""; | ||
| newPostFormEl.reset(); | ||
| const inputs = Array.from(newPostFormEl.querySelectorAll(".modal__input")); | ||
| resetValidation(newPostFormEl, inputs, settings); |
There was a problem hiding this comment.
resetValidation function is not defined.
There was a problem hiding this comment.
Still not solved. Remember to import this correctly
src/utils/Api.js
Outdated
| return fetch(`${this._baseUrl}/users/me`, { | ||
| method: "GET", | ||
| headers: { | ||
| authorization: this._token, |
There was a problem hiding this comment.
The _token is not defined/set on the class constructor.
src/utils/Api.js
Outdated
| return fetch(`${this._baseUrl}/cards`, { | ||
| method: "GET", | ||
| headers: { | ||
| authorization: this._token, |
There was a problem hiding this comment.
The _token is not defined/set on the class constructor.
guilherme-d-souza
left a comment
There was a problem hiding this comment.
You still didn't fix the API constructor or the API calls. Make sure to ask if you didn't understand or need help with that
src/utils/Api.js
Outdated
| return Promise.reject(`Error: ${res.status}`); | ||
| } | ||
| getUserInfo() { | ||
| return fetch(`${this._baseUrl}/users`, { |
There was a problem hiding this comment.
This API is returning all the users, the endpoint for this should be /users/me
| newPostImageInput.value = ""; | ||
| newPostFormEl.reset(); | ||
| const inputs = Array.from(newPostFormEl.querySelectorAll(".modal__input")); | ||
| resetValidation(newPostFormEl, inputs, settings); |
There was a problem hiding this comment.
Still not solved. Remember to import this correctly
| object-fit: cover; | ||
| } | ||
|
|
||
| .profile__avatar-edit { |
There was a problem hiding this comment.
This style doesn't match the Figma style. Make sure to follow the Figma values
src/pages/index.js
Outdated
| const previewNameEl = previewModal.querySelector(".modal__title"); | ||
|
|
||
| const deleteModal = document.querySelector("#delete-modal"); | ||
| const deleteForm = deleteModal?.querySelector(".modal__form"); |
There was a problem hiding this comment.
This selector is not correct. Make sure to check the card deletion after make the other validations
src/index.html
Outdated
| <button | ||
| class="profile__avatar-edit" | ||
| type="button" | ||
| aria-label="Edit avatar" | ||
| ></button> |
src/pages/index.js
Outdated
| const previewModalCloseBtn = previewModal.querySelector(".modal__close-btn"); | ||
| const previewNameEl = previewModal.querySelector(".modal__title"); | ||
|
|
||
| const deleteModal = document.querySelector(".delete__modal"); |
There was a problem hiding this comment.
This .delete__modal class doesn't exists on the HTML file, only for the ID delete__modal. Make sure to fix this selector.
| opacity: 50%; | ||
| } | ||
|
|
||
| .modal__delete-btn { |
There was a problem hiding this comment.
This button style doesn't match the Figma style. Make sure to follow Figma values for that.
src/index.html
Outdated
| <p class="modal__title">Golden Gate Bridge</p> | ||
| </div> | ||
| </div> | ||
| <div class="delete__modal" id="delete__modal_img"> |
There was a problem hiding this comment.
This is making your modal lose the modal styling, the modal is not opening when we click the delete button. Remember that you have change your selector, not the classes
src/pages/index.js
Outdated
| const previewModalCloseBtn = previewModal.querySelector(".modal__close-btn"); | ||
| const previewNameEl = previewModal.querySelector(".modal__title"); | ||
|
|
||
| const deleteModal = document.querySelector(".delete__modal"); |
No description provided.