@extends('admin.template')

@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">Edit Kategori TPS</h4>
                        <p class="card-description">Form edit data kategori TPS</p>

                        <form action="{{ route('admin.kategori.update', $kategori->id_kategori_tps) }}" method="POST"
                            enctype="multipart/form-data">
                            @csrf
                            @method('PUT')

                            <div class="form-group">
                                <label>Nama Kategori</label>
                                <input type="text" name="nama_kategori" value="{{ $kategori->nama_kategori }}"
                                    class="form-control" required>
                            </div>

                            <div class="form-group">
                                <label>Kepanjangan Kategori</label>
                                <input type="text" name="kepanjangan_kategori" value="{{ $kategori->kepanjangan_kategori }}"
                                    class="form-control">
                            </div>

                            <div class="form-group">
                                <label>Deskripsi</label>
                                <textarea name="deskripsi" rows="8" class="form-control">{{ $kategori->deskripsi }}</textarea>
                            </div>

                            <div class="form-group">
                                <label>Foto Kategori</label>

                                <!-- INPUT FILE ASLI (HIDDEN - TEMPLATE) -->
                                <input type="file" name="foto_kategori" id="foto_kategori" class="file-upload-default"
                                    accept="image/*">

                                <!-- INPUT DISPLAY -->
                                <div class="input-group col-xs-12">
                                    <input type="text" class="form-control file-upload-info" disabled
                                        placeholder="Upload Foto">

                                    <span class="input-group-append">
                                        <button class="file-upload-browse btn btn-primary" type="button">
                                            Upload
                                        </button>
                                    </span>
                                </div>

                                <!-- PREVIEW FOTO LAMA -->
                                @if ($kategori->foto_kategori)
                                    <div class="mt-2">
                                        <img src="{{ asset('storage/' . $kategori->foto_kategori) }}" width="250"
                                            class="img-thumbnail">
                                    </div>
                                @endif
                            </div>


                            <button class="btn btn-primary">Simpan</button>
                            <a href="{{ route('admin.kategori.index') }}" class="btn btn-light">Batal</a>
                        </form>

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