@extends('layouts.customer') @section('title', 'My Referrals') @section('content')
{{-- Referral Link Card --}}

Referral Dashboard

Share your referral link and earn points when someone completes a shipment!

@if($referralLink) {{-- Show referral link --}} @else {{-- Generate referral code --}}
@csrf
@endif

Total Referral Points: {{ $totalPoints ?? 0 }}

{{-- Referrals Table --}}
@forelse($referrals as $index => $ref) @php $position = $index + 1; // Only completed referrals count $pointsEarned = $ref->status === 'completed' ? $ref->points_awarded : 0; $isPremium = $ref->referredUser && $ref->referredUser->isPremium(); // Badge colors $badgeColor = match($position) { 1 => 'bg-yellow-400 text-gray-900', 2 => 'bg-orange-500 text-white', 3 => 'bg-red-500 text-white', default => 'bg-gray-200 text-gray-900', }; @endphp
@if($position <= 3) {{ ordinal($position) }} Referral @else Referral #{{ $position }} @endif

{{ $ref->referredUser->name ?? 'N/A' }}

{{ $ref->referredUser->email ?? 'N/A' }}

Points Earned: {{ $pointsEarned }} @if($isPremium && $ref->status === 'completed') ×10 Premium @endif

Subscribed Premium? @if($isPremium) Yes @else No @endif

@if($ref->status === 'pending')

Pending: Points will be awarded when user performs a shipment

@endif
@empty

No referrals yet.

@endforelse
@endsection