@if (session('status') || $errors->any()) @push('scripts') @endpush @endif
{{ __('Workspace') }} · {{ auth()->user()?->currentWorkspace?->name ?: __('Workspace') }}

@if ($isTrash ?? false) {{ __('Trash /') }} {{ __('deleted contacts') }} @else {{ __('Your') }} {{ __('contacts') }} @endif

@if ($isTrash ?? false) {{ __('Soft-deleted contacts kept safely in database. You can restore them anytime individually or in bulk.') }} @else {{ __('Manage people, groups, imports, and contact details from one operational view.') }} @endif

@if ($isTrash ?? false) ← {{ __('Back to contacts') }} @else {{ __('Deleted contacts') }} ({{ number_format($stats['trashed_total'] ?? 0) }}) {{-- Export ALL contacts in the current view (not just the 12 on-screen / selected rows). Submits #exportAllForm. --}} @endif
{{ __('Total contacts') }}
{{ number_format($stats['total_contacts']) }}
{{ __('in your workspace') }}
{{ __('Groups') }}
{{ number_format($stats['total_groups']) }}
{{ __('segments configured') }}
{{ __('Subscribed') }}
{{ number_format($stats['subscribed']) }}
{{ __('opted in') }}
{{ __('Unsubscribed') }}
{{ number_format($stats['unsubscribed']) }}
{{ __('opted out') }}
@if ($isTrash ?? false) ← {{ __('Back to all contacts') }} {{ __('Deleted contacts') }} {{ $contacts->total() }} @else {{ __('Deleted contacts') }} {{ number_format($stats['trashed_total'] ?? 0) }} @endif {{-- Bulk-action toolbar — shown only when one or more rows are selected. Gives the operator full control over the selection (export / add to group / remove from group / delete) instead of just delete. --}} {{-- Search + group filter. JS debounces the search box and submits this GET form so it queries EVERY contact (not just the 12 on the page). The group dropdown + the sidebar group list navigate to ?group=. --}}
{{-- Preserve the chosen page size when searching / changing group. --}}
{{-- Page size — the book can hit thousands of rows, so let the operator show more per page (and bulk-select far more than the default 12 at once). Its own GET form so it preserves the active search / group / tag filter without any JS. --}}
{{-- Hidden form for "Export" — a normal POST so the browser downloads the CSV. JS fills in the selected ids then submits. --}} {{-- "Export all" — full-book CSV honouring the ACTIVE group / tag / search filter (server-rendered, since those reload the page). `all=1` tells bulkExport to ignore the selection + paginate. --}} {{-- Select-all-matching — ticking the header checkbox only selects the rows ON THIS PAGE. This bar extends the selection to EVERY contact matching the current filter so "add all N to a group" is a single action. Only rendered when there is more than one page. --}} @if ($contacts->total() > $contacts->count()) @endif
@forelse ($contacts as $contact) @php $contactGroupIds = is_array($contact->contact_group) ? $contact->contact_group : []; $contactGroupModels = $groups->whereIn( 'id', array_map('intval', $contactGroupIds), ); $groupSlugs = $contactGroupModels ->pluck('id') ->map(fn($i) => 'g' . $i) ->implode(' '); $groupIdsCsv = implode(',', array_map('strval', $contactGroupIds)); $searchKey = strtolower( trim( ($contact->name ?? '') . ' ' . ($contact->email ?? '') . ' ' . ($contact->mobile ?? ''), ), ); $initials = \Illuminate\Support\Str::of($contact->name ?? '?') ->trim() ->limit(2, '') ->upper(); $avatarBg = ['#FFE9E4', '#E8F5E9', '#FFF6E0', '#F3E9FF', '#EEF4FF', '#FCE0D5'][ ($contact->id ?? 0) % 6 ]; @endphp {{-- Tags — filled colour pills, deliberately distinct from the outlined group chips beside them so the two never read as one list. Clicking a tag filters the table to it. --}} {{-- Which of the workspace's numbers this contact first messaged (stamped by RoutingEngine on the first inbound). --}} @empty @endforelse
{{ __('Name') }} {{ __('Groups') }} {{ __('Tags') }} {{ __('Email') }} {{ __('Mobile') }} {{ __('On number') }} {{ __('Memo') }} {{ __('Action') }}
{{ $initials }}
{{ $contact->name }}
{{ $contact->language ?? '' }}
{{-- Per-contact attributes (custom_attributes) — e.g. values imported from a CSV. status/source are surfaced elsewhere, so they're excluded here to keep this to real attributes. --}} @php $allAttrs = is_array($contact->custom_attributes ?? null) ? $contact->custom_attributes : []; // Raw source_* keys are hidden from the generic attribute chips — // the number is surfaced in its own "On number" column instead. $rowAttrs = collect($allAttrs) ->reject(fn ($v, $k) => in_array(strtolower((string) $k), ['status', 'source', 'source_number', 'source_device_id', 'source_provider'], true) || !is_scalar($v) || (string) $v === '') ->take(4); @endphp @if ($rowAttrs->isNotEmpty())
@foreach ($rowAttrs as $ak => $av) {{ \Illuminate\Support\Str::of((string) $ak)->replace('_', ' ')->title() }}: {{ \Illuminate\Support\Str::limit((string) $av, 18) }} @endforeach
@endif
@foreach ($contactGroupModels as $g) {{ $g->user_group }} @endforeach
@forelse ($contact->tags as $t) @php $tagColor = $t->color ?: 'var(--color-wa-deep)'; @endphp {{ $t->name }} @empty — @endforelse
{{ $contact->email }} @php // Normalise to ONE display format for every row. Numbers are // stored inconsistently — some plain digits, some with +/spaces, // some with a separate country_code — which made mask_phone show // "xxxxxxxx0909" on one row and "+xx xx xxxx7417" on the next. // Strip to digits, prepend the country code only when it isn't // already inline, then prefix a single "+". $ccDigits = preg_replace('/\D+/', '', (string) ($contact->country_code ?? '')); $numDigits = preg_replace('/\D+/', '', (string) ($contact->mobile ?? '')); $fullDigits = ($ccDigits !== '' && !\Illuminate\Support\Str::startsWith($numDigits, $ccDigits)) ? $ccDigits . $numDigits : $numDigits; @endphp {{ $fullDigits === '' ? '—' : '+' . mask_phone($fullDigits) }} @php $srcNumber = trim((string) ($allAttrs['source_number'] ?? '')); @endphp @if ($srcNumber !== '') +{{ $srcNumber }} @else — @endif {{ $contact->msg }}
@if ($isTrash ?? false)
@csrf
@csrf @method('DELETE')
@else
@csrf @method('DELETE')
@endif
@include('user.partials.empty-state', [ 'message' => ($isTrash ?? false) ? __('No deleted contacts found in trash.') : __('No contacts match the current filters. Try clearing filters or add your first contact.'), 'resetHref' => url('/contacts'), 'actionButtonAttrs' => ($isTrash ?? false) ? '' : 'data-modal-open="contactModal"', 'actionLabel' => ($isTrash ?? false) ? null : __('Add contact'), ])
@include('user.partials.pagination', [ 'paginator' => $contacts, 'dataAttr' => 'data-contact-page', 'label' => 'contacts', ])
{{ __('Help - 01') }}
{{ __('What is a contact?') }}

{{ __('A person or customer record with phone, email, notes, language, and group membership used across messages.') }}

{{ __('Help - 02') }}
{{ __('How should I use groups?') }}

{{ __('Create groups for segments like VIPs, new signups, cart abandoners, or local audiences before sending campaigns.') }}

{{ __('Help - 03') }}
{{ __('How do I keep lists clean?') }}

{{ __('Remove invalid numbers, respect unsubscribes, and import only opted-in contacts with a clear source.') }}

@if ($isTrash ?? false) @endif {{-- After an AJAX contact edit, the row's cached data-* attributes feed the edit modal the next time it opens. Two of them — Display name and the subscription state — are not refreshed by the page script, so the modal showed the pre-save value until a full reload. Re-sync just those two from the save response here, on top of the existing update. --}} @push('scripts') @endpush