react-native-my-survey-sdk 2.2.38 → 3.0.1

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 (75) hide show
  1. package/dist/components/XeboDropdownView.d.ts +10 -0
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -0
  3. package/dist/components/XeboDropdownView.js +190 -0
  4. package/dist/components/XeboIntroView.d.ts +9 -0
  5. package/dist/components/XeboIntroView.d.ts.map +1 -0
  6. package/dist/components/XeboIntroView.js +54 -0
  7. package/dist/components/XeboMultiNPSView.d.ts +10 -0
  8. package/dist/components/XeboMultiNPSView.d.ts.map +1 -0
  9. package/dist/components/XeboMultiNPSView.js +170 -0
  10. package/dist/components/XeboMultiRatingView.d.ts +10 -0
  11. package/dist/components/XeboMultiRatingView.d.ts.map +1 -0
  12. package/dist/components/XeboMultiRatingView.js +154 -0
  13. package/dist/components/XeboMultipleChoiceView.d.ts +10 -0
  14. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -0
  15. package/dist/components/XeboMultipleChoiceView.js +188 -0
  16. package/dist/components/XeboNPSView.d.ts +10 -0
  17. package/dist/components/XeboNPSView.d.ts.map +1 -0
  18. package/dist/components/XeboNPSView.js +269 -0
  19. package/dist/components/XeboRatingView.d.ts +10 -0
  20. package/dist/components/XeboRatingView.d.ts.map +1 -0
  21. package/dist/components/XeboRatingView.js +248 -0
  22. package/dist/components/XeboSingleChoiceView.d.ts +10 -0
  23. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -0
  24. package/dist/components/XeboSingleChoiceView.js +172 -0
  25. package/dist/components/XeboSurveyModal.d.ts +3 -0
  26. package/dist/components/XeboSurveyModal.d.ts.map +1 -0
  27. package/dist/components/XeboSurveyModal.js +345 -0
  28. package/dist/components/XeboTextBoxView.d.ts +10 -0
  29. package/dist/components/XeboTextBoxView.d.ts.map +1 -0
  30. package/dist/components/XeboTextBoxView.js +176 -0
  31. package/dist/components/XeboThankYouView.d.ts +9 -0
  32. package/dist/components/XeboThankYouView.d.ts.map +1 -0
  33. package/dist/components/XeboThankYouView.js +115 -0
  34. package/dist/core/XeboNetworkService.d.ts +34 -0
  35. package/dist/core/XeboNetworkService.d.ts.map +1 -0
  36. package/dist/core/XeboNetworkService.js +367 -0
  37. package/dist/core/XeboOfflineQueue.d.ts +8 -0
  38. package/dist/core/XeboOfflineQueue.d.ts.map +1 -0
  39. package/dist/core/XeboOfflineQueue.js +35 -0
  40. package/dist/core/XeboSurveyManager.d.ts +59 -0
  41. package/dist/core/XeboSurveyManager.d.ts.map +1 -0
  42. package/dist/core/XeboSurveyManager.js +351 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +12 -0
  46. package/dist/models/XeboAPIModels.d.ts +82 -0
  47. package/dist/models/XeboAPIModels.d.ts.map +1 -0
  48. package/dist/models/XeboAPIModels.js +4 -0
  49. package/dist/models/XeboModels.d.ts +141 -0
  50. package/dist/models/XeboModels.d.ts.map +1 -0
  51. package/dist/models/XeboModels.js +17 -0
  52. package/dist/theme/XeboTheme.d.ts +11 -0
  53. package/dist/theme/XeboTheme.d.ts.map +1 -0
  54. package/dist/theme/XeboTheme.js +25 -0
  55. package/package.json +10 -3
  56. package/babel.config.js +0 -4
  57. package/src/components/XeboDropdownView.tsx +0 -197
  58. package/src/components/XeboIntroView.tsx +0 -68
  59. package/src/components/XeboMultiNPSView.tsx +0 -166
  60. package/src/components/XeboMultiRatingView.tsx +0 -165
  61. package/src/components/XeboMultipleChoiceView.tsx +0 -183
  62. package/src/components/XeboNPSView.tsx +0 -315
  63. package/src/components/XeboRatingView.tsx +0 -267
  64. package/src/components/XeboSingleChoiceView.tsx +0 -168
  65. package/src/components/XeboSurveyModal.tsx +0 -360
  66. package/src/components/XeboTextBoxView.tsx +0 -188
  67. package/src/components/XeboThankYouView.tsx +0 -100
  68. package/src/core/XeboNetworkService.ts +0 -476
  69. package/src/core/XeboOfflineQueue.ts +0 -33
  70. package/src/core/XeboSurveyManager.ts +0 -422
  71. package/src/index.ts +0 -23
  72. package/src/models/XeboAPIModels.ts +0 -80
  73. package/src/models/XeboModels.ts +0 -169
  74. package/src/theme/XeboTheme.ts +0 -33
  75. package/tsconfig.json +0 -17
