@extends('layouts.app')

@section('page_title', 'Edit Station')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">{{ __('Edit Station') }}</div>
                    <div class="card-body">
                        @if (session('success'))
                            <div class="alert alert-success">{{ session('success') }}</div>
                        @endif
                        @if ($errors->any())
                            <div class="alert alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif
                        <form method="POST" action="{{ route('stations.update', $station['id']) }}">
                            @csrf
                            @method('PUT')
                            <div class="mb-3">
                                <label for="station_code" class="form-label">{{ __('Station Code') }}</label>
                                <input type="text" class="form-control" id="station_code" name="station_code" value="{{ old('station_code', $station['station_code']) }}" required>
                            </div>
                            <div class="mb-3">
                                <label for="station_name" class="form-label">{{ __('Station Name') }}</label>
                                <input type="text" class="form-control" id="station_name" name="station_name" value="{{ old('station_name', $station['station_name']) }}" required>
                            </div>
                            <div class="mb-3">
                                <label for="branch_name" class="form-label">{{ __('Branch Name') }}</label>
                                <input type="text" class="form-control" id="branch_name" name="branch_name" value="{{ old('branch_name', $station['branch_name']) }}" required>
                            </div>
                            <div class="d-flex justify-content-end">
                                <a href="{{ route('station-management') }}" class="btn btn-secondary me-2">{{ __('Cancel') }}</a>
                                <button type="submit" class="btn btn-primary">{{ __('Update Station') }}</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection