Deploy: 2026-05-25 00:29:42

This commit is contained in:
Hamza-Ayed
2026-05-25 00:29:42 +03:00
parent b20f457eaf
commit 7359206eb3
14 changed files with 1126 additions and 213 deletions

View File

@@ -30,7 +30,12 @@ class DashboardCubit extends Cubit<DashboardState> {
switch (tab) {
case DashboardTab.whatsapp:
final status = await _repository.getWhatsAppStatus();
emit(state.copyWith(whatsappStatus: status, isLoading: false));
final meta = await _repository.getMetaSessions();
emit(state.copyWith(
whatsappStatus: status,
metaSessions: meta,
isLoading: false,
));
break;
case DashboardTab.billing:
final plans = await _repository.getPlans();
@@ -123,4 +128,30 @@ class DashboardCubit extends Cubit<DashboardState> {
emit(state.copyWith(errorMessage: cleanMsg, isLoading: false));
}
}
// English: Connect a Facebook Page or Instagram channel and refresh sessions.
Future<void> connectMetaSession(String channelType, String pageId, String pageName, String pageAccessToken) async {
emit(state.copyWith(isLoading: true));
try {
await _repository.connectMetaSession(channelType, pageId, pageName, pageAccessToken);
final meta = await _repository.getMetaSessions();
emit(state.copyWith(metaSessions: meta, isLoading: false));
} catch (e) {
final cleanMsg = e.toString().replaceAll('Exception: ', '');
emit(state.copyWith(errorMessage: cleanMsg, isLoading: false));
}
}
// English: Disconnect a Meta page/profile connection and refresh sessions.
Future<void> disconnectMetaSession(int sessionId) async {
emit(state.copyWith(isLoading: true));
try {
await _repository.disconnectMetaSession(sessionId);
final meta = await _repository.getMetaSessions();
emit(state.copyWith(metaSessions: meta, isLoading: false));
} catch (e) {
final cleanMsg = e.toString().replaceAll('Exception: ', '');
emit(state.copyWith(errorMessage: cleanMsg, isLoading: false));
}
}
}

View File

@@ -4,6 +4,7 @@ import '../../data/models/contact_model.dart';
import '../../data/models/plan_model.dart';
import '../../data/models/super_admin_stats_model.dart';
import '../../data/models/whatsapp_status_model.dart';
import '../../data/models/meta_session_model.dart';
// English: Enum representing the 9 tabs in the Nabeh web/mobile dashboard.
// Arabic: قائمة تعداد تمثل الأبواب التسعة في لوحة تحكم نبيه على الويب والهاتف.
@@ -39,6 +40,7 @@ class DashboardState extends Equatable {
final List<ContactModel> contacts;
final List<ChatbotRuleModel> chatbotRules;
final SuperAdminStatsModel? superAdminStats;
final List<MetaSessionModel> metaSessions;
const DashboardState({
required this.activeTab,
@@ -49,6 +51,7 @@ class DashboardState extends Equatable {
this.contacts = const [],
this.chatbotRules = const [],
this.superAdminStats,
this.metaSessions = const [],
});
// English: Helper copyWith constructor to copy immutable state data safely.
@@ -62,6 +65,7 @@ class DashboardState extends Equatable {
List<ContactModel>? contacts,
List<ChatbotRuleModel>? chatbotRules,
SuperAdminStatsModel? superAdminStats,
List<MetaSessionModel>? metaSessions,
}) {
return DashboardState(
activeTab: activeTab ?? this.activeTab,
@@ -72,6 +76,7 @@ class DashboardState extends Equatable {
contacts: contacts ?? this.contacts,
chatbotRules: chatbotRules ?? this.chatbotRules,
superAdminStats: superAdminStats ?? this.superAdminStats,
metaSessions: metaSessions ?? this.metaSessions,
);
}
@@ -85,5 +90,6 @@ class DashboardState extends Equatable {
contacts,
chatbotRules,
superAdminStats,
metaSessions,
];
}