{{-- /devices when active engine = twilio. Renders the operator's connected Twilio account or the connect form. Mirrors the WABA section's empty-state + card layout so multi-engine workspaces feel consistent when they switch between modes. Vars expected (passed from DevicesController): $twilioAccount — WaProviderConfig row for provider=twilio, or null $twilioAdminDefaults — ['account_sid' => str, 'whatsapp_number' => str] — soft-hint admin-shared creds the user can inherit by leaving fields blank --}} @php $tw = $twilioAccount ?? null; $creds = $tw ? $tw->creds() : []; $sandbox = !empty($tw?->meta_json['sandbox']); $isConnected = $tw && $tw->isConnected(); $defaults = is_array($twilioAdminDefaults ?? null) ? $twilioAdminDefaults : ['account_sid' => '', 'whatsapp_number' => '']; $hasAdminDefaults = $defaults['account_sid'] !== '' && $defaults['whatsapp_number'] !== ''; @endphp
@if (!$isConnected) {{-- Empty / not-yet-connected state ──────────────────────────── --}}
{{ __('Twilio · WhatsApp') }}

{{ __('Connect your Twilio account') }}

{{ __('Paste your Twilio Account SID, Auth Token, and the WhatsApp From number Twilio assigned. Use the Sandbox while testing, then switch to a paid Twilio number when you go live.') }}

@if ($hasAdminDefaults)
{{ __('Your platform admin has shared default Twilio credentials. Leave the fields below blank to use them, or paste workspace-specific creds to override.') }}
@endif
@csrf
@error('account_sid')
{{ $message }}
@enderror @error('from_number')
{{ $message }}
@enderror
{{-- /.p-5 body wrapper --}}
{{-- /card --}} @else {{-- Connected — show the account card with disconnect + rotate options. --}}
{{ __('Workspace · Twilio account') }} {{ $sandbox ? __('Sandbox') : __('Production') }} {{ __('connected') }}
@csrf
{{ __('From number') }}
{{ $tw->phone_number ?: '—' }}
{{ __('Account SID') }}
{{ $creds['account_sid'] ? substr($creds['account_sid'], 0, 8) . '…' . substr($creds['account_sid'], -4) : '—' }}
{{ __('Connected at') }}
{{ optional($tw->connected_at)->diffForHumans() ?: '—' }}

{{ __('All broadcasts, campaigns, scheduled sends, auto-replies, and team-inbox replies on this workspace use this Twilio account. Inbound messages from your customers will be received via the Twilio webhook configured in your Twilio console.') }}

@endif