<?php

namespace PloverCRM\Modules\Integrations\Helpers;

use PloverCRM\Common\BaseLogViewer;

/**
 * Ads Integration Log Viewer
 * 
 * Handles viewing and downloading ads integration logs
 */
class AdsLogViewer extends BaseLogViewer
{
  /**
   * Constructor
   */
  public function __construct()
  {
    parent::__construct('data-sources/ads', 'ads');
  }

  /**
   * Render log viewer for ads integrations
   */
  public static function render(): void
  {
    $viewer = new self();
    $logs = $viewer->getRecentLogs();

    echo '<div style="padding: 20px; background: #fff; border: 1px solid #ddd; border-radius: 4px; margin-top: 30px;">';
    echo '<h3 style="margin-top: 0;">Ads Integration Logs</h3>';
    echo '<p style="color: #666;">View logs for ad lead integrations. Logs are grouped by task and show the complete flow from webhook receipt to contact creation.</p>';

    $viewer->renderLogEntries($logs);

    if (!empty($logs)) {
      echo '<div style="margin-top: 15px;">';
      echo \PloverCRM\Common\BaseLogViewer::getDownloadButton('data-sources/ads');
      echo '</div>';
    }

    echo '</div>';
  }
}
