@extends('setting.nav') @section('title', 'Settings') @php // Human labels for the numeric flags stored on the users row. $isAdminUser = $user->auth_id == 0; $isGoogle = $user->account_type == 0; $usesServiceAccount = $user->is_service_account == 1; $connected = $user->is_login == '0'; $roleLabel = $isAdminUser ? 'Administrator' : ($user->is_department_head == 1 ? 'Department head' : 'Member'); $accessLabel = match ((string) $user->user_level) { '2' => 'Full access', '1' => 'Limited access', default => 'Sign-in disabled', }; $fullName = trim(($user->fname ?? '') . ' ' . ($user->lname ?? '')); $imapAvailable = function_exists('imap_open'); @endphp @section('styles') @endsection @section('content') @if (session('success')) @endif @if (session('error')) @endif {{-- Who you are signed in as. Repeated on every tab so the context never leaves. --}}
{{ mb_substr($fullName !== '' ? $fullName : $user->email, 0, 1) }}

{{ $fullName !== '' ? $fullName : 'Name not set' }}

{{ $user->email }}
{{ $roleLabel }} {{ $isGoogle ? 'Google Workspace' : 'Microsoft 365' }} {{ $accessLabel }} @if ($department) {{ $department->department_name }} @endif
{{ $connected ? 'Mailbox connected' : 'Mailbox needs attention' }}

Member since {{ optional($user->created_at)->format('d M Y') ?? '—' }}

{{-- ---------------------------------------------------------------- Profile --}}
Profile details Shown next to your activity across the app
@csrf {{-- Brings the user back to this panel if validation sends them back. --}}
@error('fname')
{{ $message }}
@enderror
@error('lname')
{{ $message }}
@enderror
@error('contact')
{{ $message }}
@enderror

Used when a teammate needs to reach you about an escalated mail.

This is the mailbox every stored message is filed under, so it cannot be changed here.

Discard
Account
Role
{{ $roleLabel }}
Access
{{ $accessLabel }}
Department
{{ $department->department_name ?? ($user->group_lable ?: 'Not assigned') }}
Provider
{{ $isGoogle ? 'Google Workspace' : 'Microsoft 365' }}
Account ID
#{{ $user->id }}
Created
{{ optional($user->created_at)->format('d M Y, H:i') ?? '—' }}

Role, access level and department are set by an administrator. Ask yours if any of these look wrong.

{{-- --------------------------------------------------------------- Security --}}
Change sign-in password The password you use on the login screen
@csrf
@error('current_password')
{{ $message }}
@enderror
@error('password')
{{ $message }}
@enderror

At least 6 characters.

How sign-in works
Two-step
One-time code by email, always on
Code validity
5 minutes
Codes sent to
{{ $user->email }}

Every sign-in sends a six-digit code to this mailbox, so a password on its own is not enough to get in.


{{-- ---------------------------------------------------------- Mailbox & sync --}}
Mailbox connection How EmailInsightAI reads this mailbox
Mailbox
{{ $user->email }}
Provider
@if ($isGoogle) Google Workspace @else Microsoft 365 @endif
Sync method
{{ $usesServiceAccount ? ($isGoogle ? 'Workspace service account' : 'Microsoft Graph app token') : 'IMAP with app password' }}
Last known state
{{ $connected ? 'Connected' : 'Not connected' }}

The test asks your provider for a token on this mailbox — the same check the dashboard runs when it loads.

Fetch preferences

Which senders count as important, and which domain is treated as internal, live on their own pages.

@if ($isGoogle)
Gmail app password Only needed for IMAP fetching
@if ($usesServiceAccount) @endif @unless ($imapAvailable) @endunless
@csrf
@error('app_email')
{{ $message }}
@enderror

Spaces are ignored, so you can paste it exactly as Google shows it.

Generate in Google

The stored password is never displayed again. Saving a new one replaces it and clears the connection warning.

@endif
{{-- ------------------------------------------------------------ AI settings --}}
AI instructions Business context for AI-written replies
{{-- Be accurate about reach. The prompt is read by MailController::generateReplyDraft() and prepended to the reply-draft request. The sentiment/category/action-required classifier does NOT read it: its live call sites pass no prompt, and the prompt text it does send is hardcoded. --}}
@csrf
@error('ai_prompt')
{{ $message }}
@enderror

Up to 200 characters. Plain instructions work best.

@error('keywords')
{{ $message }}
@enderror

Up to 25 characters — a short comma-separated list. Stored and read by the inbox counters and the daily summary, though nothing displays it on screen yet.

Filling in either field is enough.
Active & previous
@if ($prompt)
In use since {{ optional($prompt->created_at)->format('d M Y') }}
{{ $prompt->ai_prompt ?: '— no prompt text —' }} @if ($prompt->keywords)
{{ $prompt->keywords }}
@endif
@else

No prompt published yet — the classifier is running on its built-in rules.

@endif @if ($promptHistory->isNotEmpty())
@foreach ($promptHistory as $past)
Replaced · {{ optional($past->created_at)->format('d M Y') }}
{{ \Illuminate\Support\Str::limit($past->ai_prompt ?: $past->keywords, 90) }}
@endforeach
@endif
{{-- -------------------------------------------------------------- Workspace --}}
Workspace configuration
Internal domain
{{ $domain->domain_name ?? 'Not set' }} Change
Your department
{{ $department->department_name ?? ($user->group_lable ?: 'Not assigned') }}
Department head
{{ $user->is_department_head == 1 ? 'Yes — you lead this department' : 'No' }}
Managed by
{{ $isAdminUser ? 'This is an administrator account' : 'Administrator #' . $user->auth_id }}

The internal domain decides which senders are treated as colleagues rather than outside contacts.

Manage
@unless ($isAdminUser)

Department and account management is available to administrators.

@endunless
@csrf
@endsection @section('scripts') @endsection