<div>
    <a href="#" wire:click="$toggle('isActive')" class="btn btn-primary">@if($post->id) Редактировать @else Новая публикация @endif</a>
    @if($isActive == 'active')
    <div class="modal fade show d-block bg-dark" style="--bs-bg-opacity: .5;z-index:3000" id="postCardModal" data-bs-backdrop="static"
        data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
        <form
            class="modal-dialog modal-dialog-scrollable modal-lg modal-fullscreen-lg-down"
            action="{{ ($post->id) ? route('admin.posts.update', ['post' => $post]) : route('admin.posts.store') }}" method="post" enctype="multipart/form-data">
            <div class="modal-content">
                <div class="modal-header border-0">
                    <h1 class="modal-title fs-5" id="exampleModalToggleLabel2">Редактирование новости</h1>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
                        wire:click="$toggle('isActive')"></button>
                </div>
                <div class="modal-body">
                    <div>
                        @csrf
                        <div class="mb-3">
                            <label for="titleFormControlTextarea" class="form-label">Заголовок</label>
                            <textarea class="form-control" id="titleFormControlTextarea1" name="name" rows="2">{{ $post->name }}</textarea>
                            @error('name')
                            <div class="text-danger">{{ $message }}</div>
                            @enderror
                        </div>
                        <div class="text-dark mb-2">
                            <label class="form-label mb-1">Города для публикации</label>
                            <div class="mb-2 p-2 border rounded">
                                @if($availableCities = GetAvailableCities())
                                <div>
                                    @foreach($availableCities as $key=>$city)
                                    <div class="form-check form-check-inline">
                                        <input name="cities[{{ $key }}]" class="form-check-input" type="checkbox" value="{{ $city->id }}" id="city_{{ $city->id }}">
                                        <label class="form-check-label" for="city_{{ $city->id }}">
                                            {{ $city->name }}
                                        </label>
                                    </div>
                                    @endforeach
                                </div>
                                @endif
                            </div>
                        </div>
                        <div class="row">
                            <div class="col mb-3">
                                <label for="categoryFormControlSelect" class="form-label">Категория</label>
                                <select class="form-select" id="categoryFormControlSelect" name="category" aria-label="">
                                    @foreach ($categories as $category)
                                    <option value="{{ $category->value }}" {{ $post->category == $category->value ? 'selected' : '' }}>
                                        {{ __($category->name) }}
                                    </option>
                                    @endforeach
                                </select>
                                @error('category')
                                <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="col mb-3">
                                <label for="formFile" class="form-label">Заставка новости</label>
                                <input class="form-control" type="file" id="formFile" name="imageFile">
                                @error('imageFile')
                                <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                        <div class="mb-3">
                            <label for="shortTextFormControlTextarea" class="form-label">Анонс</label>
                            <textarea class="form-control" id="shortTextFormControlTextarea1" name="short_text"
                                rows="3">{{ $post->short_text }}</textarea>
                            @error('short_text')
                            <div class="text-danger">{{ $message }}</div>
                            @enderror
                        </div>
                        <div class="mb-3">
                            <label for="shortTextFormControlTextarea" class="form-label">Основной текст</label>
                            @trix($post, 'content', ['inputAttributes' => ['height' => '500px']])

                            @error('text')
                            <div class="text-danger">{{ $message }}</div>
                            @enderror
                        </div>
                        <button type="submit" class="btn btn-primary">Сохранить</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <style>
        .trix-content {
            height: 500px;
            overflow-y: auto;
        }
    </style>
    @endif
</div>