function sendRatingData()

in wiki-interface/ui/js/forms.js [528:570]


function sendRatingData() {
    let ratingValue = document.getElementById('rating').value;
    let ratingTransactionId = document.getElementById('ratingTransactionId').value;
    let ratingPagePath = document.getElementById('ratingPagePath').value;
    let ratingDocumentId = document.getElementById('ratingDocumentId').value;
    let ratingPageContent = document.getElementById('ratingPageContent').value;

    document.getElementById("main-content").style.display = "none";
    document.getElementById("rating-content").style.display = "none";
    document.getElementById("loading").style.display = "block";

    const data = {
        documentId: ratingDocumentId,
        documentContent: ratingPageContent,
        documentPath: ratingPagePath,
        transactionId: ratingTransactionId,
        ratingValue: ratingValue
    };

    fetch('/api/v1/rating', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.json();
        })
        .then(responseData => {
            // Construct the redirect URL
            const redirectUrl = `/ui/`;

            window.location.href = redirectUrl;
        })
        .catch(error => {
            console.error('There was a problem with the fetch operation:', error);
            // Handle errors here (e.g., display an error message to the user)
        });
}