@extends('layouts.app') @section('title', __('admin.dashboard_title')) @section('content')
{{-- Header Row --}}

{{ __('admin.dashboard_title') }}

{{-- Package Comparison Button (Admin Only) --}} @can('access-admin-settings') @endcan {{-- Add Campaign Button (Campaign Managers and Above) --}} @can('manage-campaigns') @if ($canAddCampaign) {{ __('admin.add_campaign') }} @else @endif @endcan {{-- View Mode Toggle Buttons (Only show if user can see campaigns or products) --}} @if (Gate::allows('manage-campaigns') || Gate::allows('manage-products'))
@endif
{{-- Welcome Block --}}

{{ Auth::check() ? __('admin.welcome_message', ['name' => e(Auth::user()->name)]) : '' }}

{{ __('admin.welcome_submessage') }}

{{ __('admin.current_package') }}: {{ $currentPackageName }}

@can('access-admin-settings') {{ __('admin.upgrade_plan') }} @endcan
{{-- Quick Links & Status --}}
{{-- Quick Links --}} @php $userRole = Auth::check() ? Auth::user()->role : null; $links = []; if (Gate::allows('manage-campaigns')) { $links[__('admin.nav_campaigns')] = 'admin.campaigns.index'; } if (Gate::allows('manage-products')) { $links[__('admin.nav_inventory')] = 'admin.products.index'; } if (Gate::allows('manage-users')) { $links[__('admin.nav_users')] = 'admin.users.index'; } if (Gate::allows('manage-addresses')) { $links[__('admin.nav_addresses')] = 'admin.addresses.index'; } if (Gate::allows('manage-orders')) { $links[__('admin.nav_orders')] = 'admin.orders.index'; } @endphp @if (!empty($links))

{{ __('admin.quick_links') }}

@foreach ($links as $label => $route) {{ $label }} @endforeach
@endif {{-- System Status --}}

{{ __('admin.system_status') }}

{{-- Payment Gateway Status (Only for payment managers) --}} @can('manage-payments')

{{ __('admin.payment_gateways') }}

{{ __('admin.stripe_status') }}: {{ $stripeConfigured ? __('admin.status_on') : __('admin.status_off') }} {{ __('admin.till_status') }}: {{ $tillConfigured ? __('admin.status_on') : __('admin.status_off') }} {{ __('admin.settings_link') }}
@endcan {{-- Amazon API Status (Only for product managers) --}} @can('manage-products')
@if ($amazonApiStatus === 'Connected') @else @endif

{{ __('admin.amazon_business_api') }}

{{ $amazonApiStatus === 'Connected' ? __('admin.api_status_connected') : __('admin.api_status_error') }}

@endcan {{-- Show simple welcome message if user has no management permissions --}} @if (!Gate::allows('manage-payments') && !Gate::allows('manage-products'))

Welcome to your dashboard! Contact your administrator if you need access to additional features.

@endif
{{-- Stats Block --}}
{{-- Total Campaigns Stat --}} @if ($totalCampaigns > 0 || Gate::allows('manage-campaigns'))
{{ __('admin.total_campaigns') }}
{{ $totalCampaigns }}
@endif {{-- Total Products Stat --}} @if ($totalProducts > 0 || Gate::allows('manage-products'))
{{ __('admin.total_products') }}
{{ $totalProducts }}
@endif {{-- Total Users Stat --}} @if ($totalUsers > 0)
{{ __('admin.total_users') }}
{{ $totalUsers }}
@endif {{-- Total Addresses Stat --}} @if ($totalAddresses > 0)
{{ __('admin.total_addresses') }}
{{ $totalAddresses }}
@endif
{{-- Main Content Grid (Campaigns & Products) - Only show if user has permissions --}} @if (Gate::allows('manage-campaigns') || Gate::allows('manage-products'))
{{-- Latest Campaigns Section --}} @can('manage-campaigns')
{{-- Header --}}

{{ __('admin.latest_campaigns') }}

{{ __('admin.view_all') }}
{{-- List View Container --}}
@forelse ($latestCampaigns as $campaign)
@if ($campaign->image_path) @else
@endif
{{ $campaign->title }} @if ($campaign->enabled) {{ __('admin.campaign_enabled') }} @else {{ __('admin.campaign_disabled') }} @endif
{{ __('admin.edit') }}
@empty

{{ __('admin.no_campaigns_found') }}

{{ __('admin.create_one') }}
@endforelse
{{-- Grid View Container --}}
@forelse ($latestCampaigns as $campaign)
@if ($campaign->image_path) {{ $campaign->title }} @else
@endif

{{ $campaign->title }}

@if ($campaign->enabled) {{ __('admin.campaign_enabled') }} @else {{ __('admin.campaign_disabled') }} @endif
@empty

{{ __('admin.no_campaigns_found') }}

{{ __('admin.create_one') }}
@endforelse
@endcan {{-- Latest Products Section --}} @can('manage-products')

{{ __('admin.latest_products') }}

{{ __('admin.view_all') }}
{{-- List View Container --}}
@forelse ($latestProducts as $product)
@if ($product->image_url) {{ $product->name }} @else
@endif
{{ $product->name }} {{ __('admin.product_asin', ['asin' => $product->asin]) }}
@if ($product->campaigns->count() > 0) {{ $product->campaigns->first()->title }} @endif
@empty

{{ __('admin.no_products_found') }}

{{ __('admin.search_and_add') }}
@endforelse
{{-- Grid View Container --}}
@forelse ($latestProducts as $product)
@if ($product->image_url) {{ $product->name }} @else
@endif

{{ $product->name }}

{{ __('admin.product_asin', ['asin' => $product->asin]) }} @if ($product->campaigns->count() > 0) Campaign: {{ $product->campaigns->first()->title }} @endif
@empty

{{ __('admin.no_products_found') }}

{{ __('admin.search_and_add') }}
@endforelse
@endcan
{{-- End Main Content Grid --}} @endif {{-- Welcome message for users with no management permissions --}} @if ( !Gate::allows('manage-campaigns') && !Gate::allows('manage-products') && !Gate::allows('manage-users') && !Gate::allows('manage-orders'))

Welcome to the Dashboard

You currently have view-only access to the system. Contact your administrator if you need access to manage campaigns, products, or other features.

@endif {{-- Include the Modal Component (Admin Only) --}} @can('access-admin-settings') @endcan
{{-- End Alpine Component --}} @endsection