@extends('admin.template')

@section('title', 'Tanggapi Aduan TPS')

@section('content')
    <div class="content-wrapper">
        <div class="row">
            <div class="col-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">

                        <h4 class="card-title">Tanggapi Aduan TPS</h4>
                        <p class="card-description">
                            Form tanggapan admin terhadap aduan masyarakat
                        </p>

                        <form action="{{ route('admin.aduan.tanggapi', $aduan->id_aduan) }}" method="POST"
                            class="forms-sample">
                            @csrf

                            {{-- TPS --}}
                            <div class="form-group">
                                <label>TPS yang Diadukan</label>
                                <input type="text" class="form-control" value="{{ $aduan->lokasiTps->nama_tps ?? '-' }}"
                                    readonly>
                                <small class="text-muted">
                                    {{ $aduan->lokasiTps->alamat_tps ?? '' }}
                                </small>
                            </div>

                            {{-- Nama Pelapor --}}
                            <div class="form-group">
                                <label>Nama Pelapor</label>
                                <input type="text" class="form-control" value="{{ $aduan->nama_pelapor }}" readonly>
                            </div>

                            {{-- Alamat Pelapor --}}
                            <div class="form-group">
                                <label>Alamat Pelapor</label>
                                <input type="text" class="form-control" value="{{ $aduan->alamat_pelapor }}" readonly>
                            </div>

                            {{-- Isi Aduan --}}
                            <div class="form-group">
                                <label>Isi Aduan</label>
                                <textarea class="form-control" rows="4" readonly>{{ $aduan->isi_aduan }}</textarea>
                            </div>

                            {{-- Bukti Foto --}}
                            @if ($aduan->bukti_foto)
                                <div class="form-group">
                                    <label>Bukti Foto</label><br>
                                    <img src="{{ asset('assets/user/img/aduan/' . $aduan->bukti_foto) }}" alt="Bukti Aduan"
                                        class="border rounded img-fluid" style="max-height: 260px;">
                                </div>
                            @endif

                            {{-- Tanggapan Admin --}}
                            <div class="form-group">
                                <label>Tanggapan Admin</label>
                                <textarea name="tanggapan_admin" class="form-control @error('tanggapan_admin') is-invalid @enderror" rows="4"
                                    placeholder="Masukkan tanggapan admin...">{{ old('tanggapan_admin', $aduan->tanggapan_admin) }}</textarea>

                                @error('tanggapan_admin')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>


                            {{-- Tombol --}}
                            <button type="submit" class="mr-2 btn btn-primary">
                                Simpan Tanggapan
                            </button>
                            <a href="{{ route('admin.aduan.index') }}" class="btn btn-light">
                                Kembali
                            </a>

                        </form>

                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
