@extends('portal._layout')
@section('title', __('portal.page_title_account'))
@section('topbar')
{{ $tenant?->name ?? config('leadhub.branding.app_name', 'LeadHub') }}
@endsection
@section('content')
{{ __('portal.greeting_hi', ['name' => $lead->first_name ?: __('portal.greeting_there')]) }}
{{ __('portal.greeting_sub') }}
{{-- Pipeline progress --}}
@if($lead->pipeline && $allStages->isNotEmpty())
{{ __('portal.where_you_are') }}
@php
$currentIndex = $allStages->search(fn($s) => $s->id === $lead->pipeline_stage_id);
$total = $allStages->count();
$pct = $currentIndex === false ? 0 : (int) round((($currentIndex + 1) / $total) * 100);
@endphp
{{-- NOTE: width is DYNAMIC — driven by $pct percentage --}}
@foreach($allStages as $i => $stage)
@php $isCurrent = $stage->id === $lead->pipeline_stage_id; $isPast = $currentIndex !== false && $i < $currentIndex; @endphp
{{-- NOTE: background DYNAMIC — color depends on stage state (current/past/future) --}}
@if($isPast) ✓ @else {{ $i + 1 }} @endif
{{-- NOTE: color + font-weight DYNAMIC — highlight current stage --}}
{{ $stage->name }}
@endforeach
@endif
{{-- Assigned rep + deal --}}
@if($lead->assignedUser || $lead->deal_value)
{{ __('portal.your_account') }}
@if($lead->assignedUser)
{{ __('portal.your_contact') }}
{{ $lead->assignedUser->name }}
@endif
@if($lead->deal_value)
{{ __('portal.deal_value') }}
{{ $lead->deal_currency ?? '$' }} {{ number_format($lead->deal_value, 2) }}
@endif
@if($lead->expected_close_date)
{{ __('portal.expected_close') }}
{{-- Carbon::toFormattedDateString() returns the
English "M j, Y" format ("Apr 17, 2026") and
ignores app locale. translatedFormat() walks
the same tokens through the current Symfony
translator so non-English buyers see the
localised month abbreviation. --}}
{{ $lead->expected_close_date->translatedFormat('M j, Y') }}
@endif
@endif
{{-- Activity timeline (public-safe only) --}}
@if($activities->isNotEmpty())
{{ __('portal.recent_activity') }}
@foreach($activities as $a)
@php
// Translator-first activity description when no persisted description.
// Looks up lead_activities.
so the portal feed respects locale,
// falls back to the humanised key for unknown future activity types.
$actDesc = (string) ($a->description ?? '');
if ($actDesc === '' && $a->type) {
$actKey = 'lead_activities.' . $a->type;
$actTrans = __($actKey);
$actDesc = is_string($actTrans) && $actTrans !== $actKey
? $actTrans
: ucfirst(str_replace('_', ' ', (string) $a->type));
}
@endphp
{{ $actDesc }}
{{ $a->created_at->diffForHumans() }}
@endforeach
@endif
{{-- Documents / upload --}}
{{ __('portal.documents') }}
@if($lead->attachments->isNotEmpty())
@foreach($lead->attachments as $att)
{{ $att->original_name }}
{{ $att->getHumanSize() }} · {{ $att->created_at->diffForHumans() }}
@endforeach
@else
{{ __('portal.no_documents_yet') }}
@endif
@endsection