@extends('layouts.admin') @section('title','Returns') @section('content') @php $columns = [ 'return' => 'Return', 'customer' => 'Customer', 'reason' => 'Reason', 'items' => 'Items', 'value' => 'Value', 'priority' => 'Priority', 'status' => 'Status', 'activity' => 'Activity', 'actions' => 'Actions', ]; $label = fn (string $v) => ucwords(str_replace('_', ' ', $v)); $statusTone = fn (string $s) => match ($s) { 'requested' => 'warning', 'open' => 'info', 'inspected' => 'info', 'completed' => 'success', 'canceled' => 'muted', default => 'muted', }; $priorityTone = fn (string $p) => match ($p) { 'urgent' => 'danger', 'high' => 'warning', default => 'muted', }; $activeChips = collect([ 'status' => request('status'), 'priority' => request('priority'), 'reason_code' => request('reason_code'), 'resolution' => request('resolution'), 'from' => request('from'), 'to' => request('to'), 'sort' => request('sort') && request('sort') !== 'newest' ? request('sort') : null, ])->filter(); @endphp Needs label ({{ number_format($stats['awaiting_label']) }}) High priority ({{ number_format($stats['high_priority']) }})
Open pipeline {{ number_format($stats['open']) }} Requested / open / inspected
Refund pipeline AUD {{ number_format($stats['refund_pipeline_cents'] / 100, 0) }} Still unresolved
Awaiting approval {{ number_format($stats['requested']) }} New RMA requests Completed {{ number_format($stats['completed']) }} AUD {{ number_format($stats['refunded_cents'] / 100, 0) }} refunded Needs label {{ number_format($stats['awaiting_label']) }} No shipment label yet
@foreach([ ['label' => 'All', 'params' => []], ['label' => 'Active', 'params' => ['status' => 'active']], ['label' => 'Requested', 'params' => ['status' => 'requested']], ['label' => 'Needs label', 'params' => ['status' => 'needs_label']], ['label' => 'Inspected', 'params' => ['status' => 'inspected']], ['label' => 'Completed', 'params' => ['status' => 'completed']], ['label' => 'High priority', 'params' => ['priority' => 'elevated', 'status' => 'active']], ] as $chip) @php $isActive = collect($chip['params'])->every(fn ($v, $k) => request($k) === $v) && (empty($chip['params']) ? ! request()->hasAny(['status', 'priority', 'reason_code', 'resolution']) : true); @endphp {{ $chip['label'] }} @endforeach
@if($activeChips->isNotEmpty())
Active @foreach($activeChips as $key => $value) {{ $label($key) }}: {{ $label((string) $value) }} @endforeach Clear all
@endif
Return Customer Reason Items Value Priority Status Activity @forelse($returns as $row)
{{ $row->number }}
Order {{ $row->order?->number ?? '#'.$row->order_id }}
{{ $row->customer_email ?: ($row->customer?->email ?: '—') }}
{{ $label($row->resolution ?: 'refund') }}
{{ $row->reason ?: '—' }}
@if($row->reason_code)
{{ $label($row->reason_code) }}
@endif {{ number_format($row->item_count ?: $row->lines->sum('quantity')) }} {{ $row->labeledRefund() }} {{ $label($row->priority ?: 'normal') }} {{ $label($row->status) }} @if($row->tracking_number)
{{ $row->carrier }} · {{ $row->tracking_number }}
@endif
{{ $row->updated_at?->diffForHumans() }}
@if($row->label_sent_at && ! $row->received_at)
Label {{ $row->label_sent_at->diffForHumans() }}
@elseif($row->received_at && $row->status !== 'completed')
Received {{ $row->received_at->diffForHumans() }}
@elseif($row->completed_at)
Closed {{ $row->completed_at->diffForHumans() }}
@endif Open @empty No returns match these filters. @endforelse
{{ $returns->links() }}
@endsection