Update: 2026-06-26 17:29:23

This commit is contained in:
Hamza-Ayed
2026-06-26 17:29:23 +03:00
parent a323da29aa
commit 9ded734e38
139 changed files with 1815 additions and 2676 deletions

View File

@@ -1,5 +1,6 @@
import 'package:get/get.dart';
import '../../constant/links.dart';
import '../../views/widgets/snackbar.dart';
import '../functions/crud.dart';
class MarketingController extends GetxController {
@@ -38,22 +39,14 @@ class MarketingController extends GetxController {
void toggleAutopilot(bool value) {
isAutopilotEnabled = value;
update();
Get.snackbar(
"Autopilot Updated".tr,
value ? "Full Autopilot mode enabled".tr : "Approval Mode enabled".tr,
snackPosition: SnackPosition.BOTTOM,
);
mySnackbarInfo(value ? "Full Autopilot mode enabled".tr : "Approval Mode enabled".tr);
}
// --- System Prompt Configuration Saver ---
void savePrompt(String newPrompt) {
systemPrompt = newPrompt;
update();
Get.snackbar(
"Configuration Saved".tr,
"Gemini system instructions updated successfully".tr,
snackPosition: SnackPosition.BOTTOM,
);
mySnackbarSuccess("Gemini system instructions updated successfully".tr);
}
Future<void> fetchAnomalies() async {
@@ -72,10 +65,10 @@ class MarketingController extends GetxController {
if (res is Map && res['status'] == 'success') {
priceAnomalies = res['message'] ?? [];
} else {
Get.snackbar("Error", "Failed to fetch price anomalies");
mySnackbarError("Failed to fetch price anomalies");
}
} catch (e) {
Get.snackbar("Error", "Network error while loading anomalies");
mySnackbarError("Network error while loading anomalies");
} finally {
isLoading = false;
update();
@@ -123,10 +116,10 @@ class MarketingController extends GetxController {
if (res is Map && res['status'] == 'success') {
campaignsLog = res['message'] ?? [];
} else {
Get.snackbar("Error", "Failed to fetch campaign logs");
mySnackbarError("Failed to fetch campaign logs");
}
} catch (e) {
Get.snackbar("Error", "Network error while loading campaign logs");
mySnackbarError("Network error while loading campaign logs");
} finally {
isLoading = false;
update();
@@ -175,17 +168,17 @@ class MarketingController extends GetxController {
);
if (res is Map) {
if (res['status'] == 'success') {
Get.snackbar("Success", "AI campaign triggered successfully! Promos sent.");
mySnackbarSuccess("AI campaign triggered successfully! Promos sent.");
fetchCampaignsLog();
fetchTelemetry();
} else {
Get.snackbar("Campaign Alert", res['message'] ?? "Campaign rate limited.");
mySnackbarWarning(res['message'] ?? "Campaign rate limited.");
}
} else {
Get.snackbar("Error", "Failed to trigger AI campaign");
mySnackbarError("Failed to trigger AI campaign");
}
} catch (e) {
Get.snackbar("Error", "Network error while triggering campaign");
mySnackbarError("Network error while triggering campaign");
} finally {
isLoading = false;
update();
@@ -224,10 +217,10 @@ class MarketingController extends GetxController {
simulatorRecommendationMessage = data['recommendation_message'];
}
} else {
Get.snackbar("Simulation Error", res['message'] ?? "Failed to run simulation");
mySnackbarError(res['message'] ?? "Failed to run simulation");
}
} catch (e) {
Get.snackbar("Error", "Network error during simulation");
mySnackbarError("Network error during simulation");
} finally {
isLoading = false;
update();
@@ -340,9 +333,4 @@ class MarketingController extends GetxController {
}
}
@override
void onInit() {
super.onInit();
// Initially fetch these too if needed, but fetch them specifically when country changes
}
}