@extends('menu/main')
@section('konten-update-menu')
<h6 class="text-dark">Form Update Menu</h6>
<!-- component -->
@include('flash-message')
<script>
setTimeout(function() { 
  var flashMessage = document.querySelector('.alert'); 
   if (flashMessage) { flashMessage.style.transition = 'opacity 1s ease'; flashMessage.style.opacity = 0; setTimeout(function() { flashMessage.remove(); }, 1000); 
   } }, 1500); </script>
<div class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4 flex flex-col my-2">
<form action="{{ route('simpan-update-menu',['id' => $dataUpdateMenu->id]) }}" method="post" enctype="multipart/form-data">
    @csrf
  <div class="-mx-3 md:flex mb-6">
    <div class="md:w-1/2 px-3 mb-6 md:mb-0">
        <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-first-name">
            Kategory
        </label>
        <select class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-red rounded py-2 px-4" name="for_kategory" id="for_kategory">
            <option value="" selected>Pilih Kategory</option>
            <option value="Makanan" {{ old('for_kategory', $dataUpdateMenu->id_kategory) == 'Makanan' ? 'selected' : '' }}>Makanan</option>
            <option value="Minuman" {{ old('for_kategory', $dataUpdateMenu->id_kategory) == 'Minuman' ? 'selected' : '' }}>Minuman</option>
        </select>
        @if ($errors->has('for_kategory'))
        <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_kategory')}}</div>
        @endif
    </div>
    
    <div class="md:w-1/2 px-3">
      <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-last-name">
        Nama
      </label>
      <input name="for_nama_makanan" id="for_nama_makanan" value="{{ old('for_nama_makanan',$dataUpdateMenu->nama) }}" class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-grey-lighter rounded py-2 px-4" id="grid-last-name" type="text" placeholder="Input nama makanan / minuman">
      @if ($errors->has('for_nama_makanan'))
      <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_nama_makanan')}}</div>
    @endif
    </div>
  </div>
  <div class="-mx-3 md:flex mb-2">
    <div class="md:w-1/2 px-3 mb-6 md:mb-0">
      <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-city">
        Harga
      </label>
      <input name="for_harga" id="for_harga" value="{{ old('for_harga',$dataUpdateMenu->harga) }}" class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-grey-lighter rounded py-2 px-4" id="grid-city" type="number" placeholder="Harga makanan / minuman">
      @if ($errors->has('for_harga'))
      <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_harga')}}</div>
      @endif
    </div>
    <div class="md:w-1/2 px-3 mb-6 md:mb-0">
        <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-city">
            Jenis Menu
        </label>
        <select class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-red rounded py-2 px-4" name="for_jenis_menu" id="for_jenis_menu">
            <option value="" selected>Pilih Jenis Menu</option>
            <option value="Menu Paket" {{ old('for_jenis_menu', $dataUpdateMenu->jenis_menu) == 'Menu Paket' ? 'selected' : '' }}>Menu Paket</option>
            <option value="Menu Satuan" {{ old('for_jenis_menu', $dataUpdateMenu->jenis_menu) == 'Menu Satuan' ? 'selected' : '' }}>Menu Satuan</option>
            <option value="Menu Paket Ngumpul" {{ old('for_jenis_menu', $dataUpdateMenu->jenis_menu) == 'Menu Paket Ngumpul' ? 'selected' : '' }}>Menu Paket Ngumpul</option>
        </select>
        @if ($errors->has('for_jenis_menu'))
        <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_jenis_menu')}}</div>
        @endif
    </div>
    
    <div class="md:w-1/2 px-3 mb-6 md:mb-0">
      <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-city">
        Jenis Paket
      </label>
      <select class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-red rounded py-2 px-4" name="for_jenis_paket" id="for_jenis_paket">
        <option value="" selected>Pilih Jenis Paket</option>
        <option value="Paket 1" {{ old('for_jenis_paket',$dataUpdateMenu->jenis_paket) == 'Paket 1' ? 'selected' : '' }}>Paket 1</option>
        <option value="Paket 2" {{ old('for_jenis_paket',$dataUpdateMenu->jenis_paket) == 'Paket 2' ? 'selected' : '' }}>Paket 2</option>
        <option value="Paket 3" {{ old('for_jenis_paket',$dataUpdateMenu->jenis_paket) == 'Paket 3' ? 'selected' : '' }}>Paket 3</option>
    </select>
      @if ($errors->has('for_harga'))
      <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_harga')}}</div>
      @endif
    </div>
    <div class="md:w-1/2 px-3 mb-6 md:mb-0">
        <label class="block uppercase tracking-wide text-grey-darker text-xs font-bold mb-2" for="grid-city">
            Images
        </label>
        
        <!-- Tampilkan gambar yang telah diunggah sebelumnya, jika ada -->
        @if($dataUpdateMenu->img)
            <div class="mb-4">
                <img src="{{ asset('storage/gambar-menu/' . $dataUpdateMenu->img) }}" alt="Current Image" class="w-32 h-32 object-cover">
            </div>
        @endif
        
        <input name="for_img" id="for_img" class="appearance-none block w-full bg-grey-lighter text-grey-darker border border-grey-lighter rounded py-2 px-4" type="file">
        
        @if ($errors->has('for_img'))
            <div style="background-color: red;" class="badge text-bg-danger">{{$errors->first('for_img')}}</div>
        @endif
    </div>
    
  </div>
  <button class="btn btn-success m-2 w-20">Simpan</button>
</form>
</div>

@endsection
