// Define the callback function
function handleSubmit(data) {
    console.log('Submitting data:', data);
    // Here you can perform your API request, e.g., using fetch or XMLHttpRequest
    // Example:
    // fetch('/submit-feedback', {
    //     method: 'POST',
    //     headers: { 'Content-Type': 'application/json' },
    //     body: JSON.stringify(data)
    // }).then(response => response.json())
    //   .then(result => console.log('Feedback submitted:', result))
    //   .catch(error => console.error('Error submitting feedback:', error));
}

const texts = {
    "ratingTitle": "Please rate us:",
    "feedbackTitle": "Please leave your feedback:",
    "reasonTitle": "Why did you visit us today?",
    "nextButtonText": "Next",
    "submitButtonText": "Submit",
    "closeButtonText": "Close",
    "thankYouMessage": "Thank you for your feedback!",
    "reasons": {
        "text": "Select a reason",
        "options": [
            {
                "value": 0,
                "text": "Customer Support",
            },
            {
                "value": 1,
                "text": "Product Inquiry",
            },
            {
                "value": 2,
                "text": "Technical Issue",
            },
            {
                "value": 3,
                "text": "General Question",
            },
            {
                "value": 4,
                "text": "Other",
            }
        ]
    }
};

const settings = { numberStars: 5, minCharsAllowed: 35, showOnSamePage: true };

new FeedbackDialog(texts, handleSubmit, settings);