diff --git a/musadaq-app/lib/features/companies/views/companies_management_view.dart b/musadaq-app/lib/features/companies/views/companies_management_view.dart index 85c3b7f..46533e9 100644 --- a/musadaq-app/lib/features/companies/views/companies_management_view.dart +++ b/musadaq-app/lib/features/companies/views/companies_management_view.dart @@ -306,7 +306,6 @@ class CompaniesManagementView extends StatelessWidget { void _showLinkJoFotaraDialog(BuildContext context, Map company, CompaniesManagementController controller) { final clientIdC = TextEditingController(); final secretKeyC = TextEditingController(); - final sequenceC = TextEditingController(); Get.dialog( AlertDialog( @@ -319,7 +318,6 @@ class CompaniesManagementView extends StatelessWidget { const SizedBox(height: 16), _editField('Client ID', clientIdC, Icons.vpn_key), _editField('Secret Key', secretKeyC, Icons.lock), - _editField('Income Source Sequence (اختياري)', sequenceC, Icons.format_list_numbered), ], ), ), @@ -332,7 +330,7 @@ class CompaniesManagementView extends StatelessWidget { return; } Get.back(); - controller.connectJoFotara(company['id'], clientIdC.text, secretKeyC.text, sequenceC.text); + controller.connectJoFotara(company['id'], clientIdC.text, secretKeyC.text, ''); }, style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFF6366F1)), child: const Text('ربط الآن', style: TextStyle(color: Colors.white)), diff --git a/musadaq-app/lib/features/dashboard/views/dashboard_view.dart b/musadaq-app/lib/features/dashboard/views/dashboard_view.dart index 44653b3..49ae659 100644 --- a/musadaq-app/lib/features/dashboard/views/dashboard_view.dart +++ b/musadaq-app/lib/features/dashboard/views/dashboard_view.dart @@ -391,15 +391,12 @@ class DashboardView extends GetView { } Widget _buildGamificationCard(Map gamification, bool isDark) { - final points = gamification['points'] ?? 0; + final points = gamification['total_points'] ?? 0; final level = gamification['level'] ?? 1; final levelName = gamification['level_name'] ?? 'مبتدئ'; - final currentLevelThreshold = gamification['current_level_threshold'] ?? 0; - final nextLevelThreshold = gamification['next_level_threshold'] ?? 1000; - final progress = (points - currentLevelThreshold) / - ((nextLevelThreshold - currentLevelThreshold) > 0 - ? (nextLevelThreshold - currentLevelThreshold) - : 1); + final progressPercent = gamification['progress_percent'] ?? 0; + final badgesCount = gamification['badges_count'] ?? 0; + final availableBadges = gamification['available_badges'] ?? 9; return Container( padding: const EdgeInsets.all(16), @@ -447,15 +444,27 @@ class DashboardView extends GetView { ], ), ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), - decoration: BoxDecoration( - color: Colors.white24, - borderRadius: BorderRadius.circular(20), - ), - child: const Text( - 'المكافآت', - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + InkWell( + onTap: () => _showBadgesDialog(gamification), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: Colors.white24, + borderRadius: BorderRadius.circular(20), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'المكافآت ', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + Text( + '$badgesCount/$availableBadges', + style: const TextStyle(color: Colors.white70, fontSize: 12), + ), + ], + ), ), ), ], @@ -464,7 +473,7 @@ class DashboardView extends GetView { ClipRRect( borderRadius: BorderRadius.circular(6), child: LinearProgressIndicator( - value: progress.clamp(0.0, 1.0).toDouble(), + value: progressPercent / 100.0, backgroundColor: Colors.white24, color: Colors.amber, minHeight: 8, @@ -472,7 +481,7 @@ class DashboardView extends GetView { ), const SizedBox(height: 8), Text( - 'باقي ${nextLevelThreshold - points} نقطة للمستوى القادم', + 'باقي ${100 - progressPercent} نقطة للمستوى القادم', style: const TextStyle(color: Colors.white70, fontSize: 12), ), ], @@ -480,6 +489,36 @@ class DashboardView extends GetView { ); } + void _showBadgesDialog(Map gamification) { + final badges = gamification['badges'] as List? ?? []; + + Get.dialog( + AlertDialog( + title: const Text('شاراتك ومكافآتك', textAlign: TextAlign.center, style: TextStyle(color: Color(0xFF0F4C81))), + content: SizedBox( + width: double.maxFinite, + child: badges.isEmpty + ? const Text('لم تحصل على أي شارات بعد. قم برفع الفواتير لتبدأ!', textAlign: TextAlign.center) + : ListView.builder( + shrinkWrap: true, + itemCount: badges.length, + itemBuilder: (context, index) { + final b = badges[index]; + return ListTile( + leading: Text(b['badge_icon'] ?? '🌟', style: const TextStyle(fontSize: 24)), + title: Text(b['badge_name'] ?? '', style: const TextStyle(fontWeight: FontWeight.bold)), + subtitle: Text('تم الحصول عليها: ${(b['earned_at'] ?? '').toString().split(' ')[0]}'), + ); + }, + ), + ), + actions: [ + TextButton(onPressed: () => Get.back(), child: const Text('إغلاق')), + ], + ), + ); + } + Widget _buildQuotaMeter(Map subscription, bool isDark) { int limit = subscription['limit'] ?? 100; int used = subscription['used'] ?? 0; diff --git a/public/shell.php b/public/shell.php index d13cecc..82c29fd 100644 --- a/public/shell.php +++ b/public/shell.php @@ -1572,7 +1572,7 @@ @@ -1868,11 +1868,7 @@ -
- - -
+ + +