<?php
if (!defined('ABSPATH')) {
  exit;
}
$templates = new Chama_Template_Loader;


        $post_id = get_the_ID();
        $faqs = get_post_meta($post_id, 'campaign_faqs', true);
        $updates = get_post_meta($post_id, 'campaign_updates', true);
        $content = get_the_content();   
        ?>
						    <?php if($content || $faqs || $updates): ?>
                            <div class="chama-campaign-tabs-wrapper">
<div class="chama-card chama-campaign-tabs-card ">
<div class="chama-card-body">

    <div id="chama-panels">
      <div class="chama-panel-links">
        <?php if($content): ?>
        <button data-id="chama-campaign-story" data-default>Story</button>
        <?php endif; ?>
        <?php if($faqs): ?>
        <button data-id="chama-campaign-faqs">FAQ</button>
        <?php endif; ?>
        <?php if($updates): ?>
        <button data-id="chama-campaign-updates">Updates</button>
        <?php endif; ?>
      </div>
      
      <div class="chama-panel-content">
      <?php if($content): ?>
        <section id="chama-campaign-story">
          <h4>Story</h4>
          <?php echo wp_kses(wpautop($content), chama_allowed_tags()); ?>
        </section>
        <?php endif; ?>
        <?php if($faqs): ?>
        <section id="chama-campaign-faqs">
          <h4>FAQ</h4>
          <div class="chama-accordion">
          <?php
          foreach ($faqs as $faq):
           
          ?>
          <div class="chama-accordion-item">
      <div class="chama-accordion-item-header">
        <span class="chama-accordion-item-header-title"><?php echo esc_html($faq['campaign_faq_question']); ?></span>
        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down chama-accordion-item-header-icon">
          <path d="m6 9 6 6 6-6" />
        </svg>
      </div>
      <div class="chama-accordion-item-description-wrapper">
        <div class="chama-accordion-item-description">
          <hr>
          <div class="chama-accordion-content">
          <?php echo esc_html($faq['campaign_faq_answer']); ?>
          </div>
         
        </div>
      </div>
    </div>
          <?php
          endforeach;
          ?>
          </div>
    
        </section>
        <?php endif; ?>
        <?php if($updates): ?>
        <section id="chama-campaign-updates">
        <h4>Updates</h4>
        <?php
        $updates = array_reverse($updates);
          foreach ($updates as $update):
            $formatted_date = new DateTime($update['campaign_update_date']);
            $dateWithoutTime = $formatted_date->format('M j, Y');
          ?>
          <div class="chama-campaign-update">
          <strong class="chama-update-date"><?php echo esc_html( $dateWithoutTime); ?></strong><br/>
          <?php echo esc_html( $update['campaign_update_content']); ?>

          </div>
          
           <?php
          endforeach;
          ?>
        </section>
        <?php endif; ?>
      </div>
    </div>

</div>
</div>
</div>
<?php endif; ?>



