<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames((['user']));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter((['user']), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<div 
    x-data="{ 
        isVisible: true,
        isLoading: false,
        async handleRequest(action) {
            this.isLoading = true;
            const url = action === 'accept' 
                ? '<?php echo e(route('network.accept', $user->id)); ?>'
                : '<?php echo e(route('network.ignore', $user->id)); ?>';

            try {
                const response = await fetch(url, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>'
                    }
                });
                
                if (response.ok) {
                    this.isVisible = false;
                }
            } catch (error) {
                console.error('Action failed:', error);
            } finally {
                this.isLoading = false;
            }
        }
    }"
    x-show="isVisible"
    x-transition:leave="transition ease-in duration-300"
    x-transition:leave-start="opacity-100 scale-100"
    x-transition:leave-end="opacity-0 scale-90"
    class="bg-white rounded-xl border-2 border-[#2F3D7E]/10 p-6 hover:shadow-md transition-shadow relative overflow-hidden h-full flex flex-col"
>
    
    <div class="absolute top-0 left-0 w-1 h-full bg-[#2F3D7E] z-10"></div>
    
    
    <div class="flex justify-between items-start mb-4 w-full">
        <div class="flex gap-3 items-center min-w-0 flex-1 mr-2">
            
            <div class="relative flex h-12 w-12 shrink-0 overflow-hidden rounded-full bg-blue-50 text-[#2F3D7E]">
                <div class="flex h-full w-full items-center justify-center rounded-full bg-blue-50 font-bold text-[#2F3D7E]">
                    <?php echo e(strtoupper(substr($user->nickname, 0, 2))); ?>

                </div>
            </div>
            
            <div class="min-w-0">
                <h3 class="font-bold text-gray-900 text-sm truncate">
                    <?php echo e('@' . $user->nickname); ?>

                </h3>
                <p class="text-xs text-gray-500 truncate"><?php echo e($user->companyType); ?></p>
            </div>
        </div>
        
        
        <div class="shrink-0 inline-flex items-center rounded-full border border-blue-100 px-2.5 py-0.5 text-xs font-semibold bg-blue-50 text-[#2F3D7E]">
            Request
        </div>
    </div>

    
    <div class="mb-6 flex-1">
        <div class="text-lg font-semibold text-[#2F3D7E] mb-1 truncate"><?php echo e($user->role); ?></div>
        <div class="flex items-center gap-4 text-xs text-gray-500">
            <div class="flex items-center gap-1 min-w-0">
                <svg class="w-3 h-3 shrink-0" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/><circle cx="12" cy="10" r="3"/></svg>
                <span class="truncate"><?php echo e($user->location); ?></span>
            </div>
        </div>
    </div>

    
    <div class="flex gap-2 mt-auto">
        
        <button 
            @click="handleRequest('accept')"
            :disabled="isLoading"
            class="flex-1 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none disabled:opacity-50 h-9 px-3 bg-[#2F3D7E] hover:bg-[#232d5e] text-white shadow-sm"
        >
            <span x-show="!isLoading" class="flex items-center gap-2">
                <svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
                Accept
            </span>
            <span x-show="isLoading" style="display: none;">...</span>
        </button>

        
        <button 
            @click="handleRequest('ignore')"
            :disabled="isLoading"
            class="flex-1 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors border border-gray-200 text-gray-500 hover:text-red-600 hover:bg-red-50 h-9 px-3 bg-white"
        >
            <span class="flex items-center gap-2">
                <svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
                Ignore
            </span>
        </button>
    </div>
</div><?php /**PATH /var/www/ratemypay_dev/resources/views/components/network/request-card.blade.php ENDPATH**/ ?>