@extends('layouts.admin')

@section('title', 'Edit Gejala')

@section('content')

<div class="card shadow-sm">

    <div class="card-body">

        {{-- ALERT ERROR --}}
        @if($errors->any())

            <div class="alert alert-danger">

                <ul class="mb-0">

                    @foreach($errors->all() as $error)

                        <li>{{ $error }}</li>

                    @endforeach

                </ul>

            </div>

        @endif

        {{-- ALERT VALIDASI MB MD --}}
        @if(session('error'))

            <div class="alert alert-warning">

                {{ session('error') }}

            </div>

        @endif

        <form action="{{ route('gejala.update', $gejala->id) }}" method="POST">

            @csrf
            @method('PUT')

            <!-- KODE -->
            <div class="mb-3">

                <label class="form-label">

                    Kode Gejala

                </label>

                <input
                    type="text"
                    name="kode"
                    value="{{ $gejala->kode }}"
                    class="form-control"
                    readonly>

            </div>

            <!-- NAMA -->
            <div class="mb-3">

                <label class="form-label">

                    Nama Gejala

                </label>

                <input
                    type="text"
                    name="nama"
                    value="{{ old('nama', $gejala->nama) }}"
                    class="form-control"
                    placeholder="Masukkan nama gejala"
                    required>

            </div>

            <!-- MB -->
            <div class="mb-3">

                <label class="form-label">

                    MB (Measure of Belief)

                </label>

                <input
                    type="number"
                    name="mb"
                    class="form-control"
                    step="0.01"
                    min="0"
                    max="1"
                    value="{{ old('mb', $gejala->mb) }}"
                    required>

                <small class="text-muted">

                    Nilai MB berada pada rentang 0 sampai 1.

                </small>

            </div>

            <!-- MD -->
            <div class="mb-3">

                <label class="form-label">

                    MD (Measure of Disbelief)

                </label>

                <input
                    type="number"
                    name="md"
                    class="form-control"
                    step="0.01"
                    min="0"
                    max="1"
                    value="{{ old('md', $gejala->md) }}"
                    required>

                <small class="text-muted">

                    Nilai MD tidak boleh lebih besar dari MB.

                </small>

            </div>

            <hr>

            <!-- BUTTON -->
            <div class="d-flex justify-content-between">

                <a href="{{ route('gejala.index') }}"
                   class="btn btn-secondary">

                    ← Kembali

                </a>

                <button
                    type="submit"
                    class="btn btn-success">

                    Update Gejala

                </button>

            </div>

        </form>

    </div>

</div>

@endsection