@extends('layouts.appmin')

@section('content')
<div class="container">
    <h3 class="mb-4">Senarai Pengumuman</h3>
    <a href="{{ route('pengumuman.create') }}" class="btn btn-success mb-3">+ Tambah Pengumuman</a>

    @if(session('success'))
        <div class="alert alert-success">{{ session('success') }}</div>
    @endif

    <ul class="list-group">
        @foreach ($pengumumen as $item)
            <li class="list-group-item d-flex justify-content-between align-items-start">
                <div class="ms-2 me-auto">
                    <div class="fw-bold">{{ $item->keterangan }}</div>
                    <small>Papar: {{ $item->tarikh_mula_papar }} hingga {{ $item->tarikh_tamat_papar }}</small>
                </div>
                <div>
                    <a href="{{ route('pengumuman.edit', $item->id) }}" class="btn btn-sm btn-primary">Edit</a>
                    <form action="{{ route('pengumuman.destroy', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Padam pengumuman ini?')">
                        @csrf
                        @method('DELETE')
                        <button class="btn btn-sm btn-danger">Padam</button>
                    </form>
                </div>
            </li>
        @endforeach
    </ul>
</div>
@endsection
