@extends('app.admin.layout.layout')
@section('title',__('Edit Room'))
@push('css')
    <link rel="stylesheet" href="{{asset('/assets/admin/plugins/src/image-uploader/uploader.css')}}">
@endpush
@section('content')
    <style>
        .form-control{
            border-radius: 10px;
            border: 1px solid #7b7bff;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;        }
        .form-label{
            font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
        }
        .form-select{
            background-image: none !important;
        }
        .layout-top-spacing{
            margin: 20px;
            border-radius: 15px;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
        }
    </style>
    <br><br><br>
    <div class="card layout-top-spacing">
        <div class="card-body">
            <div class="page-title-container">
                <div class="row">
                    <div class="col-12 col-md-7">
                        <h1 class="mb-0 pb-0 display-4" id="title">@lang('Edit Room')</h1>
                        <nav class="breadcrumb-container d-inline-block" aria-label="breadcrumb">
                                <ul class="breadcrumb pt-0">
                                        <li class="breadcrumb-item"><a href="{{ route('admin:home') }}">@lang('Home')</a></li>
                                        <li class="breadcrumb-item"><a href="{{ route('admin:rooms.index') }}">@lang('Rooms')</a></li>
                                        <li class="breadcrumb-item"><a href="#">@lang('Edit Room')</a></li>
                                </ul>
                        </nav>
                    </div>


                   <script>
                        document.addEventListener('DOMContentLoaded', (event) => {
                            if (document.referrer && document.referrer !== window.location.href) {
                                sessionStorage.setItem('previousURL', document.referrer);
                            }
                        });

                        function goToPreviousURL() {
                            const previousURL = sessionStorage.getItem('previousURL');
                            if (previousURL && previousURL !== window.location.href) {
                                window.location.href = previousURL;
                            } else {
                                history.go(-1);
                            }
                        }
                    </script>


                    <div class="col-12 col-md-5 d-flex align-items-start justify-content-end">
        <button type="button" class="btn btn-outline-primary btn-icon btn-icon-start w-100 w-md-auto" onclick="goToPreviousURL()">
            <i data-acorn-icon="arrow-left" class="me-2" data-acorn-size="17"></i>
            <span>@lang('Back')</span>
        </button>
    </div>
                </div>
            </div>
            <form @class(["row needs-validation","was-validated" => $errors->any()]) action="{{route('admin:rooms.update',$room->getAttribute('id'))}}" method="post" novalidate enctype="multipart/form-data">
                @csrf
                @method('PUT')

            <div class="col-12 p-0 p-md-3 d-flex flex-wrap flex-md-nowrap justify-content-center justify-content-md-start align-items-center">

                <div class="row w-100 my-auto">

                    {{--  <div class="row">
                        <div class="col-lg-3 col-sm-12 p-0 p-md-3 d-flex flex-wrap flex-md-nowrap justify-content-center justify-content-md-start align-items-center">
                                <div class="me-md-5" id="imageContainer">
                                    <img style="height: 224px; width: 427px; object-fit: contain; cursor:pointer;" src="{{$room->image()}}" class="img-thumbnail" alt="{{$room->title()}}" onclick="document.getElementById('fileInput').click()">
                                </div>
                                <!-- Hidden file input -->
                                <input id="fileInput" type="file" style="display:none;" name="image">
                        </div>
                    </div>  --}}

                    {{--  <x-admin.form.input
                        :label="__('Video')"
                        custom-div-class="col-12 col-lg-12"
                        name="video"
                        type="file"
                        :value="old('video')"
                        nullable/>  --}}

                    <x-admin.form.input
                        :label="__('Title Az')"
                        name="title_az"
                        custom-div-class="col-12 col-lg-4"
                        :value="old('title_az',$room->getAttribute('title_az'))"
                        required/>

                    <x-admin.form.input
                        :label="__('Title Ru')"
                        name="title_ru"
                        custom-div-class="col-12 col-lg-4"
                        :value="old('title_ru',$room->getAttribute('title_ru'))"
                        required/>

                    <x-admin.form.input
                        :label="__('Title En')"
                        name="title_en"
                        custom-div-class="col-12 col-lg-4"
                        :value="old('title_en',$room->getAttribute('title_en'))"
                        required/>

                    {{--  <x-admin.form.select
                        :label="__('Room Category')"
                        id="room_category"
                        name="category_id"
                        custom-div-class="col-12 col-lg-6"
                        :selected="old('category_id',$room->category_id)"
                        :options="$roomCategories"
                        nullable/>  --}}

                    {{--  <x-admin.form.input
                        :label="__('Price')"
                        name="price"
                        custom-div-class="col-12 col-lg-6"
                        :value="old('price',$room->getAttribute('price'))"
                        required/>  --}}

                    <x-admin.form.text-area
                        :label="__('Description Az')"
                        name="description_az"
                        type="text"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('description_az',$room->getAttribute('description_az'))"/>

                    <x-admin.form.text-area
                        :label="__('Description Ru')"
                        name="description_ru"
                        type="text"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('description_ru',$room->getAttribute('description_ru'))"/>

                    <x-admin.form.text-area
                        :label="__('Description En')"
                        name="description_en"
                        type="text"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('description_en',$room->getAttribute('description_en'))"/>



                    {{--  <div class="col-span-12 mb-3">
                        <div class="form-check form-switch">
                            <input class="form-check-input" type="checkbox" id="use-background" name="show_in_main" @checked(old('show_in_main'))>
                            <label class="form-check-label" for="use-background">@lang('Show in main')</label>
                        </div>
                    </div>

                    <div class="col-12 mb-3">
                        <label class="col-form-label">@lang('Gallery')</label>
                         <div id="partners" class="form-control"></div>
                     </div>  --}}


                </div>
            </div>
                <x-admin.form.submit-button button-text="Update"/>
            </form>
        </div>
    </div>
@endsection
@push('js')
    <script src="{{asset('/assets/admin/plugins/src/image-uploader/uploader.js')}}"></script>
    <script>
        $("#partners").imageUploader({
            label:"{{__('Drag & Drop files here or click to browse')}}",
            imagesInputName: 'gallery',
            maxFiles: 50,
            maxSize: '2 * 1024 * 1024',
            allowedExt: 'jpg|jpeg|gif|png|webp|svg',
        });
    </script>

    <script src="{{asset('/assets/admin/plugins/src/tinymce/tinymce.min.js')}}"></script>
    <script>
        let tinyDarkActive = JSON.parse(localStorage.getItem("theme")).settings.layout.darkMode;
        tinymce.init({
            selector: 'textarea',
            plugins: [
                'advlist', 'autolink', 'link', 'image', 'lists', 'charmap', 'preview', 'anchor', 'pagebreak',
                'searchreplace', 'wordcount', 'visualblocks', 'visualchars', 'code', 'fullscreen', 'insertdatetime',
                'media', 'table', 'emoticons', 'help'
            ],
            skin: tinyDarkActive ? "oxide-dark" : null,
            content_css: tinyDarkActive ? "dark" : null,
            @if(in_array(app()->getLocale(),['az','ru']))
            language: '{{app()->getLocale()}}'
            @endif
        });
    </script>
@endpush
