<?php $__env->startSection('title', 'Add About Us Details'); ?>
<?php $__env->startSection('section'); ?>

    <style>
        .switch {
            position: relative;
            display: block;
            width: 60px;
            height: 34px;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            -webkit-transition: .4s;
            transition: .4s;
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            -webkit-transition: .4s;
            transition: .4s;
        }

        input:checked + .slider {
            background-color: #2196F3;
        }

        input:focus + .slider {
            box-shadow: 0 0 1px #2196F3;
        }

        input:checked + .slider:before {
            -webkit-transform: translateX(26px);
            -ms-transform: translateX(26px);
            transform: translateX(26px);
        }

        /* Rounded sliders */
        .slider.round {
            border-radius: 34px;
        }

        .slider.round:before {
            border-radius: 50%;
        }

        .help-block {
            color: red;
        }

        .has-error {
            border-block-color: red;
        }

        img {
            object-fit: contain !important;
        }
    </style>

    <?php
        if (!empty($about_us->content)) {
            // Decode the 'content' JSON string into an associative array.
            $decodedData = json_decode($about_us->content, true);
        }
    ?>
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>About Us Form</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">About Us Form</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>
        <!-- /.content-header -->

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

                <div class="row">
                    <!-- left column -->
                    <div class="col-md-12">
                        <form class="category-form" method="post" action="<?php echo e(route('admin.about-us')); ?>"
                              enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
                        <!-- general form elements -->
                            <div class="card card-primary">
                                <div class="card-body">
                                    <div class="tab-content ">
                                        <div class="tab-pane active" role="tabpanel" id="product">
                                            <h2>First Section</h2>
                                            <div class="row">


                                                <div class="col-md-4">
                                                    <label for="">Top Title</label>
                                                    <input type="text" name="top_title" placeholder="Meta Title"
                                                           class="form-control"
                                                           value="<?php echo e(!empty($about_us) ? $decodedData['top_title'] : ''); ?>">
                                                </div>
                                                <div class="col-md-4">
                                                    <label for="">Title</label>
                                                    <input type="text" name="title" placeholder="Meta Title"
                                                           class="form-control"
                                                           value="<?php echo e(!empty($about_us) ? $decodedData['title'] : ''); ?>">
                                                </div>

                                                <div class="col-md-4">
                                                    <label for="">Heading</label>
                                                    <input type="text" name="heading" placeholder="Meta Title"
                                                           class="form-control"
                                                           value="<?php echo e(!empty($about_us) ? $decodedData['heading'] : ''); ?>">
                                                </div>

                                                <div class="col-md-6 mt-4">
                                                    <label for="">Sub Heading</label>
                                                    <input type="text" name="sub_heading" placeholder="Meta Title"
                                                           class="form-control"
                                                           value="<?php echo e(!empty($about_us) ? $decodedData['sub_heading'] : ''); ?>">
                                                </div>

                                                <div class="col-md-6 mt-4 add-old-first-image-input">
                                                    <label for="first_image">First Image</label><br>

                                                    <input type="file" class="form-control old-first-image"
                                                           name="first_image" id="firstimageInput"
                                                           data-old_first_image="<?php echo e($decodedData['first_image'] ?? ''); ?>">

                                                    <img id="firstimagePreview"
                                                         src="<?php echo e(!empty($about_us) && isset($decodedData['first_image']) ? asset('/upload/cms_images/'.$decodedData['first_image']) : asset('admin/dist/img/placeholder.png')); ?>"
                                                         alt="Profile Preview"
                                                         style="width: 300px;height: 200px;margin-top: 10px;">
                                                </div>


                                            </div>

                                            <br>
                                            <div class="col">
                                                <label for="">Description</label>
                                                <textarea name="description" rows="4"
                                                          placeholder="Meta Description"
                                                          class="form-control"
                                                          id="summernote1"><?php echo e(!empty($about_us) ? $decodedData['description'] : ''); ?></textarea>
                                            </div>


                                            <h2 class="mt-3">Section Section</h2>

                                            <div class="row">

                                                <div class="col-md-6">
                                                    <label for="">Heading</label>
                                                    <input type="text" name="second_heading" placeholder="Meta Title"
                                                           class="form-control"
                                                           value="<?php echo e(!empty($about_us) ? $decodedData['second_heading'] : ''); ?>">
                                                </div>

                                                <div class="col-md-6 add-old-second-image-input">
                                                    <label for="secondimagePreview">Second Image</label><br>
                                                    <input type="file" class="form-control old-second-image"
                                                           name="second_image" id="secondimageInput"
                                                           data-old_second_image="<?php echo e($decodedData['second_image'] ?? ''); ?>">
                                                    <img id="secondimagePreview"
                                                         src="<?php echo e(!empty($about_us) && isset($decodedData['second_image']) ? asset('/upload/cms_images/'.$decodedData['second_image']) : asset('admin/dist/img/placeholder.png')); ?>"
                                                         alt="Profile Preview"
                                                         style="width: 300px;height: 200px;margin-top: 10px;">
                                                </div>


                                            </div>

                                            <br>
                                            <div class="col">
                                                <label for="">Description</label>
                                                <textarea name="second_description" rows="4"
                                                          placeholder="Meta Description"
                                                          class="form-control"
                                                          id="summernote2"><?php echo e(!empty($about_us) ? $decodedData['second_description'] : ''); ?></textarea>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <div class="card-footer text-center">
                                    <input type="submit" value="Submit" id="submit_btn" class="btn btn-primary">
                                </div>
                            </div>
                        </form>
                        <!-- /.card -->
                    </div>
                </div>


            </div>
        </section>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>

    <script>
        $('#summernote1').summernote({
            placeholder: 'Hello Admin',
            tabsize: 2,
            height: 100
        });
        $('#summernote2').summernote({
            placeholder: 'Hello Admin',
            tabsize: 2,
            height: 100
        });
    </script>
    <script>
        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 imageInput = document.getElementById('firstimageInput');
        imageInput.addEventListener('change', function () {
            showImagePreview(this, 'firstimagePreview');
        });

        const userImageInput = document.getElementById('secondimageInput');
        userImageInput.addEventListener('change', function () {
            showImagePreview(this, 'secondimagePreview');
        });


        $(document).on('click', '.old-first-image', function () {
            var oldImage = $(this).data('old_first_image');
            console.log(oldImage);
            $('<input>').attr({
                type: 'hidden',
                name: 'old_first_image',
                value: oldImage
            }).appendTo('.add-old-first-image-input');


        });

        $(document).on('click', '.old-second-image', function () {
            var oldImage = $(this).data('old_second_image');
            console.log(oldImage);
            $('<input>').attr({
                type: 'hidden',
                name: 'old_second_image',
                value: oldImage
            }).appendTo('.add-old-second-image-input');


        });
    </script>


<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/servicedemoweb/public_html/global-man-cave/resources/views/admin/page/about-us.blade.php ENDPATH**/ ?>