@php
    $route = explode('.', Route::currentRouteName());
@endphp

@extends('layouts.main')

@section('breadcrumbs')
    {{ Breadcrumbs::render(request()->route()->getName()) }}
@endsection

@section('content')
    <div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
        @if(isset($customField->id))
            <form action="{{ route('basicdata.custom-field.update', $customField->id) }}" method="POST">
                <input type="hidden" name="id" value="{{ $customField->id }}">
                @method('PUT')
       @else
                    <form method="POST" action="{{ route('basicdata.custom-field.store') }}">
       @endif
                        @csrf
                        <div class="card border border-agi-100 pb-2.5">
                            <div class="card-header bg-agi-50" id="basic_settings">
                                <h3 class="card-title">
                                    {{ isset($customField->id) ? 'Edit' : 'Tambah' }} Custom Field
                                </h3>
                                <div class="flex items-center gap-2">
                                    <a href="{{ route('basicdata.custom-field.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
                                </div>
                            </div>
                            <div class="card-body grid gap-5">
                                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                    <label class="form-label max-w-56">
                                        Name
                                    </label>
                                    <div class="flex flex-wrap items-baseline w-full">
                                        <input class="input  @error('name') border-danger bg-danger-light @enderror" type="text" name="name" value="{{ $customField->name ?? '' }}">
                                        @error('name')
                                        <em class="alert text-danger text-sm">{{ $message }}</em>
                                        @enderror
                                    </div>
                                </div>
                                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                    <label class="form-label max-w-56">
                                        Label
                                    </label>
                                    <div class="flex flex-wrap items-baseline w-full">
                                        <input class="input  @error('label') border-danger bg-danger-light @enderror" type="text" name="label" value="{{ $customField->label ?? '' }}">
                                        @error('label')
                                        <em class="alert text-danger text-sm">{{ $message }}</em>
                                        @enderror
                                    </div>
                                </div>
                                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                    <label class="form-label max-w-56">
                                        Type
                                    </label>
                                    <div class="flex flex-wrap items-baseline w-full">
                                        <select class="input @error('type') border-danger bg-danger-light @enderror" name="type">
                                            <option value="text" {{ (isset($customField->type) && $customField->type == 'text') ? 'selected' : '' }}>Text</option>
                                            <option value="radio" {{ (isset($customField->type) && $customField->type == 'radio') ? 'selected' : '' }}>Radio</option>
                                            <option value="select" {{ (isset($customField->type) && $customField->type == 'select') ? 'selected' : '' }}>Select</option>
                                            <option value="checkbox" {{ (isset($customField->type) && $customField->type == 'checkbox') ? 'selected' : '' }}>Checkbox</option>
                                            <option value="date" {{ (isset($customField->type) && $customField->type == 'date') ? 'selected' : '' }}>Date</option>
                                            <option value="number" {{ (isset($customField->type) && $customField->type == 'number') ? 'selected' : '' }}>Number</option>
                                        </select>
                                        @error('type')
                                        <em class="alert text-danger text-sm">{{ $message }}</em>
                                        @enderror
                                    </div>
                                </div>
                                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                    <label class="form-label max-w-56">
                                        Urutan Prioritas
                                    </label>
                                    <div class="flex flex-wrap items-baseline w-full">
                                        <input class="input  @error('urutan_prioritas') border-danger bg-danger-light @enderror" type="number" name="urutan_prioritas" value="{{ $customField->urutan_prioritas ?? $urutan_prioritas }}">
                                        @error('urutan_prioritas')
                                        <em class="alert text-danger text-sm">{{ $message }}</em>
                                        @enderror
                                    </div>
                                </div>
                                <div class="flex justify-end">
                                    <button type="submit" class="btn btn-primary">
                                        Save
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
    </div>
@endsection
