@playbasis-ai/qwikcard-sdk 2.3.22 → 2.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playbasis-ai/qwikcard-sdk",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "description": "Playbasis SDK for QwikCard College Rewards - React Native gamification integration",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -67,18 +67,50 @@ function AppContent({ leaderboardId }: { leaderboardId?: string }) {
67
67
  ? await (async () => {
68
68
  try {
69
69
  const res = await client.getLeaderboard(leaderboardId, { limit: 50 });
70
- return res.entries.map((e) => ({
71
- userId: e.playerId,
72
- rank: e.rank,
73
- displayName: e.displayName,
74
- score: e.score,
75
- isCurrentUser: e.playerId === player.id,
70
+ const normalized = res.entries.map((entry) => ({
71
+ userId: entry.playerId,
72
+ rank: entry.rank,
73
+ displayName: entry.displayName || 'Player',
74
+ score: entry.score,
75
+ isCurrentUser: entry.playerId === player.id,
76
76
  }));
77
+ const hasCurrentUser = normalized.some((entry) => entry.isCurrentUser);
78
+
79
+ if (!hasCurrentUser) {
80
+ return [
81
+ {
82
+ userId: player.id,
83
+ rank: 0,
84
+ displayName: player.displayName || 'You',
85
+ score: xp,
86
+ isCurrentUser: true,
87
+ },
88
+ ...normalized,
89
+ ];
90
+ }
91
+
92
+ return normalized;
77
93
  } catch {
78
- return [];
94
+ return [
95
+ {
96
+ userId: player.id,
97
+ rank: 0,
98
+ displayName: player.displayName || 'You',
99
+ score: xp,
100
+ isCurrentUser: true,
101
+ },
102
+ ];
79
103
  }
80
104
  })()
81
- : [];
105
+ : [
106
+ {
107
+ userId: player.id,
108
+ rank: 0,
109
+ displayName: player.displayName || 'You',
110
+ score: xp,
111
+ isCurrentUser: true,
112
+ },
113
+ ];
82
114
 
83
115
  return {
84
116
  user: {
@@ -280,10 +312,7 @@ function AppContent({ leaderboardId }: { leaderboardId?: string }) {
280
312
  {activeGame && (
281
313
  <View style={{ flex: 1 }}>
282
314
  <View style={gameHeaderStyle}>
283
- <TouchableOpacity
284
- onPress={closeGame}
285
- style={{ paddingVertical: 4, paddingRight: 8 }}
286
- >
315
+ <TouchableOpacity onPress={closeGame} style={{ paddingVertical: 4, paddingRight: 8 }}>
287
316
  <Text style={{ color: theme.colors.primary, fontWeight: '700' }}>← Arcade</Text>
288
317
  </TouchableOpacity>
289
318
  <Text
package/src/api/client.ts CHANGED
@@ -316,7 +316,9 @@ export class PlaybasisClient {
316
316
  | { items?: LeaderboardEntry[]; total?: number }
317
317
  | { leaderboard?: { entries?: LeaderboardEntry[]; total?: number } }
318
318
  >('GET', `/leaderboards/${encodeURIComponent(leaderboardId)}?${params}`);
319
- const leaderboardData = data as { leaderboard?: { entries?: LeaderboardEntry[]; total?: number } };
319
+ const leaderboardData = data as {
320
+ leaderboard?: { entries?: LeaderboardEntry[]; total?: number };
321
+ };
320
322
  const entries =
321
323
  'entries' in data
322
324
  ? data.entries
@@ -326,7 +328,7 @@ export class PlaybasisClient {
326
328
  const total =
327
329
  'total' in data && typeof data.total === 'number'
328
330
  ? data.total
329
- : leaderboardData.leaderboard?.total ?? entries?.length ?? 0;
331
+ : (leaderboardData.leaderboard?.total ?? entries?.length ?? 0);
330
332
 
331
333
  const normalizedEntries = (entries || []).map((entry, index) => {
332
334
  const raw = entry as LeaderboardEntry & {