Skip to content

Commit 6f86caa

Browse files
feat(user): add completedDailyCodingChallenges to FccUserModel (#1611)
* feat(user): add completedDailyCodingChallenges to FccUserModel * refactor(user): rename DailyCodingChallenge to CompletedDailyChallenge in FccUserModel * fix: typo --------- Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
1 parent 3d20c79 commit 6f86caa

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

mobile-app/lib/models/learn/completed_challenge_model.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,23 @@ class CompletedChallenge {
3030
);
3131
}
3232
}
33+
34+
class CompletedDailyChallenge {
35+
final String id;
36+
final int completedDate;
37+
final List<String> languages;
38+
39+
CompletedDailyChallenge({
40+
required this.id,
41+
required this.completedDate,
42+
required this.languages,
43+
});
44+
45+
factory CompletedDailyChallenge.fromJson(Map<String, dynamic> data) {
46+
return CompletedDailyChallenge(
47+
id: data['id'],
48+
completedDate: data['completedDate'],
49+
languages: List<String>.from(data['languages']),
50+
);
51+
}
52+
}

mobile-app/lib/models/main/user_model.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class FccUserModel {
7676
// We can add this in later after confirming it
7777
// final List? badges;
7878
final List<CompletedChallenge> completedChallenges;
79+
final List<CompletedDailyChallenge> completedDailyCodingChallenges;
7980
final List<SavedChallenge> savedChallenges;
8081
final List<Portfolio> portfolio;
8182
final List<String> yearsTopContributor; // If number, parsing it to string
@@ -127,6 +128,7 @@ class FccUserModel {
127128
required this.points,
128129
required this.calendar,
129130
required this.heatMapCal,
131+
required this.completedDailyCodingChallenges,
130132
required this.completedChallenges,
131133
required this.savedChallenges,
132134
required this.portfolio,
@@ -187,6 +189,11 @@ class FccUserModel {
187189
.map<CompletedChallenge>(
188190
(challenge) => CompletedChallenge.fromJson(challenge))
189191
.toList(),
192+
completedDailyCodingChallenges:
193+
(data['completedDailyCodingChallenges'] as List)
194+
.map<CompletedDailyChallenge>(
195+
(challenge) => CompletedDailyChallenge.fromJson(challenge))
196+
.toList(),
190197
savedChallenges: (data['savedChallenges'] as List)
191198
.map<SavedChallenge>(
192199
(challenge) => SavedChallenge.fromJson(challenge))

0 commit comments

Comments
 (0)