@extends('layouts.app') @section('content')
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif
{{-- Coluna principal --}}
Oferta #{{ $offer->id }} — {{ Str::upper($offer->platform) }}
@include('admin.monitoring.offers.partials.show-header-status', ['offer' => $offer])
@if($offer->product_image_url)
Produto
@endif

Título: {{ $offer->product_title ?? '—' }}

Preço: @if($offer->product_price) R$ {{ number_format($offer->product_price, 2, ',', '.') }} @else — @endif

Produto ID: {{ $offer->product_id }}

Fonte: {{ $offer->source?->name ?? 'manual' }}


URL Original

{{ $offer->original_url }}

@if($offer->formatted_text)
Texto formatado (o que é enviado ao Telegram)
{{ $offer->formatted_text }}
@else
Sem texto formatado. @if($offer->fetch_failed) Scraping falhou. @else Ainda processando. @endif
@endif
@include('admin.monitoring.offers.partials.show-attempts-block', ['offer' => $offer])
@if($offer->posted_at)

Publicada em {{ $offer->posted_at->format('d/m/Y H:i') }} ({{ $offer->posted_at->diffForHumans() }})

@endif
@can('monitoring.offers.manage') @endcan
{{-- Coluna lateral: status por destino + histórico --}}
{{-- Status por destino (fan-out) --}} @php $applicableTargets = \App\Models\PublicationTarget::active() ->where('user_id', $offer->user_id) ->where('created_at', '<=', $offer->created_at) ->get(); $logsByTarget = $offer->publicationLogs->groupBy('target_id'); $maxAttempts = (int) (\App\Models\Setting::get('telegram.publish_max_attempts') ?: config('telegram.publication.max_attempts_per_offer', 3)); @endphp @if($applicableTargets->isNotEmpty())
Status por destino
@can('monitoring.offers.manage') @endcan @foreach($applicableTargets as $target) @php $targetLogs = $logsByTarget->get($target->id, collect()); $hasSuccess = $targetLogs->where('status', 'success')->isNotEmpty(); $failCount = $targetLogs->where('status', 'failure')->count(); $isGivenUp = !$hasSuccess && $failCount >= $maxAttempts; $lastError = $targetLogs->where('status', 'failure')->sortByDesc('created_at')->first()?->error_message; @endphp @can('monitoring.offers.manage') @endcan @if($lastError) @endif @endforeach
Destino Status Tentativas
{{ $target->channel_name ?: $target->channel_identifier }}
{{ $target->platform }}
@if($hasSuccess) OK @elseif($isGivenUp) Desistido @elseif($failCount > 0) Falhou @else Pendente @endif {{ $targetLogs->count() }} @if(!$hasSuccess)
@csrf
@endif
{{ Str::limit($lastError, 100) }}
@endif {{-- Histórico de publicações --}}
Histórico de tentativas
@if($offer->publicationLogs->isEmpty())

Nenhuma tentativa de publicação ainda.

@else
    @foreach($offer->publicationLogs->sortByDesc('created_at') as $log)
  • {{ $log->status === 'success' ? 'OK' : 'FALHA' }} {{ $log->created_at?->format('d/m H:i') }}
    {{ $log->target?->channel_name ?: ($log->target?->channel_identifier ?? '—') }} {{ $log->target?->platform }} @if($log->error_message) {{ Str::limit($log->error_message, 80) }} @endif @if($log->external_message_id) msg_id: {{ $log->external_message_id }} @endif
  • @endforeach
@endif
@endsection @can('monitoring.offers.manage') @push('scripts') @include('admin.monitoring.offers.partials.retry-ajax-script') @endpush @endcan