@pixels-online/pixels-client-js-sdk 2.7.0 → 2.8.0

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.
Files changed (2) hide show
  1. package/README.md +92 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -74,6 +74,98 @@ client.on('playerUpdated', (player) => {
74
74
  });
75
75
  ```
76
76
 
77
+ ### 3. Render Offer UI/UX
78
+
79
+ Each offer object returned by the SDK includes helper methods for rendering offer state in your UI.
80
+
81
+ #### Checking if an Offer is Claimable
82
+
83
+ Use `offer.canClaim()` to determine whether the player has met all requirements and can claim the offer:
84
+
85
+ ```typescript
86
+ const claimable = offer.canClaim?.();
87
+ renderClaimButton(offer, { disabled: !claimable });
88
+ ```
89
+
90
+ ### Displaying Offer Progress
91
+
92
+ Use `offer.getProgressPercent()` to get the player's overall completion percentage (0–100):
93
+
94
+ ```typescript
95
+ const progress = offer.getProgressPercent?.() ?? 0;
96
+
97
+ // Example: render a progress bar
98
+ renderProgressBar(offer, { percent: progress });
99
+ ```
100
+
101
+ ### Rendering Completion Conditions
102
+
103
+ Use `offer.getCompletionConditions()` to get a list of individual conditions, each with `isMet` (boolean) and `text` (human-readable description):
104
+
105
+ ```typescript
106
+ const conditions = offer.getCompletionConditions?.() ?? [];
107
+
108
+ for (const condition of conditions) {
109
+ renderCondition({
110
+ text: condition.text,
111
+ completed: condition.isMet,
112
+ });
113
+ }
114
+
115
+ // Example React rendering
116
+ function OfferConditions({ offer }) {
117
+ const conditions = offer.getCompletionConditions?.() ?? [];
118
+ return (
119
+ <ul>
120
+ {conditions.map((c, i) => (
121
+ <li key={i} style={{ color: c.isMet ? 'green' : 'gray' }}>
122
+ {c.isMet ? '✓' : '○'} {c.text}
123
+ </li>
124
+ ))}
125
+ </ul>
126
+ );
127
+ }
128
+ ```
129
+
130
+ ### Rendering Team Offer Sibling Progress
131
+
132
+ For team offers (offers where all team members must complete for anyone to claim), use `offer.getSiblingProgress()` to display each sibling's progress:
133
+
134
+ ```typescript
135
+ const isTeamOffer = offer.labels?.includes('team_offer');
136
+
137
+ if (isTeamOffer) {
138
+ const siblingProgress = offer.getSiblingProgress?.() ?? [];
139
+
140
+ for (const sibling of siblingProgress) {
141
+ renderSiblingRow({
142
+ playerId: sibling.playerId,
143
+ percentCompleted: sibling.percentCompleted,
144
+ isComplete: sibling.isComplete,
145
+ });
146
+ }
147
+ }
148
+
149
+ // Example React rendering
150
+ function TeamProgress({ offer }) {
151
+ const siblings = offer.getSiblingProgress?.() ?? [];
152
+ if (!siblings.length) return null;
153
+
154
+ return (
155
+ <div>
156
+ <h4>Team Progress</h4>
157
+ {siblings.map((s) => (
158
+ <div key={s.playerId}>
159
+ <span>{s.playerId}</span>
160
+ <span>{s.percentCompleted}%</span>
161
+ <span>{s.isComplete ? '✓ Complete' : 'In Progress'}</span>
162
+ </div>
163
+ ))}
164
+ </div>
165
+ );
166
+ }
167
+ ```
168
+
77
169
  ### 3. Claim Offers
78
170
 
79
171
  ```typescript
@@ -291,40 +383,12 @@ const assetHelper = new AssetHelper(assetResolver, fallbackImage);
291
383
  const rewardAsset = assetHelper.resolveRewardAsset(reward, assetId);
292
384
  ```
293
385
 
294
- ## 🧪 Testing
295
-
296
- The SDK includes comprehensive test coverage:
297
-
298
- ```bash
299
- # Run all tests
300
- npm test
301
-
302
- # Run unit tests
303
- npm run test:unit
304
-
305
- # Run integration tests
306
- npm run test:integration
307
-
308
- # Run e2e tests
309
- npm run test:e2e
310
-
311
- # Run with coverage
312
- npm run test:coverage
313
-
314
- # Watch mode
315
- npm run test:watch
316
- ```
317
-
318
386
  ## 🌍 Environments
319
387
 
320
388
  The SDK supports multiple environments:
321
389
 
322
390
  - **`test`** - Sandbox environment for development
323
391
  - **`live`** - Production environment
324
- - **`staging`** - Staging environment
325
- - **`preview`** - Preview environment
326
- - **`dev`** - Development environment
327
- - **Custom URL** - Provide your own endpoint
328
392
 
329
393
  ## � Migration Guide
330
394
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixels-online/pixels-client-js-sdk",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Pixels Client JS SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",