@extends('layouts.main')

@section('title', $title = 'Tambah Data Kriteria')

@section('content')
<div class="container pt-5 mb-5">
    <div class="row gy-4 shadow mb-4 bg-body-tertiary rounded">
        <h3 class="mb-4">Tambah Data Kriteria</h3>
    </div>
    <div class="row gy-4">
        <div class="pt-3 card">
            <div class="row">
                <div class="col-sm-12 pb-3 pt-3">
                    <a href="{{ route('kriteria.index') }}" class="font-sm btn btn-warning text-white"><i class='bx bx-chevron-left'></i> Kembali</a>
                </div>
            </div>
            <form action="{{ route('kriteria.store') }}" method="POST">
                @csrf
                <div class="row">
                    <div class="form-group">
                        <label for="kode">Kode</label>
                        <input type="text" class="form-control @error('kode') is-invalid @enderror" id="kode" name="kode" value="{{ old('kode') }}">
                        @error('kode')
                            <span class="invalid-feedback" role="alert">
                                {{ $message }}
                            </span>
                        @enderror
                    </div>
                    <div class="form-group">
                        <label for="nama">Nama</label>
                        <input type="text" class="form-control @error('nama') is-invalid @enderror" id="nama" name="nama" value="{{ old('nama') }}">
                        @error('nama')
                            <span class="invalid-feedback" role="alert">
                                {{ $message }}
                            </span>
                        @enderror
                    </div>
                    <div class="form-group">
                        <label for="tipe_kriteria_id">Tipe Kriteria</label>
                        <select class="form-select @error('tipe_kriteria_id') is-invalid @enderror" name="tipe_kriteria_id" id="tipe_kriteria_id">
                            @foreach ($tipeKriterias as $tipeKriteria)
                                <option value="{{ $tipeKriteria->id }}" {{ old('tipe_kriteria_id') == $tipeKriteria->id ? 'selected' : '' }}>
                                    {{ $tipeKriteria->nama }}
                                </option>
                            @endforeach
                        </select>
                        @error('tipe_kriteria_id')
                            <span class="invalid-feedback" role="alert">
                                {{ $message }}
                            </span>
                        @enderror
                    </div>                    
                    <div class="form-group">
                        <label for="bobot">Bobot</label>
                        <input type="text" class="form-control @error('bobot') is-invalid @enderror" name="bobot" id="bobot" value="{{ old('bobot') }}">
                        @error('bobot')
                            <span class="invalid-feedback" role="alert">
                                {{ $message }}
                            </span>
                        @enderror
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="text-end"> <!-- Menambahkan kelas text-end di sini -->
                        <button type="submit" class="btn btn-success"><i class='bx bx-save'></i>
                            Simpan</button>
                        <a href="{{ route('kriteria.index') }}" class="btn btn-danger"><i class='bx bx-x'></i>
                            Batal</a>
                    </div>
                </div>                
            </form>
        </div>
    </div>
</div>
@endsection
