@extends('layouts.master')
@section('title', 'Create Item')
@section('content')
    <div class="page-content">
        <nav class="page-breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="#">Master</a></li>
                <li class="breadcrumb-item"><a href="{{ route('admin.items.index') }}">Items</a></li>
                <li class="breadcrumb-item active" aria-current="page">Create Item</li>
            </ol>
        </nav>
        <div class="row">
            <div class="col-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">Item Form</h4>
                        <form class="custom-validation" action="{{ route('admin.items.store') }}" method="POST" enctype="multipart/form-data">
                            @csrf
                            @method('POST')
                            <div class="row">
                                <div class="col-md-12 col-lg-6">
                                    <div class="mb-3">
                                        <label class="form-label">Factor</label>
                                        <select name="factor_id" id="factor_id" class="form-select" required>
                                            <option value="" hidden>Select Factor</option>
                                            @foreach ($factors as $factor)
                                                <option value="{{ $factor->id }}">{{ $factor->name }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">Item</label>
                                        <input type="text" name="code" id="code" class="form-control @error('code') is-invalid @enderror" required placeholder="Enter item" value="{{ old('code') }}" />
                                        @error('code')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">Value</label>
                                        <input type="number" step="0.01" min="0" name="value" id="value" class="form-control @error('value') is-invalid @enderror" required placeholder="Enter vakue" value="{{ old('vakue') }}" />
                                        @error('value')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="col-md-12 col-lg-6">
                                    <div class="mb-3">
                                        <label class="form-label">Item Content</label>
                                        <textarea name="content" id="content" rows="5" class="form-control @error('content') is-invalid @enderror" placeholder="Enter content" required>{{ old('content') }}</textarea>
                                        @error('content')
                                            <span class="invalid-feedback" role="alert">
                                                <strong>{{ $message }}</strong>
                                            </span>
                                        @enderror
                                    </div>

                                    <div class="mb-3">
                                        <label class="form-label">Status</label>
                                        <select name="status" id="statusItem" class="form-select" required>
                                            <option value="active">Active</option>
                                            <option value="inactive">Inactive</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="mb-0 text-end">
                                <div>
                                    <button type="reset" class="btn btn-secondary waves-effect me-1">
                                        Cancel
                                    </button>
                                    <button type="submit" class="btn btn-primary waves-effect waves-light">
                                        Submit
                                    </button>
                                </div>
                            </div>
                        </form>

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