@extends('admin.layouts.app') @section('title', admin_trans('notification_details')) @section('page-title', admin_trans('notification_details')) @section('content')
{{ admin_trans('back_to_notifications') }}
@if($notification->status === 'failed')
@csrf {{ admin_trans('resend') }}
@endif {{ admin_trans('delete') }}
@php $typeColors = [ 'system' => 'info', 'promotional' => 'warning', 'offer' => 'success', 'store' => 'primary', 'brand' => 'secondary', 'user' => 'purple' ]; $statusColors = [ 'pending' => 'warning', 'sent' => 'success', 'failed' => 'danger' ]; @endphp

{{ $notification->title }}

{{ admin_trans($notification->type) }} {{ admin_trans($notification->status) }}
{{ admin_trans('created_at') }}
{{ $notification->created_at->format('M d, Y H:i') }}
{{ $notification->message }}
@php $priorityVariant = match(true) { $notification->priority >= 8 => 'danger', $notification->priority >= 5 => 'warning', default => 'info' }; @endphp {{ $notification->priority }} - @if($notification->priority >= 8) {{ admin_trans('high') }} @elseif($notification->priority >= 5) {{ admin_trans('medium') }} @else {{ admin_trans('low') }} @endif
@foreach($notification->channels as $channel) {{ admin_trans($channel) }} @endforeach
@if($notification->data && count($notification->data) > 0)
{{ json_encode($notification->data, JSON_PRETTY_PRINT) }}
@endif

{{ admin_trans('target_audience') }}

@foreach($notification->targets as $target)
@php $targetIcons = [ 'all' => 'users', 'country' => 'globe', 'language' => 'languages', 'role' => 'user-check', 'user' => 'user', 'store_followers' => 'store', 'brand_followers' => 'sparkles' ]; @endphp
{{ admin_trans($target->target_type) }} @if($target->target_id) @switch($target->target_type) @case('country') @php $country = \App\Models\Country::find($target->target_id); @endphp @if($country) : {{ $country->name }} @endif @break @case('language') @php $language = \App\Models\Language::find($target->target_id); @endphp @if($language) : {{ $language->name }} @endif @break @case('store_followers') @php $store = \App\Models\CountryStore::find($target->target_id); @endphp @if($store) : {{ $store->store->getName() }} @endif @break @case('brand_followers') @php $brand = \App\Models\Brand::find($target->target_id); @endphp @if($brand) : {{ $brand->getName() }} @endif @break @default : {{ $target->target_id }} @endswitch @endif
{{ $target->getTargetUsers()->count() }} {{ admin_trans('users') }}
@endforeach

{{ admin_trans('delivery_history') }}

{{ admin_trans('view_full_report') }} →
@if($notification->deliveries->isEmpty())

{{ admin_trans('no_deliveries_yet') }}

@else
@foreach($notification->deliveries->take(10) as $delivery)
{{ substr($delivery->user->name, 0, 1) }}
{{ $delivery->user->name }}
{{ $delivery->user->email }}
@php $deliveryStatusColors = [ 'pending' => 'warning', 'sent' => 'info', 'read' => 'success', 'failed' => 'danger' ]; @endphp {{ admin_trans($delivery->status) }}
{{ $delivery->created_at->diffForHumans() }}
@endforeach
@endif

{{ admin_trans('delivery_statistics') }}

{{ admin_trans('total_targets') }} {{ number_format($stats['total_targets']) }}
{{ admin_trans('delivered') }} {{ number_format($stats['delivered']) }}
{{ admin_trans('read') }} {{ number_format($stats['read']) }}
{{ admin_trans('failed') }} {{ number_format($stats['failed']) }}
{{ admin_trans('pending') }} {{ number_format($stats['pending']) }}
{{ admin_trans('delivery_rate') }} {{ $stats['delivery_rate'] }}%
{{ admin_trans('read_rate') }} {{ $stats['read_rate'] }}%

{{ admin_trans('insights') }}

@if($stats['delivery_rate'] >= 90)
{{ admin_trans('excellent_delivery') }}
{{ admin_trans('high_delivery_rate_message') }}
@elseif($stats['delivery_rate'] >= 70)
{{ admin_trans('good_delivery') }}
{{ admin_trans('room_for_improvement') }}
@else
{{ admin_trans('low_delivery') }}
{{ admin_trans('delivery_issues_detected') }}
@endif @if($stats['read_rate'] >= 50)
{{ admin_trans('good_engagement') }}
{{ admin_trans('users_reading_notifications') }}
@else
{{ admin_trans('low_engagement') }}
{{ admin_trans('consider_better_timing') }}
@endif

{{ admin_trans('channel_performance') }}

@foreach($notification->channels as $channel) @php // Get deliveries for this channel $channelDeliveries = $notification->deliveries->where('channel', $channel); $channelTotal = $channelDeliveries->count(); $channelSuccess = $channelDeliveries->where('status', 'sent')->count() + $channelDeliveries->where('status', 'read')->count(); $channelRate = $channelTotal > 0 ? round(($channelSuccess / $channelTotal) * 100, 1) : 0; @endphp
@php $channelIcons = [ 'database' => 'database', 'push' => 'smartphone', 'email' => 'mail' ]; @endphp {{ admin_trans($channel) }}
{{ $channelRate }}%
{{ $channelSuccess }}/{{ $channelTotal }}
@endforeach
@endsection @push('scripts') @endpush