<?php $__env->startSection('content'); ?>
    <section class="page">
        <div class="section-header">
            <div>
                <h1>Callback requests</h1>
                <p class="muted" style="margin: 0;">Track customers waiting for phone follow-up.</p>
            </div>
        </div>

        <?php if(session('status')): ?>
            <div class="flash"><?php echo e(session('status')); ?></div>
        <?php endif; ?>

        <section class="panel">
            <div class="panel-header">
                <div>
                    <h2>Follow-up queue</h2>
                    <span class="muted"><?php echo e($callbackRequests->whereIn('status', ['needs_phone', 'requested'])->count()); ?> open items</span>
                </div>
                <a class="button secondary" href="<?php echo e(route('conversations.index')); ?>">Open inbox</a>
            </div>
            <div class="panel-body">
                <?php if($callbackRequests->isEmpty()): ?>
                    <div class="empty-state">No callback requests yet.</div>
                <?php else: ?>
                    <div class="table-wrap">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>Contact</th>
                                    <th>Phone</th>
                                    <th>Status</th>
                                    <th>Requested</th>
                                    <th>Complete</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $callbackRequests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $callbackRequest): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td>
                                            <a href="<?php echo e(route('conversations.show', $callbackRequest->conversation)); ?>">
                                                <strong><?php echo e($callbackRequest->contact->name ?? 'Unknown contact'); ?></strong>
                                            </a>
                                        </td>
                                        <td><?php echo e($callbackRequest->phone ?? $callbackRequest->contact->phone ?? 'Phone needed'); ?></td>
                                        <td>
                                            <span class="<?php echo \Illuminate\Support\Arr::toCssClasses(['badge', 'warning' => in_array($callbackRequest->status, ['needs_phone', 'requested'], true)]); ?>">
                                                <?php echo e(str_replace('_', ' ', ucfirst($callbackRequest->status))); ?>

                                            </span>
                                        </td>
                                        <td class="muted"><?php echo e($callbackRequest->requested_at->diffForHumans()); ?></td>
                                        <td>
                                            <?php if(in_array($callbackRequest->status, ['needs_phone', 'requested'], true)): ?>
                                                <form method="POST" action="<?php echo e(route('callback-requests.complete', $callbackRequest)); ?>" class="stack" style="max-width: 280px;">
                                                    <?php echo csrf_field(); ?>
                                                    <textarea class="form-control" name="notes" placeholder="Notes"><?php echo e(old('notes')); ?></textarea>
                                                    <button class="button secondary" type="submit">Complete</button>
                                                </form>
                                            <?php else: ?>
                                                <span class="muted"><?php echo e($callbackRequest->completed_at?->diffForHumans()); ?></span>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </section>
    </section>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', [
    'title' => 'Callback Requests | VejalNai',
    'topbarTitle' => 'Callback Requests',
    'topbarSubtitle' => $organization?->name ?? 'No organization assigned',
], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecom123/public_html/chat.shunnointernational.com/resources/views/callback-requests/index.blade.php ENDPATH**/ ?>