package com.realnet.OpenAi.Renders;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class TestimonialRenderer {

    @SuppressWarnings("unchecked")
    public static String render(Map<String, Object> json) {
        List<Map<String, String>> testimonials = (List<Map<String, String>>) json.get("cards");

        StringBuilder sb = new StringBuilder();
        sb.append("<div class='testimonial-section'>");
        sb.append("<h2 class='testimonial-heading'>Customer Testimonials</h2>");
        sb.append("<p class='testimonial-subtitle'>What our clients are saying...</p>");
        sb.append("<div class='testimonial-grid'>");

        if (testimonials != null) {
            for (Map<String, String> t : testimonials) {
                sb.append("<div class='testimonial-card'>")
                        .append("<div class='profile'></div>")
                        .append("<blockquote>").append(t.getOrDefault("quote", "")).append("</blockquote>")
                        .append("<p><strong>").append(t.getOrDefault("name", "")).append("</strong><br>")
                        .append(t.getOrDefault("role", "")).append("</p>")
                        .append("</div>");
            }
        }

        sb.append("</div></div>");
        return sb.toString();
    }
}
