Celeste Set (Baby Pink) (2024)

This store requires javascript to be enabled for some features to work correctly.

Reviews Questions

Celeste Set (Baby Pink) (5)

0% would recommend this product

Add a review

×

Celeste Set (Baby Pink) (6)

Ask a question
`; } }) .catch(error => console.error('Error fetching data:', error));}// Get the product ID from the hidden inputvar productId = document.getElementById('product_id').value;// Call the function with the correct product IDfetchDataAndRenderReviews(productId); // customers reviews // Assuming productId is defined somewhere in your codevar productId = document.getElementById('product_id').value;var selectedStarRating = null;var selectedSorting = null;var currentPage = 1;var isLoading = false; // Track if reviews are currently being loaded// Assign a variable to the "Show More" buttonvar loadMoreButton = document.querySelector('.loadMoreReviews');// Add a check for the existence of the button before adding the event listenerif (loadMoreButton) { loadMoreButton.addEventListener('click', function () { // Check if reviews are currently being loaded if (!isLoading) { // Call a function to load more reviews or perform additional actions loadMoreReviews(); } });}function loadMoreReviews() { // Increment the current page number currentPage++; // Fetch and render reviews for the next page fetchReviews(productId, currentPage);} // Select the "Show Less" buttonvar showLessButton = document.querySelector('.showLessReviews');document.querySelector('.showLessReviews').addEventListener('click', function () { // Decrement the current page number currentPage--; // Fetch and render reviews for the previous page fetchReviews(productId, currentPage);}); var loaderContainer = document.querySelector('.rj-loader-container');function showLoader() { loaderContainer.style.display = 'flex';}function hideLoader() { loaderContainer.style.display = 'none';} function openImagePopup(productID, imageSource) { var popupContainer = document.getElementById('imagePopup'); var rjpopupImage = document.getElementById('rjpopupImage'); rjpopupImage.src = imageSource; popupContainer.style.display = 'block'; // You can use the productID as needed } function closeImagePopup() { var popupContainer = document.getElementById('imagePopup'); popupContainer.style.display = 'none'; } function fetchReviews(product_id, page) { showLoader(); isLoading = true; // Set loading state to true var domain = document.getElementById('RJShopDomain').value;var sortDirection = selectedSorting === 'newest' ? 'desc' : 'asc'; fetch(`https://app.reviewsjunctionapps.com/api/json-reviews?domain=${domain}&product_id=${product_id}&direction=media&&page=${page}`) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { var reviews = data.reviews.data; if (reviews.length > 0) { // Filter and sort reviews filterAndSortReviews(reviews); // Render reviews renderReviews(reviews); } if (data.reviews.next_page_url === null) { // Disable the "Show More" button when there are no more reviews loadMoreButton.disabled = true; loadMoreButton.style.cursor = 'not-allowed'; loadMoreButton.querySelector('svg').style.fill = 'gray'; } else { // Enable the "Show More" button loadMoreButton.style.cursor = 'pointer'; loadMoreButton.querySelector('svg').style.fill = 'black'; loadMoreButton.disabled = false; } // Check if there are previous pages if (data.reviews.prev_page_url === null || currentPage === 1) { // Disable the "Show Less" button when on the first page showLessButton.disabled = true; showLessButton.style.cursor = 'not-allowed'; showLessButton.querySelector('svg').style.fill = 'gray'; } else { // Enable the "Show Less" button showLessButton.disabled = false; showLessButton.style.cursor = 'pointer'; showLessButton.querySelector('svg').style.fill = 'black'; } var prevNextButtons = document.querySelector('.prevnextbuttons'); prevNextButtons.style.display = data.reviews.total > 10 ? 'flex' : 'none';if(data.reviews.total == 0){ var noreviews = document.querySelector('.no-reviews'); noreviews.style.display='block'; noreviews.style.textAlign='center';} return Promise.resolve(); // Resolve the promise to keep the chain going }) .catch(error => console.error('Error fetching data:', error)) .finally(() => { hideLoader(); isLoading = false; // Reset loading state });}function filterAndSortReviews(reviews) { // Filter reviews based on the selected star rating if (selectedStarRating) { reviews = reviews.filter(review => review.stars == selectedStarRating); } if (selectedSorting ==='media') { reviews = reviews.sort(review => review.media_files.length > 0); } // Sort reviews based on the selected sorting option if (selectedSorting === 'highest') { reviews.sort((a, b) => b.stars - a.stars); } else if (selectedSorting === 'lowest') { reviews.sort((a, b) => a.stars - b.stars); }else if (selectedSorting === 'newest') { reviews.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); } else if (selectedSorting === 'oldest') { reviews.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)); }}function renderReviews(reviews) { var reviewsContainer = document.querySelector('.reviews-list-inner'); reviewsContainer.innerHTML = ''; // Clear existing reviews reviews.forEach(review => { var reviewDiv = document.createElement('div'); reviewDiv.className = 'reviews-list-item'; reviewDiv.setAttribute('data-index', reviews.indexOf(review)); // console.log('reviw data', review) // Render name and rating reviewDiv.innerHTML += `

