@extends('layouts.admin')

@section('title', 'Edit Programme')

@section('content')
    <h3 class="mb-4">Edit Programme</h3>

    @if($errors->any())
        <div class="alert alert-danger">
            <ul class="mb-0">
                @foreach($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <form action="{{ route('admin.programmes.update', $programme->id) }}" method="POST">
        @csrf
        @method('PUT')

        <div class="mb-3">
            <label class="form-label">Programme Code</label>
            <input type="text" name="programme_code" class="form-control" value="{{ $programme->programme_code }}" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Description</label>
            <input type="text" name="description" class="form-control" value="{{ $programme->description }}" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Total Credits</label>
            <input type="number" name="total_credits" class="form-control" value="{{ $programme->total_credits }}" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Duration</label>
            <input type="text" name="duration" class="form-control" value="{{ $programme->duration }}" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Attendance Mode</label>
            <input type="text" name="attendance_mode" class="form-control" value="{{ $programme->attendance_mode }}" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Status</label>
            <select name="status" class="form-select" required>
                <option value="active" {{ $programme->status === 'active' ? 'selected' : '' }}>Active</option>
                <option value="inactive" {{ $programme->status === 'inactive' ? 'selected' : '' }}>Inactive</option>
            </select>
        </div>

        <button type="submit" class="btn btn-primary">Update Programme</button>
        <a href="{{ route('admin.programmes.index') }}" class="btn btn-secondary">Cancel</a>
    </form>
@endsection
