@extends('layouts.app')

@section('title', __('{{ key }}::messages.title'))

@section('content')
    @php($isEdit = isset($record))

    <x-page-header :title="$isEdit ? __('common.edit') : __('common.create')" />

    <div class="px-panel p-3 p-md-4">
        <form method="POST"
              action="{{ $isEdit ? route('{{ key }}.update', $record) : route('{{ key }}.store') }}">
            @csrf
            @if ($isEdit)
                @method('PUT')
            @endif

            <x-form.input name="name" :label="__('{{ key }}::messages.singular')"
                          :value="$isEdit ? $record->name : null" required />

            <div class="d-flex gap-2">
                <button type="submit" class="btn px-btn-primary">{{ __('common.save') }}</button>
                <a href="{{ route('{{ key }}.index') }}" class="btn px-btn-ghost">
                    {{ __('common.cancel') }}
                </a>
            </div>
        </form>
    </div>
@endsection
