@extends('backend.p2p.layout') @section('title', __('P2P Marketplace')) @section('p2p_title') {{ __('P2P Marketplace') }} @endsection @section('p2p_icon', 'transaction-2') @php $p2pEnabled = (bool) ($settings->enabled ?? false); $ordersToday = (int) ($insights['orders_today'] ?? 0); $inFlightOrders = (int) ($insights['in_flight_orders'] ?? 0); $openDisputes = (int) ($insights['open_disputes'] ?? 0); $activeOffers = (int) ($insights['active_offers'] ?? 0); $orderSeries = $activityChart['orders'] ?? []; $disputeSeries = $activityChart['disputes'] ?? []; $chartLabels = $activityChart['labels'] ?? []; $periodOrders = (int) array_sum($orderSeries); $periodDisputes = (int) array_sum($disputeSeries); $hasActivity = ($periodOrders + $periodDisputes) > 0; $makerFee = rtrim(rtrim(number_format((float) $settings->maker_fee_pct, 4, '.', ''), '0'), '.') ?: '0'; $takerFee = rtrim(rtrim(number_format((float) $settings->taker_fee_pct, 4, '.', ''), '0'), '.') ?: '0'; $statusClass = $p2pEnabled ? 'p2p-market-chip--success' : 'p2p-market-chip--danger'; $statusLabel = $p2pEnabled ? __('Open · Accepting trades') : __('Paused'); $statusSub = $p2pEnabled ? __('All fee tiers active · Settlement window normal · Configure rules from settings.') : __('Trading is currently disabled from marketplace settings.'); $expiryMinutes = (int) $settings->order_expiry_minutes; $disputeMinutes = (int) $settings->dispute_window_minutes; $updatedAgo = $settings->updated_at ? $settings->updated_at->diffForHumans() : __('recently'); $currencyCode = siteCurrency('code') ?? 'BDT'; // Build SVG sparkline points from order counts $chartWidth = 720; $chartHeight = 220; $padX = 16; $padY = 18; $series = $orderSeries; $count = max(count($series), 2); $maxValue = $hasActivity ? max(1, (int) ((max($series ?: [1])) * 1.15)) : 1; $stepX = ($chartWidth - $padX * 2) / max(1, $count - 1); $points = []; foreach ($series as $i => $v) { $x = $padX + $i * $stepX; $y = $chartHeight - $padY - (($v - 0) / max(0.0001, $maxValue)) * ($chartHeight - $padY * 2); $points[] = [$x, $y]; } if (empty($points)) { for ($i = 0; $i < 14; $i++) { $points[] = [$padX + $i * $stepX, $chartHeight - $padY]; } } $linePath = ''; foreach ($points as $i => $p) { $linePath .= ($i === 0 ? 'M ' : ' L ').number_format($p[0], 2, '.', '').' '.number_format($p[1], 2, '.', ''); } $lastX = $points[count($points) - 1][0]; $areaPath = $linePath.' L '.number_format($lastX, 2, '.', '').' '.($chartHeight - $padY).' L '.$padX.' '.($chartHeight - $padY).' Z'; @endphp @section('p2p_action') @can('p2p-manage') @lang('Configure') @endcan @can('p2p-dispute-manage') @lang('Disputes') @if($openDisputes > 0) {{ number_format($openDisputes) }} @endif @endcan @endsection @section('p2p_content')
{{-- Market status hero --}}
@lang('Marketplace status')

{{ $statusLabel }}

{{ $p2pEnabled ? __('Live') : __('Paused') }}

{{ $statusSub }}
@lang('Last config update'): {{ $updatedAgo }}.

@lang('Maker fee') {{ $makerFee }}%
@lang('Taker fee') {{ $takerFee }}%
@lang('Dispute window') {{ $disputeMinutes }}@lang('min')
@lang('Expiry') {{ $expiryMinutes }}@lang('min')
{{-- KPI cards --}}
@lang('Orders today') {{ number_format($ordersToday) }} @lang('Last 24h')
@lang('Active offers') {{ number_format($activeOffers) }} @lang('Live across marketplace')
@lang('Pending escrow') {{ number_format($inFlightOrders) }} @lang('In-flight orders')
@lang('Open disputes') {{ number_format($openDisputes) }} @if($openDisputes > 0) @lang('Requires attention') @else @lang('All clear') @endif
{{-- 14-day chart --}}
@lang('Trading activity')
@lang('14-day flow')
{{ number_format($periodOrders) }} @lang('orders') {{ number_format($periodDisputes) }} @lang('disputes')
@lang('Total orders · Last 14 days') {{ number_format($periodOrders) }}
@lang('Orders') @lang('Disputes')
@if($hasActivity) @for($i = 0; $i < 4; $i++) @php $y = $padY + ($i * ($chartHeight - $padY * 2)) / 3; @endphp @endfor @foreach($points as $i => $p) @endforeach @foreach($chartLabels as $i => $label) @if($i % 3 === 0) {{ $label }} @endif @endforeach @else
@lang('No activity yet')
@lang('Orders and disputes from the last 14 days will appear here.')
@endif
@endsection