${review.first_name ? review.first_name.charAt(0) : 'N/A'}

${review.first_name ? review.first_name: 'N/A'} ${review.last_name}

${Array.from({ length: 5 }, (_, index) => getStarSVG(index < review.stars)).join('')}

${formatDate(review.created_at)}

${review.title}

${review.description}

${review.store_reply ? `

Store Reply: ${review.store_reply}

` : ''}${review.media_files.length > 0 ? review.media_files.map((media, index) => ` Celeste Set (Baby Pink) (7)`).join('') : ''}

`; reviewsContainer.appendChild(reviewDiv); }); loadMoreButton.disabled = false;}function getStarSVG(isFilled) { const fillColor = isFilled ? "#000000" : "transparent"; const strokeColor = "#000000"; return ` `;}function formatDate(dateString) { var options = { year: 'numeric', month: 'numeric', day: 'numeric' }; return new Date(dateString).toLocaleDateString(undefined, options);}function filterReviewsByStarRating() { showLoader(); var starRatingSelect = document.getElementById('starRatingSelect'); selectedStarRating = starRatingSelect.value; // Re-fetch and render reviews based on the selected star rating fetchReviews(productId, currentPage); // Pass the currentPage to maintain the correct page}function sortAndRenderReviews() { showLoader(); var sortbySelect = document.getElementById('sortbySelecting'); selectedSorting = sortbySelect.value; // Re-fetch and render reviews based on the selected sorting option fetchReviews(productId, currentPage, sortbySelect); // Pass the currentPage to maintain the correct page}var sortbySelecting = document.getElementById('sortbySelecting'); selectedSorting = sortbySelecting.value;// Initial loadfetchReviews(productId, currentPage, selectedSorting);

${question.first_name} ${question.last_name}

${questionDate}

${question.question_content}

${ question.answer_content ? `

${question.answer_content}

` : '' }

`; questionListInner.appendChild(questionListItem); }); } function updateButtonsState(questionsData) { const remainingQuestions = questionsData.total - currentPage * 10; loadMoreButton.disabled = remainingQuestions <= 0; showLessButton.disabled = currentPage === 1; // Disable/enable buttons with gray color and cursor not allowed loadMoreButton.style.cursor = loadMoreButton.disabled ? 'not-allowed' : 'pointer'; loadMoreButton.querySelector('svg').style.fill = loadMoreButton.disabled ? 'gray' : 'black'; showLessButton.style.cursor = showLessButton.disabled ? 'not-allowed' : 'pointer'; showLessButton.querySelector('svg').style.fill = showLessButton.disabled ? 'gray' : 'black'; } function showLoader() { // Implement your loader display logic here } function hideLoader() { // Implement your loader hide logic here } });

${review.first_name ? review.first_name: 'N/A'} ${review.last_name}

${Array.from({ length: 5 }, (_, index) => getStarSVG(index < review.stars)).join('')}

${formatDate(review.created_at)}

Celeste Set (Baby Pink) (2024)
Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 5819

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.