@extends('layouts.main_dashboard.app') @section('title', app()->getLocale() === 'ar' ? 'النقاط والأوسمة والمكافآت' : 'Points, Badges & Rewards') @section('page_heading', app()->getLocale() === 'ar' ? 'النقاط والأوسمة والمكافآت' : 'Points, Badges & Rewards') @section('skip_page_hero', true) @php $isArabic = app()->getLocale() === 'ar'; $criteriaLabels = [ 'total_points' => $isArabic ? 'إجمالي النقاط' : 'Total points', 'assignment_submissions' => $isArabic ? 'عدد الواجبات المسلمة' : 'Assignment submissions', 'quiz_completions' => $isArabic ? 'عدد الاختبارات المكتملة' : 'Quiz completions', 'completed_materials' => $isArabic ? 'المواد المكتملة' : 'Completed materials', 'certificates_count' => $isArabic ? 'عدد الشهادات' : 'Certificates count', ]; $statusLabels = [ 'pending' => $isArabic ? 'قيد المراجعة' : 'Pending', 'approved' => $isArabic ? 'معتمد' : 'Approved', 'rejected' => $isArabic ? 'مرفوض' : 'Rejected', 'fulfilled' => $isArabic ? 'تم التسليم' : 'Fulfilled', ]; $activeRulesCount = $rules->where('is_active', true)->count(); $activeBadgesCount = $badges->where('is_active', true)->count(); $activeRewardsCount = $rewards->where('is_active', true)->count(); $pendingRedemptionsCount = $redemptions->where('status', 'pending')->count(); @endphp @section('content')

{{ $isArabic ? 'إدارة النقاط والأوسمة والمكافآت' : 'Manage Points, Badges, and Rewards' }}

{{ $isArabic ? 'تم فصل كل جزء في مساحة مستقلة لتسهيل ضبط قواعد النقاط، إنشاء الأوسمة، إدارة المكافآت، ومتابعة طلبات الاستبدال بدون تداخل.' : 'Each area is separated into its own workspace so point rules, badges, rewards, and redemption requests can be managed without overlap.' }}

{{ $isArabic ? 'قواعد النقاط النشطة' : 'Active Point Rules' }}

{{ $activeRulesCount }}

{{ $isArabic ? 'الأوسمة النشطة' : 'Active Badges' }}

{{ $activeBadgesCount }}

{{ $isArabic ? 'المكافآت النشطة' : 'Active Rewards' }}

{{ $activeRewardsCount }}

{{ $isArabic ? 'طلبات قيد المراجعة' : 'Pending Redemptions' }}

{{ $pendingRedemptionsCount }}

{{ $isArabic ? 'قواعد النقاط' : 'Point Rules' }}

{{ $isArabic ? 'كل قاعدة في صف مستقل لتحديث الاسم، النقاط، وحالة التفعيل.' : 'Each rule is isolated in its own row for editing name, points, and activation status.' }}

@foreach($rules as $rule)
@csrf @method('PUT')

{{ $rule->action_key }}

@endforeach

{{ $isArabic ? 'إضافة وسام جديد' : 'Create Badge' }}

{{ $isArabic ? 'نموذج مستقل لإنشاء وسام جديد دون التأثير على قائمة الأوسمة الحالية.' : 'A separate form for creating a badge without mixing it with the current list.' }}

@csrf

{{ $isArabic ? 'قائمة الأوسمة' : 'Badges List' }}

@forelse($badges as $badge)
@csrf @method('PUT')

{{ $badge->name }}

{{ $criteriaLabels[$badge->criteria_type] ?? $badge->criteria_type }} · {{ $badge->criteria_value }}

#{{ $badge->id }}
@csrf @method('DELETE')
@empty
{{ $isArabic ? 'لا توجد أوسمة مضافة حتى الآن.' : 'No badges have been created yet.' }}
@endforelse

{{ $isArabic ? 'إضافة مكافأة جديدة' : 'Create Reward' }}

{{ $isArabic ? 'إدارة إنشاء المكافآت منفصلة عن قائمة التعديل حتى تبقى الواجهة أوضح.' : 'Reward creation is separated from the management list to keep the interface cleaner.' }}

@csrf

{{ $isArabic ? 'قائمة المكافآت' : 'Rewards List' }}

@forelse($rewards as $reward)
@csrf @method('PUT')

{{ $reward->name }}

{{ $reward->description ?: ($isArabic ? 'بدون وصف إضافي.' : 'No extra description.') }}

#{{ $reward->id }}
{{ $isArabic ? 'محجوز/مستخدم' : 'Reserved' }}: {{ $reward->reserved_count }}
@csrf @method('DELETE')
@empty
{{ $isArabic ? 'لا توجد مكافآت مضافة حتى الآن.' : 'No rewards have been created yet.' }}
@endforelse

{{ $isArabic ? 'طلبات الاستبدال' : 'Redemption Requests' }}

{{ $isArabic ? 'كل طلب في مساحة مستقلة لتغيير الحالة وتسجيل الملاحظات.' : 'Each redemption is isolated for status updates and internal notes.' }}

@forelse($redemptions as $redemption)
@csrf @method('PUT')

{{ $redemption->user?->name }}

{{ $redemption->reward?->name }} · {{ $redemption->points_cost }} {{ $isArabic ? 'نقطة' : 'pts' }}

{{ $statusLabels[$redemption->status] ?? $redemption->status }}
@empty
{{ $isArabic ? 'لا توجد طلبات استبدال حديثة.' : 'No recent redemption requests.' }}
@endforelse

{{ $isArabic ? 'آخر حركات النقاط' : 'Recent Point Transactions' }}

@forelse($recentTransactions as $transaction)

{{ $transaction->user?->name }}

{{ $transaction->action_key }}

{{ $transaction->points >= 0 ? '+' : '' }}{{ $transaction->points }}
@empty
{{ $isArabic ? 'لا توجد حركات نقاط حديثة.' : 'No recent point transactions.' }}
@endforelse
@endsection