@extends('layouts.admin')

@section('title', 'Edit Communication Log')

@section('content')
<div class="container mx-auto px-4 py-6">
    <h1 class="text-2xl font-semibold mb-4">Edit Communication Log</h1>

    <div class="bg-white rounded-lg shadow-md p-6">
        <form action="{{ route('admin.marketing.communication-log.update', $log) }}" method="POST">
            @csrf
            @method('PUT')

            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div>
                    <label for="merchant_id" class="block text-sm font-medium text-gray-700">Merchant</label>
                    <select id="merchant_id" name="merchant_id" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                        @foreach($merchants as $merchant)
                            <option value="{{ $merchant->id }}" {{ $log->merchant_id == $merchant->id ? 'selected' : '' }}>{{ $merchant->name }}</option>
                        @endforeach
                    </select>
                </div>

                <div>
                    <label for="channel" class="block text-sm font-medium text-gray-700">Channel</label>
                    <input type="text" id="channel" name="channel" value="{{ $log->channel }}" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
                </div>

                <div>
                    <label for="direction" class="block text-sm font-medium text-gray-700">Direction</label>
                    <select id="direction" name="direction" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                        <option value="outbound" {{ $log->direction == 'outbound' ? 'selected' : '' }}>Outbound</option>
                        <option value="inbound" {{ $log->direction == 'inbound' ? 'selected' : '' }}>Inbound</option>
                    </select>
                </div>

                <div class="md:col-span-2">
                    <label for="summary" class="block text-sm font-medium text-gray-700">Summary</label>
                    <textarea id="summary" name="summary" rows="3" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">{{ $log->summary }}</textarea>
                </div>

                <div class="md:col-span-2">
                    <label for="notes" class="block text-sm font-medium text-gray-700">Notes</label>
                    <textarea id="notes" name="notes" rows="6" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">{{ $log->notes }}</textarea>
                </div>
            </div>

            <div class="mt-6 flex justify-end">
                <a href="{{ route('admin.marketing.communication-log') }}" class="bg-gray-200 text-gray-800 px-4 py-2 rounded-md mr-2">Cancel</a>
                <button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-md">Update Log</button>
            </div>
        </form>
    </div>
</div>
@endsection
