{{-- Stores\Show — real settings page (Phase 3). Tabbed layout, URL-bound active tab. Per-section save buttons. Agents can view every tab; save controls render only for owner/admin (the server-side `Gate::authorize('manageStores')` is the authoritative line of defence). Settings-missing branch: if `$store->settings` is null (should never happen — Phase 1 invariant), render a defensive error panel and skip all forms. No create-on-read. --}}
@php $store = $this->store; @endphp {{-- Back link --}}
← {{ __('Back to stores') }}
@if ($store === null)
{{ __('Store not available in this workspace.') }}
@else {{-- Header --}}
{{ $store->name }} {{ $store->status }}
{{ $store->slug }}
{{-- Settings-missing defensive branch (Phase 1 invariant says this never triggers, but if it ever does we don't want to render forms backed by `null`). --}} @if ($store->settings === null)
{{ __('Store settings record is missing') }}
{{ __('This store has no associated store_settings row. Save actions are disabled until an operator repairs it. Contact engineering — every store should have settings created automatically.') }}
@else {{-- Tab bar --}} @php $tabs = [ 'general' => __('General'), 'sla' => __('SLA & support'), 'self-service' => __('Customer self-service'), 'links' => __('Links'), 'integrations' => __('Integrations'), 'email-addresses' => __('Email addresses'), ]; $tabBase = 'px-3 py-2 text-sm font-medium border-b-2 -mb-px transition'; $tabActive = 'border-zinc-900 text-zinc-900 dark:border-zinc-100 dark:text-zinc-100'; $tabIdle = 'border-transparent text-zinc-500 hover:text-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-200'; @endphp
@foreach ($tabs as $tabKey => $tabLabel) @endforeach
{{-- ============ GENERAL ============ --}} @if ($activeTab === 'general')
{{ __('General') }} {{ __('Public-facing store identity. The slug appears in URLs and routing rules.') }}
@if ($this->canManage)
{{ __('Save general') }}
@endif
@endif {{-- ============ SLA ============ --}} @if ($activeTab === 'sla')
{{ __('SLA & support') }} {{ __('Numeric SLA in working days. Used by future SLA-breach detection and WISMO automation.') }}
@if ($this->canManage)
{{ __('Save SLA') }}
@endif
@endif {{-- ============ SELF-SERVICE ============ --}} @if ($activeTab === 'self-service')
{{ __('Customer self-service') }} {{ __('Decide how customers cancel orders or edit delivery addresses. ClearDesk-mode requires configured Shopify + Helm integrations.') }}
{{-- Cancel order --}}
{{ __('Disabled') }} {{ __('External') }} {{ __('ClearDesk') }} @if ($cancelOrderMode === \App\Enums\CancelOrderMode::External->value) @endif
{{-- Edit address --}}
{{ __('Disabled') }} {{ __('External') }} {{ __('ClearDesk') }} @if ($editAddressMode === \App\Enums\EditAddressMode::External->value) @endif
@if ( $cancelOrderMode === \App\Enums\CancelOrderMode::ClearDesk->value || $editAddressMode === \App\Enums\EditAddressMode::ClearDesk->value )
{{ __('ClearDesk mode runs the action through Helm and Shopify. It will refuse to save unless both integrations are configured.') }}
@endif @if ($this->canManage)
{{ __('Save self-service') }}
@endif
@endif {{-- ============ LINKS ============ --}} @if ($activeTab === 'links') @php $tenantAccount = app(\App\Support\CurrentAccount::class)->get(); $supportLink = $tenantAccount !== null ? url('/self-help/'.$tenantAccount->slug.'/'.$store->slug) : null; @endphp
{{-- ============ CUSTOMER SUPPORT LINK ============ Canonical public URL for this store. The operator drops this into order-confirmation emails / dispatch emails / order page CTAs — it's the ONLY way a customer reaches their self-help portal. --}}
{{ __('Customer support link') }} {{ __('Drop this into your order confirmation + dispatch emails. It\'s the only URL customers should use to open self-help — there is no public store picker.') }} @if ($supportLink !== null) {{-- Plain HTML button with Alpine on a wrapping div so x-on attributes bind reliably (a Flux button can wrap the click handler in a way that prevents x-on from firing). Two inline spans toggle for a brief "Copied!" confirmation. --}}
{{ $supportLink }}
@endif
{{-- ============ EXTERNAL CUSTOMER-FACING LINKS ============ --}}
{{ __('External help links') }} {{ __('Optional. URLs that point to your existing returns portal / FAQ on other systems.') }}
@if ($this->canManage)
{{ __('Save links') }}
@endif
@endif {{-- ============ INTEGRATIONS (display-only) ============ --}} @if ($activeTab === 'integrations') @php $summary = $this->integrationsSummary; @endphp
{{ __('Integrations') }} {{ __('Display only. CRUD lands in a later iteration.') }}
{{-- "Manage integrations" is the future `/integrations` page. Render disabled until that route exists. --}} {{ __('Manage integrations (coming soon)') }}
@php $statusColor = fn (string $s): string => match ($s) { 'configured' => 'lime', 'error' => 'red', 'disabled' => 'amber', default => 'zinc', }; $statusLabel = fn (string $s): string => match ($s) { 'configured' => __('Configured'), 'error' => __('Error'), 'disabled' => __('Disabled'), default => __('Missing'), }; @endphp
{{ __('Shopify · account-level') }}
{{ $statusLabel($summary['shopify_account']) }}
{{ __('Shopify · this store') }}
{{ $statusLabel($summary['shopify_store']) }}
{{ __('Helm · account-level') }}
{{ $statusLabel($summary['helm_account']) }}
{{ __('Helm · this store') }}
{{ $statusLabel($summary['helm_store']) }}
{{ __('Custom integrations') }}
{{ trans_choice('{0} None|{1} :n enabled custom integration|[2,*] :n enabled custom integrations', $summary['custom_count'], ['n' => $summary['custom_count']]) }}
@endif {{-- ============ EMAIL ADDRESSES (read-only) ============ --}} @if ($activeTab === 'email-addresses')
{{ __('Email addresses') }} {{ __('Addresses linked to this store. Set a default sender or unlink an address here, or open Channels for full management.') }}
{{ __('Manage in Channels') }}
{{-- Current default sender callout. Renders only when a pointer is set; otherwise the empty- state below covers it. --}} @php $defaultRow = $this->defaultEmailAddressRow; @endphp @if ($defaultRow !== null)
{{ __('Current default sender') }}
{{ $defaultRow['address'] }} {{ __($defaultRow['status_label']) }}
@if ($this->canManage) {{ __('Clear') }} @endif
@endif @php $linked = $this->linkedEmailAddresses; @endphp @if ($linked->isEmpty())
{{ __('No email addresses linked yet') }}

{{ __('Inbound email won\'t route to this store and outbound replies will use the platform default sender. Add an address in Channels to wire this store up.') }}

@else @endif

{{ __('Outbound replies from this store use the configured default sender. If none is set or the default isn\'t ready, replies fall back to the platform default.') }}

@endif @endif @endif