@extends('Dashboard.layouts.main')

@section('title', 'Tambah Keluhan Baru')

@section('content')
<div class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="page-title-box">
                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                            <li class="breadcrumb-item"><a href="{{ route('complaints.index') }}">Keluhan</a></li>
                            <li class="breadcrumb-item active">Tambah Baru</li>
                        </ol>
                    </div>
                    <h4 class="page-title">Tambah Keluhan Baru</h4>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <form action="{{ route('complaints.store') }}" method="POST">
                            @csrf
                            
                            @if ($errors->any())
                            <div class="alert alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                            @endif

                            <div class="form-group">
                                <label for="jenis_layanan">Jenis Layanan <span class="text-danger">*</span></label>
                                <select class="form-control @error('jenis_layanan') is-invalid @enderror" id="jenis_layanan" name="jenis_layanan" required>
                                    <option value="">Pilih Jenis Layanan</option>
                                    <option value="Pengujian Kualitas Air" {{ old('jenis_layanan') == 'Pengujian Kualitas Air' ? 'selected' : '' }}>Pengujian Kualitas Air</option>
                                    <option value="Pengambilan Contoh Uji" {{ old('jenis_layanan') == 'Pengambilan Contoh Uji' ? 'selected' : '' }}>Pengambilan Contoh Uji</option>
                                </select>
                                @error('jenis_layanan')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="tanggal_keluhan">Tanggal Kejadian <span class="text-danger">*</span></label>
                                <input type="date" class="form-control @error('tanggal_keluhan') is-invalid @enderror" id="tanggal_keluhan" name="tanggal_keluhan" value="{{ old('tanggal_keluhan') }}" required>
                                @error('tanggal_keluhan')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="uraian_keluhan">Uraian Keluhan <span class="text-danger">*</span></label>
                                <textarea class="form-control @error('uraian_keluhan') is-invalid @enderror" id="uraian_keluhan" name="uraian_keluhan" rows="4" required>{{ old('uraian_keluhan') }}</textarea>
                                <small class="form-text text-muted">Jelaskan keluhan Anda secara detail</small>
                                @error('uraian_keluhan')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="saran">Saran <span class="text-danger">*</span></label>
                                <textarea class="form-control @error('saran') is-invalid @enderror" id="saran" name="saran" rows="4" required>{{ old('saran') }}</textarea>
                                <small class="form-text text-muted">Berikan saran atau masukan untuk perbaikan layanan</small>
                                @error('saran')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="mt-3 text-right">
                                <a href="{{ route('complaints.index') }}" class="btn btn-secondary mr-2">Batal</a>
                                <button type="submit" class="btn btn-primary">Kirim Keluhan</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection 