diff --git a/lib/ai_agent/ai_service.dart b/lib/ai_agent/ai_service.dart index b1de277..f44e7b7 100644 --- a/lib/ai_agent/ai_service.dart +++ b/lib/ai_agent/ai_service.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:connect/config/app_config.dart'; +import 'package:connect/services/points_service.dart'; /// Service class for handling AI-powered chat interactions with Dino agent. /// @@ -115,7 +116,9 @@ Always be encouraging and help users get the most out of Connect! } else if (lowerMessage.contains('find') || lowerMessage.contains('search') || lowerMessage.contains('browse')) { return 'To find tasks:\n\n1️⃣ Go to the "Browse" tab\n2️⃣ Use filters to narrow down tasks\n3️⃣ Tap on a task to see details\n4️⃣ Make an offer if interested!\n\nYou can also use the map view to see tasks near you! 📍'; } else if (lowerMessage.contains('payment') || lowerMessage.contains('pay') || lowerMessage.contains('money')) { - return 'We use a point-based system for payments! ⭐\n\n• Earn points by completing tasks\n• Use points to post and pay for tasks\n• Platform takes 10% commission\n• Service providers receive 90% of points\n\nNeed help understanding the points system?'; + final platformCommissionRate = PointsService.platformCommissionRate; + final providerPayoutRate = PointsService.providerPayoutRate; + return 'We use a point-based system for payments! ⭐\n\n• Earn points by completing tasks\n• Use points to post and pay for tasks\n• Platform takes ${(platformCommissionRate * 100).toStringAsFixed(0)}% commission\n• Service providers receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of points\n\nNeed help understanding the points system?'; } else if (lowerMessage.contains('help') || lowerMessage.contains('support')) { return 'I\'m here to help! Here are some common topics:\n\n📝 How to post tasks\n🔍 How to find tasks\n💳 Payment setup\n📍 Location services\n📱 App features\n\nWhat would you like to know more about?'; } else if (lowerMessage.contains('feature') || lowerMessage.contains('what can') || lowerMessage.contains('do')) { @@ -123,7 +126,8 @@ Always be encouraging and help users get the most out of Connect! } else if (lowerMessage.contains('thank') || lowerMessage.contains('thanks')) { return 'You\'re welcome! I\'m always here to help. Don\'t hesitate to ask if you need anything else! 🦕✨'; } else if (lowerMessage.contains('earn') || lowerMessage.contains('money') || lowerMessage.contains('work')) { - return 'Want to earn points? Here\'s how:\n\n⭐ Browse available tasks in your area\n💼 Make competitive offers\n✅ Complete tasks professionally\n💰 Earn points (90% of task value)\n⭐ Build your reputation\n\nStart by checking the Browse tab! 🚀'; + final providerPayoutRate = PointsService.providerPayoutRate; + return 'Want to earn points? Here\'s how:\n\n⭐ Browse available tasks in your area\n💼 Make competitive offers\n✅ Complete tasks professionally\n💰 Earn points (${(providerPayoutRate * 100).toStringAsFixed(0)}% of task value)\n⭐ Build your reputation\n\nStart by checking the Browse tab! 🚀'; } else if (lowerMessage.contains('safety') || lowerMessage.contains('secure') || lowerMessage.contains('trust')) { return 'Your safety is our priority! 🔒\n\n• All users are verified\n• Secure payment system\n• Real-time tracking\n• User ratings and reviews\n• 24/7 support available\n\nFeel free to ask about any safety concerns!'; } else { diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index cc63486..437eff7 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -124,6 +124,21 @@ class AppConfig { static String get firebaseMacosBundleId => _getEnv('FIREBASE_MACOS_BUNDLE_ID', 'com.example.connect'); + // Firebase Auth Action URL + /// Generate Firebase auth action URL for email verification + /// Uses the configured Firebase project ID or defaults to firebaseAuthDomain + static String get firebaseAuthActionUrl { + final projectId = firebaseProjectId; + if (projectId.isNotEmpty) { + return 'https://$projectId.firebaseapp.com/__/auth/action'; + } + // Fallback to auth domain if available + if (firebaseAuthDomain.isNotEmpty) { + return 'https://$firebaseAuthDomain/__/auth/action'; + } + return 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action'; + } + // ============================================================================ // GOOGLE MAPS CONFIGURATION // ============================================================================ diff --git a/lib/firebase/fb.dart b/lib/firebase/fb.dart index 51157fc..cbffd9e 100644 --- a/lib/firebase/fb.dart +++ b/lib/firebase/fb.dart @@ -1,4 +1,5 @@ import 'package:firebase_auth/firebase_auth.dart'; +import 'package:connect/config/app_config.dart'; class FirebaseAuthService { final FirebaseAuth _auth = FirebaseAuth.instance; @@ -21,12 +22,12 @@ class FirebaseAuthService { try { await credential.user!.sendEmailVerification( ActionCodeSettings( - url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action', + url: AppConfig.firebaseAuthActionUrl, handleCodeInApp: true, - androidPackageName: 'com.example.connect', + androidPackageName: AppConfig.appPackageName, androidInstallApp: true, androidMinimumVersion: '12', - iOSBundleId: 'com.example.connect', + iOSBundleId: AppConfig.firebaseIosBundleId, ), ); print("Email verification sent successfully to: $email"); @@ -136,12 +137,12 @@ class FirebaseAuthService { try { await user.sendEmailVerification( ActionCodeSettings( - url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action', + url: AppConfig.firebaseAuthActionUrl, handleCodeInApp: true, - androidPackageName: 'com.example.connect', + androidPackageName: AppConfig.appPackageName, androidInstallApp: true, androidMinimumVersion: '12', - iOSBundleId: 'com.example.connect', + iOSBundleId: AppConfig.firebaseIosBundleId, ), ); print("Email verification resent successfully to: ${user.email}"); diff --git a/lib/loginpage/loginp.dart b/lib/loginpage/loginp.dart index 9baa236..8b0fdc2 100644 --- a/lib/loginpage/loginp.dart +++ b/lib/loginpage/loginp.dart @@ -7,6 +7,7 @@ import 'package:connect/firebase/fb.dart'; import 'package:connect/signuppage/signuppage.dart'; import 'package:connect/profilepage/profile_check_wrapper.dart'; import 'package:connect/core/utils/responsive.dart'; +import 'package:connect/config/app_config.dart'; class LoginPage extends StatefulWidget { const LoginPage({super.key}); @@ -448,12 +449,12 @@ class _LoginPageState extends State { try { await user.sendEmailVerification( ActionCodeSettings( - url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action', + url: AppConfig.firebaseAuthActionUrl, handleCodeInApp: true, - androidPackageName: 'com.example.connect', + androidPackageName: AppConfig.appPackageName, androidInstallApp: true, androidMinimumVersion: '12', - iOSBundleId: 'com.example.connect', + iOSBundleId: AppConfig.firebaseIosBundleId, ), ); if (context.mounted) { diff --git a/lib/profilepage/payment_settings.dart b/lib/profilepage/payment_settings.dart index b5bc01a..feddcbc 100644 --- a/lib/profilepage/payment_settings.dart +++ b/lib/profilepage/payment_settings.dart @@ -375,14 +375,17 @@ class _PaymentSettingsScreenState extends State { } void _showAddPointsDialog() { + final providerPayoutRate = PointsService.providerPayoutRate; + final platformCommissionRate = PointsService.platformCommissionRate; + showDialog( context: context, builder: (context) => AlertDialog( title: Text('Earn Points', style: GoogleFonts.poppins()), content: Text( 'Complete tasks as a service provider to earn points!\n\n' - '• Complete a task: Earn 90% of task points\n' - '• Platform commission: 10%\n\n' + '• Complete a task: Earn ${(providerPayoutRate * 100).toStringAsFixed(0)}% of task points\n' + '• Platform commission: ${(platformCommissionRate * 100).toStringAsFixed(0)}%\n\n' 'Points can be used to post tasks and pay for services.', style: GoogleFonts.poppins(), ), @@ -397,6 +400,9 @@ class _PaymentSettingsScreenState extends State { } void _showPointsInfoDialog() { + final providerPayoutRate = PointsService.providerPayoutRate; + final platformCommissionRate = PointsService.platformCommissionRate; + showDialog( context: context, builder: (context) => AlertDialog( @@ -407,8 +413,8 @@ class _PaymentSettingsScreenState extends State { '✓ Points are used instead of money\n' '✓ Earn points by completing tasks\n' '✓ Use points to post and pay for tasks\n' - '✓ Platform takes 10% commission\n' - '✓ Service providers receive 90% of points\n\n' + '✓ Platform takes ${(platformCommissionRate * 100).toStringAsFixed(0)}% commission\n' + '✓ Service providers receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of points\n\n' 'This is a point-based economy system for the Connect platform.', style: GoogleFonts.poppins(), ), diff --git a/lib/signuppage/signuppage.dart b/lib/signuppage/signuppage.dart index d5ee8d5..0389d54 100644 --- a/lib/signuppage/signuppage.dart +++ b/lib/signuppage/signuppage.dart @@ -9,6 +9,7 @@ import 'package:connect/firebase/fb.dart'; import 'package:connect/profilepage/complete_profile_screen.dart'; import 'package:connect/menupage/mainp.dart'; import 'package:connect/loginpage/loginp.dart'; // Added import for LoginPage +import 'package:connect/config/app_config.dart'; import 'dart:async'; // Added for Timer class SignupPage extends StatefulWidget { @@ -775,12 +776,12 @@ class _SignupPageState extends State { try { await user.sendEmailVerification( ActionCodeSettings( - url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action', + url: AppConfig.firebaseAuthActionUrl, handleCodeInApp: true, - androidPackageName: 'com.example.connect', + androidPackageName: AppConfig.appPackageName, androidInstallApp: true, androidMinimumVersion: '12', - iOSBundleId: 'com.example.connect', + iOSBundleId: AppConfig.firebaseIosBundleId, ), ); Navigator.of(context).pop(); @@ -904,12 +905,12 @@ class _SignupPageState extends State { try { await user.sendEmailVerification( ActionCodeSettings( - url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action', + url: AppConfig.firebaseAuthActionUrl, handleCodeInApp: true, - androidPackageName: 'com.example.connect', + androidPackageName: AppConfig.appPackageName, androidInstallApp: true, androidMinimumVersion: '12', - iOSBundleId: 'com.example.connect', + iOSBundleId: AppConfig.firebaseIosBundleId, ), ); Navigator.of(context).pop(); diff --git a/lib/task_post/payment_confirmation_screen.dart b/lib/task_post/payment_confirmation_screen.dart index 6bcdcb9..dd7fe4a 100644 --- a/lib/task_post/payment_confirmation_screen.dart +++ b/lib/task_post/payment_confirmation_screen.dart @@ -31,8 +31,14 @@ class _PaymentConfirmationScreenState extends State { @override Widget build(BuildContext context) { - final platformCommission = widget.taskAmount * 0.10; - final providerPayout = widget.taskAmount * 0.90; + // Use configured commission rates from PointsService + final commissionCalculation = PointsService.calculateCommission(widget.taskAmount); + final platformCommission = commissionCalculation['platformCommission']!; + final providerPayout = commissionCalculation['providerPayout']!; + + // Get percentage rates for display + final platformCommissionRate = PointsService.platformCommissionRate; + final providerPayoutRate = PointsService.providerPayoutRate; return Scaffold( appBar: AppBar( @@ -127,14 +133,14 @@ class _PaymentConfirmationScreenState extends State { ), const Divider(), _buildPaymentRow( - 'Platform Commission (10%)', + 'Platform Commission (${(platformCommissionRate * 100).toStringAsFixed(0)}%)', '-${platformCommission.toStringAsFixed(0)} Points', isTotal: false, color: Colors.orange, ), const SizedBox(height: 8), _buildPaymentRow( - 'Provider Payout (90%)', + 'Provider Payout (${(providerPayoutRate * 100).toStringAsFixed(0)}%)', '${providerPayout.toStringAsFixed(0)} Points', isTotal: false, color: Colors.green, @@ -244,8 +250,8 @@ class _PaymentConfirmationScreenState extends State { Text( '• Ensure you have sufficient points in your account\n' '• Points will be deducted immediately\n' - '• Provider will receive 90% of the points\n' - '• Platform commission is 10%', + '• Provider will receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of the points\n' + '• Platform commission is ${(platformCommissionRate * 100).toStringAsFixed(0)}%', style: GoogleFonts.poppins( fontSize: 12, color: Colors.orange[800],