@extends('layouts.app')

@section('title', 'Edit Announcement | Institution Axis')

@section('sidebar-menu')
    @include('schooladmin.partials.sidebar')
@endsection

@section('breadcrumb')
    <span><a href="{{ route('schooladmin.dashboard') }}">Home</a></span> / <span><a href="{{ route('schooladmin.communication.index') }}">Communication</a></span> / <span><a href="{{ route('schooladmin.communication.announcements.index') }}">Announcements</a></span> / <span class="active-page">Edit Announcement</span>
@endsection

@section('content')
<div class="row justify-content-center">
    <div class="col-lg-8">
        <div class="card shadow-sm border-0 rounded-4">
            <div class="card-header bg-white">
                <h5 class="mb-0"><i class="fas fa-edit me-2 text-primary"></i>Update Announcement</h5>
            </div>
            <div class="card-body">
                <form action="{{ route('schooladmin.communication.announcements.update', $announcement) }}" method="POST">
                    @csrf
                    @method('PUT')
                    <div class="mb-3">
                        <label for="title" class="form-label">Announcement Title</label>
                        <input type="text" name="title" id="title" class="form-control" value="{{ $announcement->title }}" required>
                    </div>

                    <div class="mb-3">
                        <label for="target_role" class="form-label">Target Audience</label>
                        <select name="target_role" id="target_role" class="form-select" required>
                            <option value="all" {{ $announcement->target_role == 'all' ? 'selected' : '' }}>Everyone (Public)</option>
                            <option value="teachers" {{ $announcement->target_role == 'teachers' ? 'selected' : '' }}>Teachers Only</option>
                            <option value="parents" {{ $announcement->target_role == 'parents' ? 'selected' : '' }}>Parents Only</option>
                            <option value="students" {{ $announcement->target_role == 'students' ? 'selected' : '' }}>Students Only</option>
                        </select>
                    </div>

                    <div class="mb-3">
                        <label for="content" class="form-label">Announcement Content</label>
                        <textarea name="content" id="content" rows="6" class="form-control" required>{{ $announcement->content }}</textarea>
                    </div>

                    <div class="d-flex justify-content-end gap-3 mt-4">
                        <a href="{{ route('schooladmin.communication.announcements.index') }}" class="btn btn-light px-4">Cancel</a>
                        <button type="submit" class="btn btn-primary px-5 shadow-sm">Update Announcement</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
