<?php $__env->startSection('title', 'Darul Ifta'); ?>

<?php $__env->startSection('content'); ?>
    <div class="admin-heading">
        <div>
            <span>Moderation</span>
            <h1>Darul Ifta Questions</h1>
        </div>
    </div>

    <section class="admin-question-list">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $questions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $question): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <article class="admin-card admin-question-card">
                <div class="admin-question-head">
                    <div>
                        <div class="moderation-badges">
                            <span class="status-pill"><?php echo e(strtoupper($question->locale)); ?></span>
                            <span class="status-pill"><?php echo e($question->category); ?></span>
                            <span class="<?php echo \Illuminate\Support\Arr::toCssClasses(['status-pill', 'is-pending' => ! $question->is_approved, 'is-live' => $question->is_approved]); ?>">
                                <?php echo e($question->is_approved ? 'Published' : 'Pending review'); ?>

                            </span>
                            <span class="status-pill"><?php echo e(ucfirst($question->status)); ?></span>
                        </div>
                        <h2><?php echo e($question->title); ?></h2>
                        <p><?php echo e($question->body); ?></p>
                        <small><?php echo e($question->user->name); ?> · <?php echo e($question->created_at->diffForHumans()); ?></small>
                    </div>
                    <form method="post" action="<?php echo e(route('admin.questions.destroy', $question)); ?>">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('delete'); ?>
                        <button class="btn btn-ghost" type="submit">Delete</button>
                    </form>
                </div>

                <form class="admin-form-grid" method="post" action="<?php echo e(route('admin.questions.update', $question)); ?>">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('put'); ?>
                    <input name="category" value="<?php echo e($question->category); ?>" required>
                    <select name="status">
                        <option value="pending" <?php if($question->status === 'pending'): echo 'selected'; endif; ?>>Pending</option>
                        <option value="open" <?php if($question->status === 'open'): echo 'selected'; endif; ?>>Open</option>
                        <option value="answered" <?php if($question->status === 'answered'): echo 'selected'; endif; ?>>Answered</option>
                        <option value="closed" <?php if($question->status === 'closed'): echo 'selected'; endif; ?>>Closed</option>
                    </select>
                    <label class="check-row">
                        <input type="checkbox" name="is_approved" value="1" <?php if($question->is_approved): echo 'checked'; endif; ?>>
                        <span>Publish question</span>
                    </label>
                    <button class="btn btn-primary" type="submit">Update</button>
                </form>

                <form class="admin-reply-create" method="post" action="<?php echo e(route('admin.questions.replies.store', $question)); ?>">
                    <?php echo csrf_field(); ?>
                    <label>
                        <span>Official answer</span>
                        <textarea name="body" rows="3" placeholder="Write an official answer. It will be published immediately." required></textarea>
                    </label>
                    <button class="btn btn-primary" type="submit">Publish official answer</button>
                </form>

                <div class="reply-thread">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $question->replies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reply): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <form class="reply-item" method="post" action="<?php echo e(route('admin.replies.update', $reply)); ?>">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('put'); ?>
                            <strong>
                                <?php echo e($reply->user->name); ?>

                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($reply->is_official): ?> · Official <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                · <?php echo e($reply->is_approved ? 'Published' : 'Pending'); ?>

                            </strong>
                            <textarea name="body" rows="3"><?php echo e($reply->body); ?></textarea>
                            <label class="check-row">
                                <input type="checkbox" name="is_official" value="1" <?php if($reply->is_official): echo 'checked'; endif; ?>>
                                <span>Official answer</span>
                            </label>
                            <label class="check-row">
                                <input type="checkbox" name="is_approved" value="1" <?php if($reply->is_approved): echo 'checked'; endif; ?>>
                                <span>Publish reply</span>
                            </label>
                            <button class="btn btn-ghost" type="submit">Save reply</button>
                        </form>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </div>
            </article>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
            <div class="admin-card">No questions yet.</div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </section>

    <?php echo e($questions->links()); ?>

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

<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/jrk-website/resources/views/admin/questions/index.blade.php ENDPATH**/ ?>