@extends('layouts.admin-layout')
@section('title', 'Home Page Cms')
@section('css')
    <link rel="stylesheet"
        href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-iconpicker/1.10.0/css/bootstrap-iconpicker.min.css" />
    <script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-iconpicker/1.10.0/js/bootstrap-iconpicker.bundle.min.js">
    </script>
@endsection
@section('content')

    <div class="content-wrapper">

        <section class="content ">
            <div class="container-fluid">

                <div class="row">
                    <!-- left column -->
                    <div class="col-md-12 mt-5">
                        <form action="{{ route('admin.pages.update', ['slug' => $page->slug]) }}" method="post"
                            class="category-form" enctype="multipart/form-data">
                            <input type="hidden" name="media_collections[]" value="story_image1">
                            <input type="hidden" name="media_collections[]" value="story_image2">
                            <input type="hidden" name="media_collections[]" value="story_image3">
                            <input type="hidden" name="media_collections[]" value="story_image4">
                            <input type="hidden" name="media_collections[]" value="story_image5">
                            <input type="hidden" name="media_collections[]" value="story_image6">
                            <input type="hidden" name="media_collections[]" value="story_image7">
                            @csrf
                            <input type="hidden" name="slug" value="{{ $page->slug }}">

                            <div class="card card-dark card-box-shadow">
                                <div class="card-header">
                                    <h3 class="card-title">(Home Page)</h3>
                                </div>

                                <div class="card-body">
                                    <div class="tab-content text-center">
                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2>Home Main Product Section</h2>

                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <label for="">heading *</label>
                                                        <input type="text" name="pro_main_heading"
                                                            class="form-control form__field" required
                                                            value="{{ $content['pro_main_heading'] ?? '' }}">
                                                    </div>

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

                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2>Home Story One Section</h2>

                                                <div class="row">

                                                    <div class="col-md-4">
                                                        <label for="">Info Heading *</label>
                                                        <input type="text" name="home_sto1_info" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_sto1_info'] ?? '' }}">
                                                    </div>

                                                    <div class="col-md-8">
                                                        <label for="">Description *</label>
                                                        <textarea class="form-control form__field" name="home_sto1_desc" required placeholder="Description">{{ $content['home_sto1_desc'] ?? '' }}</textarea>
                                                    </div>
                                                    <div class="col-md-12">
                                                        <div class="form-group">
                                                            <label for="banner_image">Video</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image1" accept="video/*">
                                                            <small class="text-danger">Please upload a video file smaller
                                                                than 10 MB.</small>
                                                            @if ($page->hasMedia('story_image1'))
                                                                <label for="existing_background_story_image2"></label>
                                                                @foreach ($page->getMedia('story_image1') as $media)
                                                                    <video class="main-slider__video" autoplay loop muted
                                                                        width="100%" height="300px">
                                                                        <source src="{{ $media->getUrl() }}"
                                                                            type="video/mp4">
                                                                    </video>
                                                                @endforeach
                                                            @endif


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


                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2>Home Story Two Section</h2>

                                                <div class="row">

                                                    <div class="col-md-4">
                                                        <label for="">Heading *</label>
                                                        <input type="text" name="home_sto2_heading" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_sto2_heading'] ?? '' }}">
                                                    </div>

                                                    <div class="col-md-8">
                                                        <label for="">Description *</label>
                                                        <textarea class="form-control form__field" name="home_sto2_desc" required placeholder="Description">{{ $content['home_sto2_desc'] ?? '' }}</textarea>
                                                    </div>

                                                    <div class="col-md-4">
                                                        <label for="">Button Text *</label>
                                                        <textarea class="form-control form__field" name="home_sto2_btn_text" required placeholder="Description">{{ $content['home_sto2_btn_text'] ?? '' }}</textarea>
                                                    </div>
                                                    <div class="col-md-8">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image One</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image2" id="cta_image">
                                                            @if ($page->hasMedia('story_image2'))
                                                                <label for="existing_background_story_image2"></label>
                                                                @foreach ($page->getMedia('story_image2') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>

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

                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2 class="text-center my-5">Home Story Three Section</h2>
                                                <div class="row">

                                                    <!-- Banner Section -->

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Heading *</label><br>
                                                            <input type="text" required
                                                                class="form-control form__field" name="home_sto3_heading"
                                                                id="title"
                                                                value="{{ $content['home_sto3_heading'] ?? '' }}">
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Description One *</label><br>
                                                            <textarea class="form-control form__field" name="home_sto3_des1" required placeholder="Description">{{ $content['home_sto3_des1'] ?? '' }}</textarea>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Description Two *</label><br>
                                                            <textarea class="form-control form__field" name="home_sto3_des2" required placeholder="Description">{{ $content['home_sto3_des2'] ?? '' }}</textarea>
                                                        </div>
                                                    </div>


                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Description Three *</label><br>
                                                            <textarea class="form-control form__field" name="home_sto3_des3" required placeholder="Description">{{ $content['home_sto3_des3'] ?? '' }}</textarea>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Description Four *</label><br>
                                                            <textarea class="form-control form__field" name="home_sto3_des4" required placeholder="Description">{{ $content['home_sto3_des4'] ?? '' }}</textarea>
                                                        </div>
                                                    </div>


                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Description Five *</label><br>
                                                            <textarea class="form-control form__field" name="home_sto3_des5" required placeholder="Description">{{ $content['home_sto3_des5'] ?? '' }}</textarea>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="title">Button Text *</label><br>
                                                            <input type="text" required
                                                                class="form-control form__field" name="home_sto3_btn"
                                                                id="title"
                                                                value="{{ $content['home_sto3_btn'] ?? '' }}">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image One</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image3" id="cta_image">
                                                            @if ($page->hasMedia('story_image3'))
                                                                <label for="existing_background_story_image3"></label>
                                                                @foreach ($page->getMedia('story_image3') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image Two</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image4" id="cta_image">
                                                            @if ($page->hasMedia('story_image4'))
                                                                <label for="existing_background_story_image4"></label>
                                                                @foreach ($page->getMedia('story_image4') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image Three</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image5" id="cta_image">
                                                            @if ($page->hasMedia('story_image5'))
                                                                <label for="existing_background_story_image5"></label>
                                                                @foreach ($page->getMedia('story_image5') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>

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

                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2>Home Story Four Section</h2>

                                                <div class="row">

                                                    <div class="col-md-4">
                                                        <label for="">Heading *</label>
                                                        <input type="text" name="home_sto4_heading" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_sto4_heading'] ?? '' }}">
                                                    </div>
                                                    <div class="col-md-4">
                                                        <label for="">Image One Title *</label>
                                                        <input type="text" name="home_sto4_img1_title" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_sto4_img1_title'] ?? '' }}">
                                                    </div>

                                                    <div class="col-md-4">
                                                        <label for="">Image Two Title *</label>
                                                        <input type="text" name="home_sto4_img2_title" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_sto4_img2_title'] ?? '' }}">
                                                    </div>


                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image One</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image6" id="cta_image">
                                                            @if ($page->hasMedia('story_image6'))
                                                                <label for="existing_background_story_image6"></label>
                                                                @foreach ($page->getMedia('story_image6') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="banner_image">Image One</label><br>
                                                            <input type="file" class="form-control form__field"
                                                                name="story_image7" id="cta_image">
                                                            @if ($page->hasMedia('story_image7'))
                                                                <label for="existing_background_story_image7"></label>
                                                                @foreach ($page->getMedia('story_image7') as $media)
                                                                    <img src="{{ $media->getUrl() }}"
                                                                        alt="Existing Banner Image"
                                                                        style="max-width: 200px; max-height: 200px; margin-top: 10px; background-color: black">
                                                                @endforeach
                                                            @endif
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                        </div>
                                        <div class="card p-5 mb-3">
                                            <div class="card-body">
                                                <h2>Home Gallery Section</h2>

                                                <div class="row">

                                                    <div class="col-md-12">
                                                        <label for="">Heading *</label>
                                                        <input type="text" name="home_gallery_heading" required
                                                            class="form-control form__field"
                                                            value="{{ $content['home_gallery_heading'] ?? '' }}">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </div>

                                </div>
                            </div>
                            <br>
                            <div class="text-center">
                                <input type="submit" value="Update" class="btn btn-dark">
                            </div>
                            <br>
                        </form>

                        <!-- /.card -->
                    </div>
                </div>

            </div>
        </section>
    </div>
@endsection
@section('script')

    <script>
        $(document).ready(function() {

            $('.icon-picker-btn1').iconpicker({
                iconset: 'fontawesome',
            }).on('iconpickerSelected', function(event) {


            }).on('change', function(e) {
                let selectedIcon = e.icon;
                console.log(selectedIcon);

                $('.icon-input1').val(selectedIcon);
            });
        });

        function showImagePreview(input, previewId) {
            const preview = document.getElementById(previewId);

            if (input.files && input.files[0]) {
                const reader = new FileReader();

                reader.onload = function(e) {
                    preview.src = e.target.result;
                    preview.style.display = 'block';
                };

                reader.readAsDataURL(input.files[0]);
            }
        }


        const ourDrinkHomeSecondSecImageInput = document.getElementById('ourDrinkHomeSecondSecImageInput');
        ourDrinkHomeSecondSecImageInput.addEventListener('change', function() {
            showImagePreview(this, 'ourDrinkPageFirstImagePreview');
        });
    </script>
@endsection
