$(document).ready(function () {
    var tooltipTrigger = document.getElementById('tooltipTrigger');
    var tooltip = new bootstrap.Tooltip(tooltipTrigger, {
        title: "Detail",
        placement: "left"
    });

    $("#showModal").on("show.bs.modal", function (event) {
        const button = $(event.relatedTarget);
        const data = {
            fullName: button.data("full-name"),
            barbershop: button.data("barbershop"),
            pob: button.data("pob"),
            dob: button.data("dob"),
            address: button.data("address"),
            gender: button.data("gender"),
            sop: button.data("sop"),
            avatar: button.data("avatar"),
            ktp: button.data("ktp"),
        };

        var genderBadge = '';
        if (data.gender === 1) {
            genderBadge = '<span class="badge bg-success">Laki-laki</span>';
        } else if (data.gender === 2) {
            genderBadge = '<span class="badge bg-info">Perempuan</span>';
        } else {
            genderBadge = '<span class="badge bg-secondary">Tidak Diketahui</span>';
        }

        $('#user-avatar').attr('src', data.avatar);
        $('#user-name').text(data.fullName);
        $('#user-barbershop').text(data.barbershop);
        $('#user-pob').text(data.pob);
        $('#user-dob').text(data.dob);
        $('#user-address').text(data.address);
        $('#user-gender').html(genderBadge);
        $('#user-sop').text(data.sop);
        $('#user-ktp').attr('src', data.ktp);
    });
});
