@php $isConnected = $integration && $integration->isConnected(); @endphp
{{-- Left rail --}} {{-- Main --}}
{{ __('Integrations') }} / {{ __('HubSpot') }}
@if ($isConnected)

{{ $integration->portal_name ?: __('HubSpot') }} {{ __('portal') }}

{{ __('Portal ID:') }} {{ $integration->portal_id ?: '—' }} · {{ __('Connected') }} {{ $integration->connected_at?->diffForHumans() ?? '—' }}

@else

{{ __('Connect') }} {{ __('HubSpot CRM') }}

{{ __('Push contacts + deals into HubSpot whenever a :app conversation triggers an interesting event — new chat, order placed, SKU of interest mentioned.', ['app' => \App\Models\SystemSetting::get('app_name', config('app.name', 'WaDesk'))]) }}

@endif
@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif @if (!$isConnected) @if (!$appEnabled)
{{ __("HubSpot isn't configured yet") }}

An admin needs to register a HubSpot public app at {{ __('developers.hubspot.com') }} and paste the Client ID + Client Secret at /admin/settings/hubspot.

@else

{{ __('Connect your HubSpot portal') }}

{{ __("You'll be redirected to HubSpot to approve the scopes:") }} {{ \App\Models\SystemSetting::get('hubspot_scopes', \App\Services\Hubspot\HubspotService::DEFAULT_SCOPES) }}

@csrf
@endif @else {{-- Connected — live sync KPIs (from the activity log, no hardcoded numbers) --}}
{{ __('Deals created') }}
{{ number_format($stats['created'] ?? 0) }}
{{ __('Stage updates') }}
{{ number_format($stats['updated'] ?? 0) }}
{{ __('Failed') }}
{{ number_format($stats['failed'] ?? 0) }}
{{ __('Last sync') }}
{{ !empty($stats['last']) ? \Illuminate\Support\Carbon::parse($stats['last'])->diffForHumans() : __('Never') }}
{{-- Connected — activity log --}}

{{ __('Recent activity') }}

@csrf
@forelse ($recentLogs as $log) @php $statusCss = $log->status === 'sent' ? 'bg-wa-green/15 text-wa-deep' : 'bg-accent-coral/15 text-accent-coral'; @endphp @empty @endforelse
{{ __('Event') }} {{ __('Object ID') }} {{ __('Status') }} {{ __('When') }}
{{ $log->event_type }} {{ $log->object_id ?: '—' }} {{ $log->status }} {{ $log->created_at?->diffForHumans() ?? '—' }}
{{ __('No HubSpot sync events yet. A contact + deal is pushed automatically the next time an order is placed, and the deal advances as its status changes.') }}
@endif