<?php
    if (! defined('ABSPATH')) {
        exit;
    }

    $chama_view_nonce          = wp_create_nonce('chama_view_transactions_nonce');
    $account_url               = CHAMA_ACCOUNT_URL;
    $display_donate_page       = get_option('chama_display_donate');
    $display_membership_page   = get_option('chama_display_membership');
    $display_crowdfunding_page = get_option('chama_display_crowdfunding');
    $display_commissions_page  = get_option('chama_display_commissions');
    $has_subscription          = false;
    $user                      = wp_get_current_user();
    $user_id                   = $user->ID;
    if ($user_id) {
        $has_subscription = get_user_meta($user_id, 'chama_stripe_subscription_id', true);
    }

?>

<div id="chama-page-header">
    <i class="far fa-user-circle fa-2x"></i>

        <h3>Account</h3>

</div>
<div class="chama-account-nav-wrapper">
    <ul id="chama-header-nav">
<li class="chama-nav-item                                                   <?php echo $tab == 'profile' ? 'active' : ''; ?>">
    <a href="<?php echo esc_url($account_url); ?>" class="chama-nav-link">Profile</a>
</li>

<?php if ($display_donate_page): ?>
    <li class="chama-nav-item<?php echo $tab == 'donations' ? 'active' : ''; ?>">
        <a href="<?php echo esc_url(add_query_arg(['tab' => 'donations', 'cfn' => $chama_view_nonce], $account_url)); ?>" class="chama-nav-link">Donations</a>
    </li>
<?php endif; ?>

<?php if ($display_membership_page): ?>
    <li class="chama-nav-item<?php echo $tab == 'subscriptions' ? 'active' : ''; ?>">
        <a href="<?php echo esc_url(add_query_arg(['tab' => 'subscriptions', 'cfn' => $chama_view_nonce], $account_url)); ?>" class="chama-nav-link">Subscriptions</a>
    </li>
<?php endif; ?>

<?php if ($display_crowdfunding_page): ?>
    <li class="chama-nav-item<?php echo $tab == 'crowdfunding' ? 'active' : ''; ?>">
        <a href="<?php echo esc_url(add_query_arg(['tab' => 'crowdfunding', 'cfn' => $chama_view_nonce], $account_url)); ?>" class="chama-nav-link">Crowdfunding</a>
    </li>
<?php endif; ?>

<?php if ($display_commissions_page): ?>
    <li class="chama-nav-item<?php echo $tab == 'commissions' ? 'active' : ''; ?>">
        <a href="<?php echo esc_url(add_query_arg(['tab' => 'commissions', 'cfn' => $chama_view_nonce], $account_url)); ?>" class="chama-nav-link">Commissions</a>
    </li>
<?php endif; ?>

<?php if ($has_subscription): ?>
    <li class="chama-nav-item<?php echo $tab == 'billing' ? 'active' : ''; ?>">
        <a href="<?php echo esc_url(add_query_arg(['tab' => 'billing', 'cfn' => $chama_view_nonce], $account_url)); ?>" class="chama-nav-link">Billing</a>
    </li>
<?php endif; ?>
</ul>
</div>


