@extends('dashboard.layouts.app')

@section('content')

<div class="row layout-top-spacing">
    <div class="col-lg-12">
        @if(Session::has('success'))
                <div class="alert alert-light-success alert-dismissible fade show border-0 mb-4" role="alert">
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x close" data-bs-dismiss="alert"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>
                    {{ Session::get('success') }}
                </div>
            @endif

            @if(Session::has('error'))
                <div class="alert alert-light-danger alert-dismissible fade show border-0 mb-4" role="alert">
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x close" data-bs-dismiss="alert"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>
                    {{ Session::get('error') }}
                </div>
            @endif

        <div class="statbox widget box box-shadow">
            <div class="widget-header">
                <div class="row">
                    <div class="col-xl-12 col-md-12 col-sm-12 col-12">
                        <h4>Create New Service</h4>
                    </div>                 
                </div>
            </div>

            <div class="widget-content widget-content-area">
                <div class="row">
                    <div class="col-lg-12 col-12 ">
                        <form action="{{ route('services.store') }}" method="post" enctype="multipart/form-data">
                            @csrf

                            <div class="form-group mb-4">
                                <label>Name En:</label>
                                <input type="text" name="name_en" class="form-control @error('name_en') is-invalid @enderror" value="{{ old('name_en') }}" placeholder="service name in english">
                                @error('name_en')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Name Ar:</label>
                                <input type="text" name="name_ar" class="form-control form-control-rtl @error('name_ar') is-invalid @enderror" value="{{ old('name_ar') }}" placeholder="service name in arabic">
                                @error('name_ar')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Mini Discreption En:</label>
                                <textarea name="mini_description_en" class="form-control @error('mini_description_en') is-invalid @enderror" placeholder="service mini discreption in english">{{ old('mini_description_en') }}</textarea>
                                @error('mini_description_en')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Mini Discreption Ar:</label>
                                <textarea name="mini_description_ar" class="form-control form-control-rtl @error('mini_description_ar') is-invalid @enderror" placeholder="service mini discreption in arabic">{{ old('mini_description_ar') }}</textarea>
                                @error('mini_description_ar')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Discreption En:</label>
                                <textarea id="descriptionEnEditor" name="description_en" class="form-control" placeholder="service discreption in english" rows="8">{{ old('description_en') }}</textarea>
                                @error('description_en')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Discreption Ar:</label>
                                <textarea id="descriptionArEditor" name="description_ar" class="form-control form-control-rtl" placeholder="service discreption in arabic" rows="8">{{ old('description_ar') }}</textarea>
                                @error('description_ar')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label>Order:</label>
                                <input type="text" name="order" class="form-control @error('order') is-invalid @enderror" value="{{ old('order') }}" placeholder="service order ex: 1, 2, ...">
                                @error('order')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>
                            <div class="form-group mb-4">
                                <label for="image">Image:</label>
                                <input type="file" name="image" class="form-control" id="image">
                                @error('image')
                                    <div class="invalid-feedback">
                                        <strong>{{ $message }}</strong>
                                    </div>
                                @enderror
                            </div>

                            <div class="form-group mb-4">
                                <div class="form-check form-switch form-check-inline ">
                                    <input type="checkbox" name="page_details" class="form-check-input" role="switch" id="page_details" checked>
                                    <label class="form-check-label" for="page_details">Make Page Details</label>
                                </div>
                            </div>

                            <button type="submit" class="btn btn-success">Create</button>
                        </form>
                    </div>                                        
                </div>

            </div>
        </div>
    </div>

</div>

@endsection

@section('js')
    <script src="https://cdn.ckeditor.com/ckeditor5/35.1.0/classic/ckeditor.js"></script>
    <script>
        ClassicEditor
            .create( document.querySelector('#descriptionEnEditor') )
            .catch( error => {
                console.error(error);
            });

        ClassicEditor
            .create( document.querySelector('#descriptionArEditor'), {
                language: {
                    ui: 'en',
                    content: 'ar'
                }
            })
            .catch( error => {
                console.error(error);
            });

    </script>
@endsection