@extends('layouts.admin_layout')

@section('content')

<script src="https://cdn.ckeditor.com/ckeditor5/38.1.0/classic/ckeditor.js"></script>


<main class="h-full pb-16 overflow-y-auto">
    <div class="container grid px-6 mx-auto">
        <br><br>
        <h2
            class="flex my-6 text-2xl font-semibold text-gray-700 dark:text-gray-200"
        >
             <a href="{{ route('admin.blogs') }}">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                   <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
                </svg>
             </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create A Blog Post
            </h2>
            <!-- CTA -->
            <a
              class="flex items-center justify-between p-4 mb-8 text-sm font-semibold bg-blue-600 rounded-lg shadow-md focus:outline-none focus:shadow-outline-green"
              href="{{ route('welcome') }}" style="color: #fff;"
            >
              <div class="flex items-center">
                <svg
                  class="w-5 h-5 mr-2"
                  fill="currentColor"
                  viewBox="0 0 20 20"
                >
                  <path
                    d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
                  ></path>
                </svg>
                <span>Go to website</span>
              </div>
              <span>View &RightArrow;</span>
            </a>

            <!-- General elements -->
            <h4
              class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"
            >
             Add a Blog Post
            </h4>
            <div
              class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"
            >
            <x-alert/>
            
            <form method="post" action="{{ route('admin.add-blog') }}" class="mt-4" enctype="multipart/form-data">
            @csrf
            <div class="flex items-center mb-4">
              <label class="block w-full mb-5 mr-3 text-sm">
                <span class="font-semibold text-gray-700 dark:text-gray-400">Author Name</span>
                <input
                  class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input" name="author_name" required type="text"
                />
              </label>

              <label class="block w-full mb-5 mr-3 text-sm">
                <span class="font-semibold text-gray-700 dark:text-gray-400">Author Title</span>
                <input
                  class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input" name="author_title" type="text"
                required/>
              </label>
            </div>

            <div class="flex items-center mb-4">
                <label class="block w-full mb-5 mr-3 text-sm">
                    <span class="font-semibold text-gray-700 dark:text-gray-400">Views</span>
                    <input
                        class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input" name="views" type="number"
                    required/>
                </label>
            </div>

            <div class="flex items-center mb-4">
                <label class="block w-full mb-5 mr-3 text-sm">
                    <span class="font-semibold text-gray-700 dark:text-gray-400">Featured Image</span>
                    <input
                        class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input" name="featured_image" type="file"
                    />
                </label>
            </div>

            <div class="flex items-center mb-4">
                <label class="block w-full mb-5 mr-3 text-sm">
                    <span class="font-semibold text-gray-700 dark:text-gray-400">Blog Title</span>
                    <input
                        class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input" name="title" type="text"
                    required/>
                </label>
            </div>

            <div class="flex items-center mb-4">
              <label class="block w-full mb-5 mr-3 text-sm">
                <span class="font-semibold text-gray-700 dark:text-gray-400">Content</span>
                <textarea id="myTextarea" name="content"
                  class="block mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
                ></textarea>
              </label>
            </div>

              <div class="mx-auto">
              <button
                  class="px-5 py-3 font-medium leading-5 text-white transition-colors duration-150 bg-blue-600 border border-transparent rounded-lg hover:bg-green-700 focus:outline-none focus:shadow-outline-green"
                  type="submit" style="color: #fff;"
                >
                  Create Blog
                </button>
              </div>
            </form>
        </div>
                            
    </div>
</main>



<!-- Page js -->
<script>
ClassicEditor
    .create(document.querySelector("#myTextarea"))
    .catch(error => {
        console.error( error );
    } );
</script>
@endsection