<?php if(auth()->guard()->check()): ?>
<div class="container wallet-bal">
  <div class="row text-left">
    <div class="col-xs-6">
      <button class="btn btn-clear btn-refresh-wallet">
        <i class="icon-currency-dollar fs-lg i-dollar"></i>
        &nbsp;&nbsp;
        <span class="bal-txt">IDR 0.00</span>
      </button>
    </div>
    <div class="col-xs-6 noSidePadding i-refresh">
      <button class="btn btn-clear btn-refresh-wallet pull-right">
        <i class="icon-refresh-2"></i>
      </button>
    </div>
  </div>
</div>

<script>
$(document).ready(function () {

    function loadBalance() {
        $('.bal-txt').html('<img src="<?php echo e(asset('images/load.gif')); ?>" width="18">');

        $.ajax({
            url: '/get-saldo', // ✅ FIX
            type: 'GET',
            dataType: 'json',
            success: function (res) {
                if (res.data) {
                    $('.bal-txt').text(res.data);
                } else {
                    $('.bal-txt').text('IDR 0.00');
                }
            },
            error: function (xhr) {
                console.error(xhr.responseText);
                $('.bal-txt').text('IDR 0.00');
            }
        });
    }

    // load awal
    loadBalance();

    // refresh manual
    $('.btn-refresh-wallet').on('click', function () {
        loadBalance();
    });

});
</script>
<?php endif; ?><?php /**PATH /home/ybjqutnd/jp.royalkingz.top/resources/views/nav_saldo.blade.php ENDPATH**/ ?>