@extends('layouts.admin')
@section('style')
@parent
{{-- Tokens, faces and control styles are taken from the WhatsApp Flows Studio
design system (resources/js/wa-flows/preview.css) so this page reads as the
same product. That stylesheet is bundled into the flows JS and never loads
here, so the subset this page needs is inlined — no asset build required. --}}
@endsection
@section('content')
Channel Preferences
{{ $channel->name }}
@php
// A hidden tab must not hide the reason a save failed, so a failing tab opens.
$agentErr = $errors->has('agent_mode_timeout_hours');
$pacingErr = $errors->hasAny(['blast_chunk_size', 'blast_chunk_interval_minutes']);
// The Meta calls redirect back here, so their tab opens to show the result.
// They are their own requests, so they never collide with a validation error.
$setupKeys = ['wh_success', 'wh_error', 'reg_success', 'reg_error', 'msg_success', 'msg_error'];
$onSetup = collect($setupKeys)->contains(fn ($k) => session()->has($k))
|| $errors->hasAny(['test_to', 'test_body']);
// SMS fallback saves through its own form and comes back with ?tab=sms-fallback.
$onSms = ! $onSetup && (request('tab') === 'sms-fallback' || $errors->hasAny(['sms_fallback_enabled', 'sms_fallback_workflows.*']));
$onPacing = $pacingErr && ! $agentErr && ! $onSetup && ! $onSms;
$onAgent = ! $onPacing && ! $onSetup && ! $onSms;
// The Meta cards name the edge they call, so they need the account they
// call it on. Missing pieces render as placeholders rather than blanks.
$acct = $channel->waAccount;
$ver = config('whatsapp.graph_version');
@endphp
{{-- One form across both tabs: the route validates every field on each PUT,
so a tab with its own form would fail the other tab's rules. --}}
{{-- Kept out of the settings form: the Meta setup buttons target these by id,
so neither call carries the preference fields along with it. --}}