@extends('layouts.app')

@section('content')
<div class="breadcrumbbar">
    <div class="row align-items-center">
        <div class="col-md-8 col-lg-8">
            <h4 class="page-title">Edit Agent</h4>
            <div class="breadcrumb-list">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Home</a></li>
                    <li class="breadcrumb-item"><a href="{{ route('agents.index') }}">Agents</a></li>
                    <li class="breadcrumb-item active" aria-current="page">Edit Agent</li>
                </ol>
            </div>
        </div>
    </div>          
</div>
<div class="row">
    <div class="col-lg-6">
        <div class="card m-b-30">
            <div class="card-header">
                <h5 class="card-title mb-0">Agent Details</h5>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ route('agents.update', $agent) }}">
                    @csrf
                    @method('PUT')
                    <div class="mb-3">
                        <label class="form-label" for="name">Name</label>
                        <input class="form-control" id="name" name="name" placeholder="Agent Name" value="{{ old('name', $agent->name) }}" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label" for="country">Currency</label>
                        <select class="form-select" id="country" name="country">
                            <option value="">Select currency</option>
                            @foreach($currencies as $currency)
                                <option value="{{ $currency->code }}" @selected(old('country', $agent->country) == $currency->code)>
                                    {{ $currency->code }} - {{ $currency->name }}
                                </option>
                            @endforeach
                        </select>
                    </div>
                    <div class="d-flex gap-2">
                        <button class="btn btn-primary" type="submit">Update Agent</button>
                        <a href="{{ route('agents.index') }}" class="btn btn-outline-secondary">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
