Update: 2026-05-08 02:25:00

This commit is contained in:
Hamza-Ayed
2026-05-08 02:25:00 +03:00
parent 189382e065
commit 4721ca83da
6 changed files with 89 additions and 64 deletions

View File

@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/network/dio_client.dart';
import '../../../core/utils/logger.dart';
class ReferralController extends GetxController {
var isLoading = true.obs;
var hasError = false.obs;
var errorMessage = ''.obs;
var referralData = Rxn<Map<String, dynamic>>();
@override
@@ -21,11 +24,18 @@ class ReferralController extends GetxController {
Future<void> fetchReferralCode() async {
try {
isLoading.value = true;
hasError.value = false;
final res = await DioClient().client.get('referral/my-code');
if (res.data['success'] == true) {
referralData.value = Map<String, dynamic>.from(res.data['data']);
} else {
hasError.value = true;
errorMessage.value = res.data['message'] ?? 'خطأ غير معروف';
debugPrint('Referral API error: ${res.data}');
}
} catch (e) {
hasError.value = true;
errorMessage.value = 'تعذّر الاتصال بالخادم';
AppLogger.error('Failed to fetch referral code', e);
} finally {
isLoading.value = false;