Update default location to Thrissur and remove Whitefield, Bengaluru
This commit is contained in:
@@ -12,7 +12,7 @@ class GamificationProvider extends ChangeNotifier {
|
||||
UserGamificationProfile? profile;
|
||||
List<LeaderboardEntry> leaderboard = [];
|
||||
List<ShopItem> shopItems = [];
|
||||
List<AchievementBadge> achievements = [];
|
||||
List<AchievementBadge> achievements = GamificationService.defaultBadges; // Initialize with defaults
|
||||
List<SubmissionModel> submissions = [];
|
||||
CurrentUserStats? currentUserStats;
|
||||
int totalParticipants = 0;
|
||||
@@ -60,10 +60,16 @@ class GamificationProvider extends ChangeNotifier {
|
||||
|
||||
shopItems = results[2] as List<ShopItem>;
|
||||
|
||||
// Prefer achievements from dashboard API; fall back to getAchievements()
|
||||
// Prefer achievements from dashboard API; fall back to fetched or existing defaults
|
||||
final dashAchievements = dashboard.achievements;
|
||||
final fetchedAchievements = results[3] as List<AchievementBadge>;
|
||||
achievements = dashAchievements.isNotEmpty ? dashAchievements : fetchedAchievements;
|
||||
|
||||
if (dashAchievements.isNotEmpty) {
|
||||
achievements = dashAchievements;
|
||||
} else if (fetchedAchievements.isNotEmpty) {
|
||||
achievements = fetchedAchievements;
|
||||
}
|
||||
// Otherwise, keep current defaults
|
||||
|
||||
_lastLoadTime = DateTime.now();
|
||||
} catch (e) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class GamificationService {
|
||||
// ---------------------------------------------------------------------------
|
||||
Future<DashboardResponse> getDashboard() async {
|
||||
final email = await _getUserEmail();
|
||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$email';
|
||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=${Uri.encodeComponent(email)}';
|
||||
final res = await _api.get(url, requiresAuth: false);
|
||||
|
||||
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
||||
@@ -50,7 +50,7 @@ class GamificationService {
|
||||
// GET /v1/gamification/dashboard?user_id={userId}
|
||||
// ---------------------------------------------------------------------------
|
||||
Future<DashboardResponse> getDashboardForUser(String userId) async {
|
||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=$userId';
|
||||
final url = '${ApiEndpoints.gamificationDashboard}?user_id=${Uri.encodeComponent(userId)}';
|
||||
final res = await _api.get(url, requiresAuth: false);
|
||||
|
||||
final profileJson = res['profile'] as Map<String, dynamic>? ?? {};
|
||||
@@ -175,20 +175,17 @@ class GamificationService {
|
||||
} catch (_) {
|
||||
// Fall through to defaults
|
||||
}
|
||||
return _defaultBadges;
|
||||
return defaultBadges;
|
||||
}
|
||||
|
||||
static const _defaultBadges = [
|
||||
AchievementBadge(id: 'badge-01', title: 'First Step', description: 'Submit your first event.', iconName: 'edit', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-02', title: 'Silver Streak', description: 'Submit 5 events.', iconName: 'trending_up', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-03', title: 'Gold Rush', description: 'Submit 15 events.', iconName: 'emoji_events', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-04', title: 'Top 10', description: 'Reach top 10 on leaderboard.', iconName: 'leaderboard', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-05', title: 'Image Pro', description: 'Upload 10 event images.', iconName: 'photo_library', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-06', title: 'Pioneer', description: 'One of the first contributors.', iconName: 'rocket_launch', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-07', title: 'Community Star', description: 'Get 10 events approved.', iconName: 'verified', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-08', title: 'Event Hunter', description: 'Submit 25 events.', iconName: 'event_hunter', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-09', title: 'District Champion', description: 'Rank #1 in your district.', iconName: 'location_on', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-10', title: 'Platinum Achiever', description: 'Earn 1500 EP.', iconName: 'diamond', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-11', title: 'Diamond Legend', description: 'Earn 5000 EP.', iconName: 'workspace_premium', isUnlocked: false, progress: 0.0),
|
||||
static const defaultBadges = [
|
||||
AchievementBadge(id: 'badge-01', title: 'Newcomer', description: 'First Event Posted', iconName: 'star', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-02', title: 'Contributor', description: '10th Event Posted within a month', iconName: 'crown', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-03', title: 'On Fire!', description: '3 Day Streak of logging in', iconName: 'fire', isUnlocked: false, progress: 0.67),
|
||||
AchievementBadge(id: 'badge-04', title: 'Verified', description: 'Identity Verified successfully', iconName: 'verified', isUnlocked: true, progress: 1.0),
|
||||
AchievementBadge(id: 'badge-05', title: 'Quality', description: '5 Star Event Rating received', iconName: 'star', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-06', title: 'Community', description: 'Referred 5 Friends to the platform', iconName: 'community', isUnlocked: false, progress: 0.4),
|
||||
AchievementBadge(id: 'badge-07', title: 'Expert', description: 'Level 10 Reached in 3 months', iconName: 'expert', isUnlocked: false, progress: 0.0),
|
||||
AchievementBadge(id: 'badge-08', title: 'Precision', description: '100% Data Accuracy on all events', iconName: 'precision', isUnlocked: false, progress: 0.0),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user