@extends('layouts.customer') @section('customer-content')

Welcome back, {{ auth()->user()->name }}!

Total Orders

{{ $totalOrders }}

Pending Orders

{{ $pendingOrders }}

Wishlist

{{ $wishlistCount }}

{{-- Recent Orders --}}

Recent Orders

View All →
@if($recentOrders->count() > 0)
@foreach($recentOrders as $order) @endforeach
Order # Date Items Total Status
{{ $order->order_number }} {{ $order->created_at->format('M d, Y') }} {{ $order->items->count() }} item(s) {{ price($order->total) }} {{ ucfirst($order->status) }} View →
@else

No orders yet. Start shopping →

@endif
{{-- Recent Chats --}}

Recent Chats

@if($recentChats->count() > 0)
@foreach($recentChats as $chat) @php $participant = $chat->vendor ?? $chat->promoter ?? $chat->admin; $participantType = $chat->vendor_id ? 'vendor' : ($chat->promoter_id ? 'promoter' : 'admin'); $initial = $participant ? substr($participant->name, 0, 1) : '?'; $lastMessage = $chat->messages->last(); $unreadCount = $chat->messages()->where('is_read', false)->where('sender_id', '!=', auth()->id())->count(); $avatarClass = match($participantType) { 'vendor' => 'bg-emerald-100 text-emerald-700', 'promoter' => 'bg-purple-100 text-purple-700', default => 'bg-red-100 text-red-700', }; $badgeClass = match($participantType) { 'vendor' => 'bg-emerald-50 text-emerald-700', 'promoter' => 'bg-purple-50 text-purple-700', default => 'bg-red-50 text-red-700', }; @endphp
{{ $initial }}
@if($unreadCount > 0) @endif

{{ $participant->name ?? 'Unknown' }}

{{ $participantType }}

{{ $lastMessage ? Str::limit($lastMessage->message ?: 'Sent an image', 30) : ($chat->product ? 'About: ' . $chat->product->name : 'No messages yet') }}

@if($unreadCount > 0) {{ $unreadCount }} @endif
@endforeach
@else

No conversations

Start a new chat to begin messaging

@endif
{{-- New Chat Modal --}} @endsection