@extends('layouts.admin.app')

@section('title', translate('Customer Checking'))

@section('content')
    @php
        $subject     = data_get($courierPerformanceSummary, 'subject', []);
        $subjectName = data_get($subject, 'name', translate('Customer'));
        $backUrl     = $sourceOrder
            ? route($sourceOrder->order_type === 'parcel' ? 'admin.parcel.order.details' : 'admin.order.details', [$sourceOrder->id, 'module_id' => $sourceOrder->module_id])
            : route('admin.users.customer.view', [data_get($subject, 'customer_id')]);
    @endphp

    <div class="content container-fluid">
        <div class="page-header">
            <div class="row align-items-center">
                <div class="col-sm mb-2 mb-sm-0">
                    <h1 class="page-header-title">{{ translate('Customer Checking') }}</h1>
                    <div class="fs-12 text-muted d-flex flex-wrap align-items-center gap-2">
                        <span><i class="tio-user mr-1"></i>{{ $subjectName }}</span>
                        @if(data_get($subject, 'phone'))
                            <span>•</span>
                            <span><i class="tio-call mr-1"></i>{{ data_get($subject, 'phone') }}</span>
                        @endif
                        @if(data_get($subject, 'email'))
                            <span>•</span>
                            <span><i class="tio-email mr-1"></i>{{ data_get($subject, 'email') }}</span>
                        @endif
                    </div>
                </div>
                <div class="col-sm-auto">
                    <a href="{{ $backUrl }}" class="btn btn--primary">
                        <i class="tio-arrow-backward"></i>
                        {{ translate('Back') }}
                    </a>
                </div>
            </div>
        </div>

        @if($sourceOrder)
            <div class="card mb-3">
                <div class="card-body d-flex flex-wrap align-items-center justify-content-between gap-3">
                    <div>
                        <h5 class="mb-1">
                            {{ translate('Order Reference') }} #{{ $sourceOrder->id }}
                        </h5>
                        <div class="fs-12 text-muted">
                            {{ translate('Use this summary to decide courier risk before sending the current order.') }}
                        </div>
                    </div>
                    <span class="text-capitalize badge badge-soft-dark py-2 px-3">
                        {{ str_replace('_', ' ', $sourceOrder->order_status) }}
                    </span>
                </div>
            </div>
        @endif

        @include('admin-views.customer.partials._courier-performance-summary', [
            'courierPerformanceSummary' => $courierPerformanceSummary,
        ])
    </div>
@endsection
