@extends('daylight::layouts.app')

@section('title', __('daylight::store.create_brand'))

@section('content')
    <x-daylight::page-header :title="__('daylight::store.create_brand')" />

    <x-daylight::session-messages/>

    <form method="post" action="{{ route('daylight.store.categories.store') }}">
        @csrf

        <input type="hidden" name="locale" value="{{ request()->get('locale', app()->getLocale()) }}">

        <x-daylight::input.group
            :label="__('daylight::general.parent')"
            :error="$errors->first('parent')"
            for="parent_id"
        >
            <x-daylight::input.select name="parent_id" id="parent_id" :disabled="!auth()->user()->can('update:categories')" searchable>
                <option value="">{{ __('daylight::store.no_parent') }}</option>
                @foreach($parents as $parent)
                    @include('daylight::store.categories.partials.parent', ['parent' => $parent, 'level' => 0])
                @endforeach
            </x-daylight::input.select>
        </x-daylight::input.group>

        <x-daylight::locale-selector :route="route('daylight.store.categories.create')"/>

        <div x-data="{ name: '{{ old('name') }}', slug: '{{ old('slug') }}' }">
            <x-daylight::input.group
                :label="__('daylight::general.name')"
                :error="$errors->first('name')"
                for="code"
            >
                <x-daylight::input.text
                    name="name"
                    id="name"
                    value="{{ old('name') }}"
                    :disabled="!auth()->user()->can('update:categories')"
                    x-model="name"
                />
            </x-daylight::input.group>

            <x-daylight::input.group
                :label="__('daylight::general.slug')"
                :error="$errors->first('slug')"
                for="slug"
            >
                <x-daylight::input.text
                    name="slug"
                    id="slug"
                    value="{{ old('slug') }}"
                    :disabled="!auth()->user()->can('update:categories')"
                    x-slug="name"
                />
            </x-daylight::input.group>
        </div>

        <x-daylight::seo />

        <div class="mt-6 flex items-center justify-end gap-x-3">
            <x-daylight::buttons.secondary href="{{ route('daylight.store.categories.index') }}" element="a">
                {{ __('daylight::general.cancel') }}
            </x-daylight::buttons.secondary>

            <x-daylight::buttons.primary type="submit">
                {{ __('daylight::general.save') }}
            </x-daylight::buttons.primary>
        </div>
    </form>
@endsection
