@extends('layout.app')
@section('content')
    <form action="{{ route('voice-gateway.update', $gateway->id) }}" method="POST">
        @method('put')
        @csrf
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="form-group col-md-6">
                        <label for="name" class="block text-sm font-medium text-gray-700">
                            Name <span class="text-danger">*</span>
                        </label>
                        <input type="text" name="name" id="name" value="{{ $gateway->name }}"
                            class="form-control" placeholder="Voice Gateway Name" autocomplete="off" required>
                        @error('name')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-6">
                        <label for="caller_id" class="block text-sm font-medium text-gray-700">
                            Caller ID (DID) <span class="text-danger">*</span>
                        </label>
                        <input type="text" name="caller_id" id="caller_id" value="{{ $gateway->caller_id }}"
                            class="form-control" placeholder="096xxxxxxxx" autocomplete="off" required>
                        @error('caller_id')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                        <small class="form-text text-muted">The DID from which call will be initiated</small>
                    </div>

                    <div class="form-group col-md-6">
                        <label for="retry_count" class="block text-sm font-medium text-gray-700">
                            Retry Count <span class="text-danger">*</span>
                        </label>
                        <input type="number" name="retry_count" id="retry_count" value="{{ $gateway->retry_count }}"
                            class="form-control" placeholder="0" min="0" max="5" required>
                        @error('retry_count')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                        <small class="form-text text-muted">Number of retry attempts (0-5)</small>
                    </div>

                    <div class="form-group col-md-6">
                        <label for="username" class="block text-sm font-medium text-gray-700">
                            Username
                        </label>
                        <input type="text" name="username" id="username" value="{{ $gateway->username }}"
                            class="form-control" placeholder="Username" autocomplete="off">
                        @error('username')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-6">
                        <label for="password" class="block text-sm font-medium text-gray-700">
                            Password
                        </label>
                        <input type="text" name="password" id="password" value="{{ $gateway->password }}"
                            class="form-control" placeholder="Password" autocomplete="off">
                        @error('password')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-6">
                        <label for="api_key" class="block text-sm font-medium text-gray-700">
                            API Key
                        </label>
                        <input type="text" name="api_key" id="api_key" value="{{ $gateway->api_key }}"
                            class="form-control" placeholder="API Key" autocomplete="off">
                        @error('api_key')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-12">
                        <label for="api_url" class="block text-sm font-medium text-gray-700">
                            API URL <span class="text-danger">*</span>
                        </label>
                        <input type="text" name="api_url" id="api_url" class="form-control"
                            placeholder="http://example.com/api/do_blast" value="{{ $gateway->api_url }}" required>
                        @error('api_url')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-12">
                        <label for="report_url" class="block text-sm font-medium text-gray-700">
                            Report URL
                        </label>
                        <input type="text" name="report_url" id="report_url" class="form-control"
                            placeholder="http://example.com/api/get_report" value="{{ $gateway->report_url }}">
                        @error('report_url')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>

                    <div class="form-group col-md-6">
                        <label for="status" class="block text-sm font-medium text-gray-700">
                            Status
                        </label>
                        <select name="status" id="status" class="form-control select2" required>
                            <option value="">Select One</option>
                            <option value="enable" {{ $gateway->status == 'enable' ? 'selected' : '' }}>Enable</option>
                            <option value="disable" {{ $gateway->status == 'disable' ? 'selected' : '' }}>Disable</option>
                        </select>
                        @error('status')
                            <div class="alert alert-danger mt-1">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary float-right">Update</button>
                </div>
            </div>
        </div>
    </form>
@endsection

