<?php
    $user = auth()->user();
?>

<div class="dashboard-top-nav">
    <div class="row align-items-center">
        <div class="col-3 d-lg-block d-none">
            <h5 class="page-title"><?php echo e(__($pageTitle)); ?></h5>
        </div>
        <div class="col-3 d-lg-none d-block">
            <button class="sidebar-open-btn"><i class="las la-bars"></i></button>
        </div>
        <div class="col-9">
            <div class="d-flex flex-wrap justify-content-end align-items-center">
                <ul class="header-top-menu">
                    <li class="m-0">
                        <a href="javascript:void(0)" class="btn btn--base btn-sm" id="refreshBalance">
                            <i class="las la-sync-alt"></i>
                            <span id="userBalance"><?php echo app('translator')->get('Loading...'); ?></span>
                        </a>
                    </li>
                </ul>
                <div class="header-user">
                    <a href="<?php echo e(route('login.login.logout')); ?>" class="name btn--dark btn-sm">
                        <i class="las la-sign-out-alt"></i>
                        <?php echo app('translator')->get('Logout'); ?>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        function loadBalance() {
            fetch("<?php echo e(route('index.index.balance')); ?>")
                .then(response => response.json())
                .then(data => {
                    if (data.status === "success") {
                        document.getElementById("userBalance").innerHTML = data.balance + " <?php echo e(strtoupper(auth()->user()->currency)); ?>";
                    } else {
                        document.getElementById("userBalance").innerHTML = "Error";
                    }
                })
                .catch(() => {
                    document.getElementById("userBalance").innerHTML = "Error";
                });
        }

        document.getElementById("refreshBalance").addEventListener("click", function() {
            loadBalance();
        });

        // Load balance on page load
        loadBalance();
    });
</script>
<?php /**PATH /home/paysafebd23/ovimanager.store/resources/views/partials/auth_topbar.blade.php ENDPATH**/ ?>