<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\AppLayout::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <?php echo e(__('Dealer Management')); ?>

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

    <div class="p-6 space-y-6">
        <?php if(session('status')): ?>
            <div class="rounded-md bg-green-50 border border-green-200 px-4 py-3 text-sm text-green-800">
                <?php echo e(session('status')); ?>

            </div>
        <?php endif; ?>

        <?php if($errors->any()): ?>
            <div class="rounded-md bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-800">
                <ul class="list-disc pl-5 space-y-1">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <li><?php echo e($error); ?></li>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
            </div>
        <?php endif; ?>

        <div class="bg-white border border-gray-200 rounded-xl shadow-sm p-5 flex items-center justify-between">
            <div>
                <h1 class="text-xl font-semibold text-gray-900">Dealers</h1>
                <p class="mt-1 text-sm text-gray-600">
                    Platform-level dealer management. This list is not scoped by the current dealer.
                </p>
            </div>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.dealers.manage')): ?>
                <a
                    href="<?php echo e(route('settings.dealers.create')); ?>"
                    class="inline-flex items-center rounded-lg bg-red-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-700"
                >
                    Add Dealer
                </a>
            <?php endif; ?>
        </div>

        <div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden">
            <table class="min-w-full divide-y divide-gray-200 text-sm">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Name</th>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Code</th>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Default</th>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Status</th>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Provisioning</th>
                        <th class="px-4 py-2 text-left font-semibold text-gray-700">Created</th>
                        <th class="px-4 py-2 text-right font-semibold text-gray-700">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100">
                    <?php $__empty_1 = true; $__currentLoopData = $dealers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dealer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td class="px-4 py-2 text-gray-900"><?php echo e($dealer->name); ?></td>
                            <td class="px-4 py-2 text-gray-700 font-mono text-xs"><?php echo e($dealer->code); ?></td>
                            <td class="px-4 py-2">
                                <?php if($dealer->is_default): ?>
                                    <span class="inline-flex items-center rounded-full bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700">
                                        Default
                                    </span>
                                <?php endif; ?>
                            </td>
                            <td class="px-4 py-2">
                                <?php if($dealer->is_active): ?>
                                    <span class="inline-flex items-center rounded-full bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700">
                                        Active
                                    </span>
                                <?php else: ?>
                                    <span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600">
                                        Inactive
                                    </span>
                                <?php endif; ?>
                            </td>
                            <td class="px-4 py-2">
                                <?php if($dealer->is_default): ?>
                                    <span class="inline-flex items-center rounded-full bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700">
                                        Provisioned
                                    </span>
                                    <div class="mt-0.5 text-xs text-gray-500">
                                        Base dealer
                                    </div>
                                <?php else: ?>
                                    <?php if($dealer->provisioning_status === 'provisioned'): ?>
                                        <span class="inline-flex items-center rounded-full bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700">
                                            Provisioned
                                        </span>
                                    <?php elseif($dealer->provisioning_status === 'failed'): ?>
                                        <span class="inline-flex items-center rounded-full bg-red-50 px-2 py-0.5 text-xs font-medium text-red-700">
                                            Failed
                                        </span>
                                    <?php else: ?>
                                        <span class="inline-flex items-center rounded-full bg-yellow-50 px-2 py-0.5 text-xs font-medium text-yellow-700">
                                            Pending
                                        </span>
                                    <?php endif; ?>
                                    <?php if($dealer->provisioned_at): ?>
                                        <div class="mt-0.5 text-xs text-gray-500">
                                            <?php echo e($dealer->provisioned_at->format('Y-m-d H:i')); ?>

                                        </div>
                                    <?php endif; ?>
                                    <?php if($dealer->provisioning_status === 'failed' && $dealer->provisioning_error): ?>
                                        <div class="mt-0.5 text-[11px] text-red-600">
                                            <?php echo e(Str::limit($dealer->provisioning_error, 80)); ?>

                                        </div>
                                    <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td class="px-4 py-2 text-gray-500">
                                <?php echo e($dealer->created_at?->format('Y-m-d') ?? '—'); ?>

                            </td>
                            <td class="px-4 py-2">
                                <div class="flex items-center justify-end gap-2">
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.dealers.manage')): ?>
                                        <a
                                            href="<?php echo e(route('settings.dealers.edit', $dealer)); ?>"
                                            class="inline-flex items-center rounded-md border border-gray-200 px-2 py-1 text-xs text-gray-700 hover:bg-gray-50"
                                        >
                                            Edit
                                        </a>

                                        <?php if(! $dealer->is_default): ?>
                                            <form
                                                id="dealer-toggle-<?php echo e($dealer->id); ?>"
                                                method="POST"
                                                action="<?php echo e(route('settings.dealers.toggle-active', $dealer)); ?>"
                                            >
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('PATCH'); ?>
                                                <button
                                                    type="button"
                                                    @click="$store.__confirm.openConfirm('Are you sure you want to change this dealer&#039;s active status?', 'dealer-toggle-<?php echo e($dealer->id); ?>')"
                                                    class="inline-flex items-center rounded-md border border-gray-200 px-2 py-1 text-xs text-gray-700 hover:bg-gray-50"
                                                >
                                                    <?php echo e($dealer->is_active ? 'Deactivate' : 'Activate'); ?>

                                                </button>
                                            </form>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="px-4 py-4 text-center text-sm text-gray-500">
                                No dealers found.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>

            <div class="px-4 py-3 border-t border-gray-100">
                <?php echo e($dealers->links()); ?>

            </div>
        </div>

    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>

<?php /**PATH C:\Projects\mtt-os\resources\views\settings\dealers\index.blade.php ENDPATH**/ ?>