@extends('Dashboard.layouts.main')

@section('title', 'Detail Keluhan')

@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">Detail</li>
                        </ol>
                    </div>
                    <h4 class="page-title">Detail Keluhan</h4>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="d-flex justify-content-between mb-4">
                                    <h4>Informasi Keluhan</h4>
                                    <div>
                                        @can('customer')
                                        <a href="{{ route('complaints.edit', $complaint->id) }}" class="btn btn-primary btn-sm mr-1">
                                            <i class="fe-edit"></i> Edit
                                        </a>
                                        <button type="button" class="btn btn-danger btn-sm" onclick="confirmDelete('{{ route('complaints.destroy', $complaint->id) }}')">
                                            <i class="fe-trash"></i> Hapus
                                        </button>
                                        @endcan
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header bg-light">
                                        <h5 class="card-title mb-0">Informasi Pengisi</h5>
                                    </div>
                                    <div class="card-body">
                                        <table class="table table-borderless">
                                            <tr>
                                                <th style="width: 30%;">Nama</th>
                                                <td>{{ $complaint->user->name }}</td>
                                            </tr>
                                            <tr>
                                                <th>Email</th>
                                                <td>{{ $complaint->user->email }}</td>
                                            </tr>
                                            @if($complaint->user->phone)
                                            <tr>
                                                <th>Telepon</th>
                                                <td>{{ $complaint->user->phone }}</td>
                                            </tr>
                                            @endif
                                            @if($complaint->user->business_name)
                                            <tr>
                                                <th>Nama Usaha</th>
                                                <td>{{ $complaint->user->business_name }}</td>
                                            </tr>
                                            @endif
                                            @if($complaint->user->business_address)
                                            <tr>
                                                <th>Alamat Usaha</th>
                                                <td>{{ $complaint->user->business_address }}</td>
                                            </tr>
                                            @endif
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header bg-light">
                                        <h5 class="card-title mb-0">Detail Keluhan</h5>
                                    </div>
                                    <div class="card-body">
                                        <table class="table table-borderless">
                                            <tr>
                                                <th style="width: 40%;">Jenis Layanan</th>
                                                <td>{{ $complaint->jenis_layanan }}</td>
                                            </tr>
                                            <tr>
                                                <th>Tanggal Keluhan</th>
                                                <td>{{ \Carbon\Carbon::parse($complaint->tanggal_keluhan)->format('d-m-Y') }}</td>
                                            </tr>
                                            <tr>
                                                <th>Dibuat Pada</th>
                                                <td>{{ $complaint->created_at->format('d-m-Y H:i:s') }}</td>
                                            </tr>
                                            <tr>
                                                <th>Diperbarui Pada</th>
                                                <td>{{ $complaint->updated_at->format('d-m-Y H:i:s') }}</td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row mt-3">
                            <div class="col-md-12">
                                <div class="card">
                                    <div class="card-header bg-light">
                                        <h5 class="card-title mb-0">Uraian Keluhan</h5>
                                    </div>
                                    <div class="card-body">
                                        <p>{{ $complaint->uraian_keluhan }}</p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row mt-3">
                            <div class="col-md-12">
                                <div class="card">
                                    <div class="card-header bg-light">
                                        <h5 class="card-title mb-0">Saran</h5>
                                    </div>
                                    <div class="card-body">
                                        <p>{{ $complaint->saran }}</p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row mt-4">
                            <div class="col-12 text-right">
                                <a href="{{ route('complaints.index') }}" class="btn btn-secondary">Kembali ke Daftar</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Sertakan Modal Konfirmasi Hapus -->
@include('layouts.delete-modal')
@endsection 