@php $tz = config('app.display_timezone'); $myState = $myEmail === null ? __('No Workspace email') : ($myOptedOut ? __('Off for you') : ($on ? __('Read') : __('Not yet'))); $cards = [ ['label' => __('Gmail logging'), 'value' => $on ? __('On') : __('Off'), 'icon' => 'envelope', 'accent' => $on ? '#059669' : '#64748b', 'sub' => $on ? __('Since :date', ['date' => $onSince?->copy()->timezone($tz)->format('j M Y')]) : ($googleOn ? __('A director turns it on') : __('Google Workspace is off'))], ['label' => __('Your mailbox'), 'value' => $myState, 'icon' => 'user', 'accent' => '#4f46e5', 'sub' => $myAccount?->gmail_synced_at && ! $myOptedOut ? __('Read :when', ['when' => $myAccount->gmail_synced_at->diffForHumans()]) : ($myEmail ?? __('Not on :domain', ['domain' => $domain ?: __('the company domain')]))], ['label' => __('Filed in 7 days'), 'value' => number_format($filedWeek), 'icon' => 'inbox', 'accent' => '#0891b2', 'sub' => __('Across the team')], ['label' => __('Your private threads'), 'value' => $privateThreads->count(), 'icon' => 'lock-closed', 'accent' => '#7c3aed', 'sub' => __('Never filed')], ]; $stateMeta = [ 'read' => ['label' => __('Read'), 'color' => 'emerald'], 'error' => ['label' => __('Needs attention'), 'color' => 'rose'], 'opted_out' => ['label' => __('Turned off by them'), 'color' => 'slate'], 'off' => ['label' => __('Logging is off'), 'color' => 'slate'], 'no_email' => ['label' => __('No Workspace email'), 'color' => 'amber'], ]; @endphp
@include('livewire.crm.settings.partials.nav', ['current' => 'crm.settings.gmail'])
@foreach ($cards as $m)

{{ $m['label'] }}

{{ $m['value'] }}

{{ $m['sub'] }}
@endforeach
{{-- Your mailbox --}}

{{ __('Your mailbox') }}

@if ($myEmail === null)

{{ __('You have no Workspace email on :domain, so nothing is read from your mail.', ['domain' => $domain ?: __('the company domain')]) }}

@elseif ($myOptedOut)

{{ __('You turned Gmail logging off for yourself. Nothing is read from :email. Turning it back on starts from that moment; nothing from the time it was off is filed.', ['email' => $myEmail]) }}

{{ __('Turn on for me') }} @else

@if ($on) {{ __('BillPro reads :email every few minutes and files emails with known contacts. You can keep any thread private from the list below.', ['email' => $myEmail]) }} @else {{ __('Gmail logging is off for the company, so nothing is read from :email yet.', ['email' => $myEmail]) }} @endif

@if ($myAccount?->gmail_last_error && $on)

{{ __('Google refused the last attempt') }}

{{ $myAccount->gmail_last_error }}

@endif {{ __('Turn off for me') }} @endif
{{-- Company switch --}}

{{ __('For the company') }}

{{ $on ? __('On') : __('Off') }}

{{ __('An email is filed only when someone else on it is a contact in the CRM, an organisation\'s own email address, or an address on an organisation\'s own domain (never a public one such as gmail.com). Each email is filed once, however many of the team were copied in. Attachments stay in Gmail.') }}

@if ($canManage)
@if ($on) {{ __('Turn off') }} @if ($errorCount > 0) {{ __('Try refused mailboxes again') }} @endif @elseif ($googleOn) {{ __('Turn on') }} @else

{{ __('Turn Google Workspace on first.') }}

@endif
@endif
@if ($canManage)

{{ __('Setup for the Workspace admin') }}

{{ __('1. In Google Cloud, enable the Gmail API') }}

{{ __('2. In the domain-wide delegation entry for BillPro, include for logging') }}

{{ implode(',', $readScopes) }}

{{ __('3. For templates, sequences and campaigns sent from Gmail, also include') }}

{{ implode(',', $sendScopes) }}

{{ __('Add them to the scopes already listed for Calendar and Meet; the entry keeps all of them, comma separated. A change in the Admin console can take a few hours to reach Google\'s servers.') }}

{{ __('Mailboxes') }}

{{ __(':read read, :errors needing attention. Private threads are never shown here.', ['read' => $readCount, 'errors' => $errorCount]) }}

@foreach ($mailboxes as $row) @endforeach
{{ __('Person') }} {{ __('Workspace email') }} {{ __('Status') }} {{ __('Last read') }}
{{ $row['user']->name }} {{ $row['email'] ?? __('Not set') }} {{ $stateMeta[$row['state']]['label'] }} @if ($row['state'] === 'error')

{{ $row['error'] }}

@endif
{{ $row['synced_at'] ? $row['synced_at']->copy()->timezone($tz)->format('j M Y H:i') : __('Not yet') }}
@endif {{-- Filed from your mailbox --}}

{{ __('Filed from your mailbox') }}

{{ __('The 25 most recent. Keeping a thread private removes what was filed from it and files nothing more from it.') }}

@forelse ($myFiled as $message) @empty @endforelse
{{ __('Date') }} {{ __('Subject') }} {{ __('Filed on') }} {{ __('Direction') }} {{ __('Actions') }}
{{ $message->sent_at->copy()->timezone($tz)->format('j M Y H:i') }} {{ $message->subject ?: __('(no subject)') }} {{ $message->direction === 'outbound' ? __('To :to', ['to' => implode(', ', array_keys((array) $message->to))]) : __('From :from', ['from' => $message->from_name ?: $message->from_email]) }} @if ($message->customer) {{ $message->customer->name }} @endif @if ($message->opportunity) {{ $message->opportunity->title }} @endif {{ __(\App\Models\Crm\EmailMessage::DIRECTIONS[$message->direction] ?? $message->direction) }}
@if ($message->gmail_url) {{ __('Open in Gmail') }} @endif
@include('livewire.crm.partials.paginator', ['rows' => $myFiled])
@if ($privateThreads->isNotEmpty())

{{ __('Your private threads') }}

{{ __('Only you see this list.') }}

@foreach ($privateThreads as $thread) @endforeach
{{ __('Subject') }} {{ __('Kept private on') }} {{ __('Actions') }}
{{ $thread->subject ?: __('(no subject)') }} {{ $thread->created_at->copy()->timezone($tz)->format('j M Y') }}
@include('livewire.crm.partials.paginator', ['rows' => $privateThreads])
@endif