<?php

declare(strict_types=1);

// Wallet Transactions (Phase 3 — Wallet). The authenticated client's own
// purchase transactions (airtime/data/tv/education/electricity) — the
// actual debits behind the Ledger's entries — developer/v1/wallet/
// transactions.php (ClientWalletService::getTransactions(), a thin
// pass-through to TransactionRepository with client_id forced from the
// session). service_type is validated server-side as a plain string, not
// a closed enum (confirmed in that endpoint's own Validator rules), so
// it's a free-text filter here — same precedent as admin-ui's own
// transactions/index.php. Read-only, no step-up.
//
// Transaction Details pass: columns trimmed from 5 to the 4 the roadmap
// calls out by name (Reference, Amount, Status, Date) — Service dropped
// from this table specifically, not lost: it's one click away on the
// new wallet/transaction-detail.php every row now opens (bindTable's
// rowHref, assets/js/pages/wallet-transactions.js), alongside Network/
// Phone Number/Provider info this table never had room for anyway. All
// filtering/search/sorting/pagination is untouched — only the column
// set and the now-clickable row changed.

require __DIR__ . '/../includes/bootstrap.php';

$pageTitle = 'Wallet Transactions';
$activeNav = 'transactions';
$breadcrumbs = [['label' => 'Wallet', 'href' => uh_url('wallet/')], ['label' => 'Transactions']];
$pageScript = 'wallet-transactions';

ob_start();
?>

<?= uh_subnav(uh_wallet_nav_items(), 'transactions') ?>

<?= uh_card('
  <div class="d-flex flex-wrap gap-2 mb-3 align-items-end">
    ' . uh_form_select('status', 'Status', [
        'pending' => 'Pending', 'queued' => 'Queued', 'processing' => 'Processing',
        'reconciliation_required' => 'Requires Reconciliation', 'success' => 'Success',
        'failed' => 'Failed', 'refunded' => 'Refunded', 'reversed' => 'Reversed', 'expired' => 'Expired',
    ], showLabel: true) . '
    <div class="uh-filter-sm">' . uh_form_field('service_type', 'Service Type', 'text', ['placeholder' => 'e.g. AIRTIME']) . '</div>
    <div class="uh-filter-sm">' . uh_form_field('date_from', 'From', 'date') . '</div>
    <div class="uh-filter-sm">' . uh_form_field('date_to', 'To', 'date') . '</div>
  </div>
' . uh_table('uh-transactions-body', [
    ['label' => 'Reference', 'class' => 'uh-col-reference'],
    ['label' => 'Amount', 'class' => 'uh-col-amount'],
    ['label' => 'Status', 'class' => 'uh-col-status'],
    ['label' => 'Date', 'class' => 'uh-col-date'],
]), 'Transactions', '', 'transactions') ?>
<?php
$content = ob_get_clean();
require __DIR__ . '/../layouts/app.php';