@@ -1,476 +0,0 @@
1
- import {
2
- XeboSurvey,
3
- XeboQuestion,
4
- XeboQuestionType,
5
- XeboChoice,
6
- XeboConditionalFollowUp,
7
- XeboAnswer,
8
- XeboUserData,
9
- XeboQualityFlags,
10
- XeboGeolocation,
11
- XeboDeviceInfo,
12
- } from '../models/XeboModels';
13
- import {
14
- APICollectorResponse,
15
- APISurveyResponse,
16
- APIQuestion,
17
- APIConfigScale,
18
- } from '../models/XeboAPIModels';
19
-
20
- // ─── URL helpers ──────────────────────────────────────────────────────────────
21
-
22
- export function resolveZone(zone: string): string {
23
- return zone;
24
- }
25
-
26
- export function buildBaseURL(resolvedZone: string): string {
27
- return `https://${resolvedZone}-api.xebo.ai`;
28
- }
29
-
30
- export function buildFeedbackBaseURL(resolvedZone: string): string {
31
- return `https://${resolvedZone}-feedback-api.xebo.ai`;
32
- }
33
-
34
- export function buildVerifyURL(): string {
35
- return 'https://api.xebo.ai/api/v1/api-key/verify';
36
- }
37
-
38
- // ─── Step 0: API key verification → bearer token ─────────────────────────────
39
-
40
- export async function verifyApiKey(
41
- verifyURL: string,
42
- zone: string,
43
- apiKey: string,
44
- ): Promise<string> {
45
- const url = `${verifyURL}?zone=${encodeURIComponent(zone)}`;
46
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
47
- console.log('[Xebo Step 0] Verifying API key');
48
- console.log('URL:', url);
49
-
50
- const res = await fetch(url, {
51
- method: 'GET',
52
- headers: { 'x-api-key': apiKey },
53
- });
54
-
55
- const json = await res.json();
56
- console.log('[Xebo] Verify response status:', res.status);
57
- console.log('[Xebo] Verify response:', JSON.stringify(json));
58
-
59
- if (!res.ok) {
60
- throw new Error(
61
- `[Xebo] verifyApiKey failed — HTTP ${res.status}: ${JSON.stringify(json)}`
62
- );
63
- }
64
-
65
- const token: string | undefined =
66
- json?.access_token ??
67
- json?.token ??
68
- json?.data?.token ??
69
- json?.bearerToken ??
70
- json?.data?.access_token;
71
-
72
- if (!token) {
73
- throw new Error(
74
- `[Xebo] verifyApiKey — bearer token not found in response: ${JSON.stringify(json)}`
75
- );
76
- }
77
-
78
- console.log('[Xebo] Bearer token obtained successfully');
79
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
80
- return token;
81
- }
82
-
83
- // ─── HTML stripping ───────────────────────────────────────────────────────────
84
-
85
- export function stripHTML(raw: string | undefined): string {
86
- if (!raw) return '';
87
- return raw
88
- .replace(/<[^>]*>/g, '')
89
- .replace(/&amp;/g, '&')
90
- .replace(/&lt;/g, '<')
91
- .replace(/&gt;/g, '>')
92
- .replace(/&nbsp;/g, ' ')
93
- .replace(/&quot;/g, '"')
94
- .replace(/&#39;/g, "'")
95
- .trim();
96
- }
97
-
98
- // ─── Question type mapping ────────────────────────────────────────────────────
99
-
100
- function mapRatingStyle(apiType?: string): string {
101
- switch (apiType?.toLowerCase()) {
102
- case 'star':
103
- case 'stars': return 'star';
104
- case 'heart':
105
- case 'hearts': return 'heart';
106
- case 'circle':
107
- case 'circles': return 'circle';
108
- case 'tile':
109
- case 'tiles': return 'tile';
110
- case 'emoji':
111
- case 'emojis': return 'emoji';
112
- default: return 'star';
113
- }
114
- }
115
-
116
- function mapQuestionType(apiType: string): XeboQuestionType {
117
- switch (apiType) {
118
- case 'single_choice': return XeboQuestionType.singleChoice;
119
- case 'multi_choice': return XeboQuestionType.multipleChoice;
120
- case 'dropdown': return XeboQuestionType.dropdown;
121
- case 'single_text': return XeboQuestionType.singleTextBox;
122
- case 'multi_text': return XeboQuestionType.multipleTextBox;
123
- case 'nps':
124
- case 'nps_pro': return XeboQuestionType.nps;
125
- case 'multi_nps': return XeboQuestionType.multiNps;
126
- case 'rating':
127
- case 'rating_pro': return XeboQuestionType.rating;
128
- case 'multi_rating': return XeboQuestionType.multiRating;
129
- default: return XeboQuestionType.singleChoice;
130
- }
131
- }
132
-
133
- // ─── Survey parsing ───────────────────────────────────────────────────────────
134
-
135
- export function parseSurvey(data: APISurveyResponse['data']): XeboSurvey {
136
- // Collect all follow-up question IDs (from NPS Pro configScale)
137
- const followUpQuestionIds = new Set<string>();
138
- for (const block of data.blocks) {
139
- for (const item of block.questions) {
140
- const q = item.question;
141
- const scales = q.settings?.configScale ?? [];
142
- for (const scale of scales) {
143
- for (const qid of scale.qId ?? []) {
144
- followUpQuestionIds.add(qid);
145
- }
146
- }
147
- }
148
- }
149
-
150
- const questions: XeboQuestion[] = [];
151
-
152
- for (const block of data.blocks) {
153
- for (const item of block.questions) {
154
- const q = item.question;
155
-
156
- // Skip follow-up questions (they're embedded inline)
157
- if (followUpQuestionIds.has(q.uuid)) continue;
158
-
159
- const type = mapQuestionType(q.quesType);
160
- if (type === XeboQuestionType.dropdown) {
161
- console.log('[Xebo] Dropdown raw options keys:', JSON.stringify(Object.keys(q.options ?? {})));
162
- console.log('[Xebo] Dropdown options.row:', JSON.stringify(q.options?.row));
163
- console.log('[Xebo] Full dropdown q.options:', JSON.stringify(q.options));
164
- }
165
- const rawOptions = q.options as any;
166
- const rowSource: any[] = Array.isArray(rawOptions)
167
- ? rawOptions
168
- : (rawOptions?.row ?? rawOptions?.items ?? rawOptions?.choices ?? []);
169
- const rows: XeboChoice[] = rowSource.map((r: any) => ({
170
- id: r.uuid ?? r.id,
171
- text: stripHTML(r.text ?? r.label ?? r.value ?? ''),
172
- value: r.uuid ?? r.id,
173
- }));
174
- const cols: XeboChoice[] = (rawOptions?.col ?? rawOptions?.columns ?? []).map((c: any) => ({
175
- id: c.uuid ?? c.id,
176
- text: stripHTML(c.text ?? c.label ?? ''),
177
- value: c.uuid ?? c.id,
178
- }));
179
-
180
- // Build conditional follow-ups for NPS Pro
181
- const conditionalFollowUps: XeboConditionalFollowUp[] = [];
182
- const scales: APIConfigScale[] = q.settings?.configScale ?? [];
183
- for (const scale of scales) {
184
- if (scale.enabled === false) continue;
185
- const followUpQId = scale.qId?.[0];
186
- if (!followUpQId) continue;
187
-
188
- // Find the follow-up question in all blocks
189
- let followUpApiQ: APIQuestion | undefined;
190
- for (const b of data.blocks) {
191
- for (const bi of b.questions) {
192
- if (bi.question.uuid === followUpQId) {
193
- followUpApiQ = bi.question;
194
- break;
195
- }
196
- }
197
- if (followUpApiQ) break;
198
- }
199
-
200
- const followUpOptions: XeboChoice[] = (followUpApiQ?.options?.row ?? []).map(r => ({
201
- id: r.uuid,
202
- text: stripHTML(r.text),
203
- value: r.uuid,
204
- }));
205
-
206
- conditionalFollowUps.push({
207
- minRating: Number(scale.scale.min),
208
- maxRating: Number(scale.scale.max),
209
- followUpQuestion: stripHTML(followUpApiQ?.title ?? ''),
210
- followUpType: followUpApiQ ? mapQuestionType(followUpApiQ.quesType) : XeboQuestionType.singleTextBox,
211
- followUpOptions,
212
- questionId: followUpQId,
213
- });
214
- }
215
-
216
- const npsSettings = q.settings?.nps;
217
- const ratingSettings = q.settings?.rating;
218
-
219
- const parsed: XeboQuestion = {
220
- id: q.uuid,
221
- type,
222
- title: stripHTML(q.title),
223
- subtitle: stripHTML(q.helperText?.text),
224
- placeholder: stripHTML(q.placeholder?.text),
225
- isRequired: q.required?.enabled ?? false,
226
- options: rows.length > 0 ? rows : undefined,
227
- columns: cols.length > 0 ? cols : undefined,
228
- npsLabels: npsSettings
229
- ? {
230
- lower: npsSettings.leftLabel,
231
- upper: npsSettings.rightLabel,
232
- detractorColor: npsSettings.colors?.detractor,
233
- passiveColor: npsSettings.colors?.passive,
234
- promoterColor: npsSettings.colors?.promoter,
235
- }
236
- : undefined,
237
- followUpQuestion: undefined,
238
- conditionalFollowUps: conditionalFollowUps.length > 0 ? conditionalFollowUps : undefined,
239
- ratingStyle: mapRatingStyle(ratingSettings?.type),
240
- showColLabels: ratingSettings?.colLabel,
241
- ratingColor: ratingSettings?.color,
242
- };
243
-
244
- questions.push(parsed);
245
- }
246
- }
247
-
248
- // Append auto thank-you question
249
- const tyPage = data.thankYouPage;
250
- const tyTitle = tyPage?.enabled && tyPage.content
251
- ? stripHTML(tyPage.content)
252
- : 'Thank You!';
253
- const tySubtitle = tyPage?.enabled && tyPage.content
254
- ? undefined
255
- : 'Your feedback is greatly appreciated.';
256
-
257
- questions.push({
258
- id: 'thank_you_auto',
259
- type: XeboQuestionType.thankYou,
260
- title: tyTitle,
261
- subtitle: tySubtitle,
262
- isRequired: false,
263
- redirectURL: tyPage?.links,
264
- });
265
-
266
- const introPageRaw = data.introPage;
267
- const thankYouPageRaw = data.thankYouPage;
268
-
269
- const survey = {
270
- id: data.uuid,
271
- name: data.displayTitle,
272
- projectId: data.projectId,
273
- questions,
274
- introPage: introPageRaw
275
- ? {
276
- enabled: introPageRaw.enabled ?? false,
277
- content: stripHTML(introPageRaw.content),
278
- buttonText: introPageRaw.buttonText,
279
- }
280
- : undefined,
281
- thankYouPage: thankYouPageRaw
282
- ? {
283
- enabled: thankYouPageRaw.enabled ?? false,
284
- content: stripHTML(thankYouPageRaw.content),
285
- links: thankYouPageRaw.links,
286
- }
287
- : undefined,
288
- };
289
-
290
- console.log('[Xebo] Full parsed survey:', JSON.stringify(survey, null, 2));
291
- return survey;
292
- }
293
-
294
- // ─── API calls ────────────────────────────────────────────────────────────────
295
-
296
- export interface CollectorInfo {
297
- surveyId: string;
298
- uuid: string;
299
- mongoId: string;
300
- }
301
-
302
- export async function fetchCollector(
303
- baseURL: string,
304
- collectorId: string,
305
- bearerToken: string,
306
- ): Promise<CollectorInfo> {
307
- const url = `${baseURL}/v3/collectors/collect/${collectorId}`;
308
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
309
- console.log('[Xebo Step 1] Fetching collector');
310
- console.log('URL:', url);
311
- console.log('Collector ID:', collectorId);
312
-
313
- const res = await fetch(url, { headers: { 'Authorization': `Bearer ${bearerToken}` } });
314
- const json: APICollectorResponse = await res.json();
315
-
316
- // The API may return the collector object directly at the root OR wrapped in a `data` key
317
- const payload = json?.data ?? (json as unknown as APICollectorResponse['data']);
318
-
319
- if (!res.ok || !payload?.surveyId) {
320
- throw new Error(
321
- `[Xebo] fetchCollector failed — HTTP ${res.status}. ` +
322
- `Check your apiKey, collectorId and zone. Response: ${JSON.stringify(json)}`
323
- );
324
- }
325
-
326
- const info: CollectorInfo = {
327
- surveyId: payload.surveyId,
328
- uuid: payload.uuid,
329
- mongoId: payload._id,
330
- };
331
-
332
- console.log('Collector UUID:', info.uuid);
333
- console.log('Collector MongoId:', info.mongoId);
334
- console.log('Survey ID:', info.surveyId);
335
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
336
-
337
- return info;
338
- }
339
-
340
- export async function fetchSurvey(
341
- baseURL: string,
342
- surveyId: string,
343
- bearerToken: string,
344
- ): Promise<XeboSurvey> {
345
- const url = `${baseURL}/v3/survey-management/surveys/${surveyId}`;
346
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
347
- console.log('[Xebo Step 2] Fetching survey');
348
- console.log('URL:', url);
349
-
350
- const res = await fetch(url, { headers: { 'Authorization': `Bearer ${bearerToken}` } });
351
- const json: APISurveyResponse = await res.json();
352
-
353
- console.log('[Xebo] Survey HTTP status:', res.status);
354
- console.log('[Xebo] Survey data keys:', Object.keys(json?.data ?? {}));
355
- console.log('[Xebo] blocks:', JSON.stringify(json?.data?.blocks?.length));
356
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
357
-
358
- if (!json?.data) {
359
- throw new Error(`[Xebo] fetchSurvey — no data in response. HTTP ${res.status}`);
360
- }
361
- if (!Array.isArray(json.data.blocks)) {
362
- throw new Error(`[Xebo] fetchSurvey — 'blocks' missing. Keys: ${Object.keys(json.data)}`);
363
- }
364
-
365
- return parseSurvey(json.data);
366
- }
367
-
368
- export interface SubmitResult {
369
- ok: boolean;
370
- status: number;
371
- responseJson: unknown;
372
- }
373
-
374
- export interface SubmitMeta {
375
- userData?: XeboUserData;
376
- deviceModel?: string;
377
- platform?: string;
378
- osVersion?: string;
379
- startTime?: string;
380
- endTime?: string;
381
- qualityFlags?: XeboQualityFlags;
382
- geolocation?: XeboGeolocation;
383
- deviceInfo?: XeboDeviceInfo;
384
- }
385
-
386
- export async function submitResponse(
387
- feedbackBaseURL: string,
388
- surveyId: string,
389
- collectorUUID: string,
390
- bearerToken: string,
391
- answers: XeboAnswer[],
392
- meta?: SubmitMeta,
393
- ): Promise<SubmitResult> {
394
- const url = `${feedbackBaseURL}/v3/survey-participation/${surveyId}/response/create-response`;
395
-
396
- // Filter out auto thank-you answer
397
- const filteredAnswers = answers.filter(a => a.questionId !== 'thank_you_auto');
398
-
399
- // Build custom_variables — the platform maps these to Name, Email, Mobile, Unique Id fields
400
- const customVariables: Record<string, string> = {};
401
- if (meta?.userData) {
402
- if (meta.userData.name) customVariables.fName = meta.userData.name;
403
- if (meta.userData.email) customVariables.email = meta.userData.email;
404
- if (meta.userData.phone) customVariables.mobile = meta.userData.phone;
405
- if (meta.userData.uniqueId) customVariables.unique_id = meta.userData.uniqueId;
406
- if (meta.userData.country) customVariables.country = meta.userData.country;
407
- if (meta.userData.city) customVariables.city = meta.userData.city;
408
- if (meta.userData.eData) {
409
- Object.entries(meta.userData.eData).forEach(([key, value]) => {
410
- if (key && value) customVariables[key] = value;
411
- });
412
- }
413
- }
414
-
415
- // time_spent in whole seconds, derived from netTimeDuration (minutes)
416
- const timeTakenSecs = meta?.qualityFlags
417
- ? Math.round(meta.qualityFlags.data.survey.netTimeDuration * 60)
418
- : undefined;
419
-
420
- const osVersion = (meta?.osVersion ?? '').replace(/^(ios|android)\s*/i, '');
421
- const userAgent = meta?.platform === 'ios'
422
- ? `Mozilla/5.0 (iPhone; CPU iPhone OS ${osVersion.replace(/\./g, '_')} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
423
- : `Mozilla/5.0 (Linux; Android ${osVersion}; Mobile) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36`;
424
-
425
- const payload: Record<string, unknown> = {
426
- collector_id: collectorUUID,
427
- responses: [
428
- {
429
- response_status: 'complete',
430
- mode: 'React Native SDK',
431
- userAgent,
432
- ...(meta?.startTime && { start_time: meta.startTime }),
433
- ...(meta?.endTime && { end_time: meta.endTime }),
434
- ...(timeTakenSecs !== undefined && { time_spent: timeTakenSecs }),
435
- ...(Object.keys(customVariables).length > 0 && { custom_variables: customVariables }),
436
- ...(meta?.qualityFlags && { qualityFlags: meta.qualityFlags }),
437
- ...(meta?.deviceInfo && { deviceInfo: meta.deviceInfo }),
438
- ...(meta?.geolocation && { geoLocation: meta.geolocation }),
439
- questions: filteredAnswers.map(a => ({
440
- uuid: a.questionId,
441
- answer: a.value.map(v => ({
442
- row_id: v.rowId || null,
443
- col_id: v.colId || null,
444
- text: v.text || null,
445
- })),
446
- })),
447
- },
448
- ],
449
- };
450
-
451
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
452
- console.log('[Xebo Step 3] Submitting response');
453
- console.log('URL:', url);
454
- console.log('Survey ID:', surveyId);
455
- console.log('Collector ID:', collectorUUID);
456
- console.log('Question count:', filteredAnswers.length);
457
- console.log('Payload:', JSON.stringify(payload, null, 2));
458
-
459
- const res = await fetch(url, {
460
- method: 'POST',
461
- headers: {
462
- 'Authorization': `Bearer ${bearerToken}`,
463
- 'Content-Type': 'application/json',
464
- 'User-Agent': userAgent,
465
- },
466
- body: JSON.stringify(payload),
467
- });
468
-
469
- const responseJson = await res.json();
470
-
471
- console.log('HTTP Status:', res.status);
472
- console.log('Response JSON:', JSON.stringify(responseJson, null, 2));
473
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
474
-
475
- return { ok: res.ok, status: res.status, responseJson };
476
- }
@@ -1,33 +0,0 @@
1
- import AsyncStorage from '@react-native-async-storage/async-storage';
2
- import { XeboQueuedResponse } from '../models/XeboModels';
3
-
4
- const STORAGE_KEY = 'com.xebo.offline_responses';
5
-
6
- export const XeboOfflineQueue = {
7
- async enqueue(response: XeboQueuedResponse): Promise<void> {
8
- const existing = await this.getAll();
9
- existing.push(response);
10
- await this.saveAll(existing);
11
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
12
- console.log('[Xebo Offline Queue] Enqueued response:', response.responseId);
13
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
14
- },
15
-
16
- async getAll(): Promise<XeboQueuedResponse[]> {
17
- try {
18
- const raw = await AsyncStorage.getItem(STORAGE_KEY);
19
- if (!raw) return [];
20
- return JSON.parse(raw) as XeboQueuedResponse[];
21
- } catch {
22
- return [];
23
- }
24
- },
25
-
26
- async saveAll(responses: XeboQueuedResponse[]): Promise<void> {
27
- await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(responses));
28
- },
29
-
30
- async clear(): Promise<void> {
31
- await AsyncStorage.removeItem(STORAGE_KEY);
32
- },
33
- };