@explorins/pers-sdk-react-native 2.3.7 → 2.3.8

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1266 -1244
  3. package/dist/__tests__/PersSDKProvider.test.js +33 -0
  4. package/dist/hooks/useBusiness.d.ts +2 -2
  5. package/dist/hooks/useBusiness.d.ts.map +1 -1
  6. package/dist/hooks/useBusiness.js +2 -2
  7. package/dist/hooks/useIPFSUrl.d.ts +3 -3
  8. package/dist/hooks/useIPFSUrl.d.ts.map +1 -1
  9. package/dist/hooks/useIPFSUrl.js +7 -7
  10. package/dist/hooks/useWeb3.js +4 -4
  11. package/dist/index.js +2400 -487
  12. package/dist/index.js.map +1 -1
  13. package/dist/providers/PersSDKProvider.d.ts +4 -0
  14. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  15. package/dist/providers/PersSDKProvider.js +14 -0
  16. package/dist/providers/react-native-http-client.d.ts +2 -0
  17. package/dist/providers/react-native-http-client.d.ts.map +1 -1
  18. package/dist/providers/react-native-http-client.js +5 -2
  19. package/dist/storage/rn-secure-storage.d.ts.map +1 -1
  20. package/dist/storage/rn-secure-storage.js +21 -8
  21. package/package.json +3 -3
  22. package/src/__tests__/PersSDKProvider.test.tsx +484 -420
  23. package/src/__tests__/setup.ts +40 -40
  24. package/src/hooks/index.ts +60 -60
  25. package/src/hooks/useAnalytics.ts +327 -327
  26. package/src/hooks/useAuth.ts +265 -265
  27. package/src/hooks/useBookings.ts +191 -191
  28. package/src/hooks/useBusiness.ts +251 -251
  29. package/src/hooks/useCampaigns.ts +500 -500
  30. package/src/hooks/useDonations.ts +66 -66
  31. package/src/hooks/useEvents.ts +372 -372
  32. package/src/hooks/useFiles.ts +155 -155
  33. package/src/hooks/useIPFSUrl.ts +192 -192
  34. package/src/hooks/usePurchases.ts +65 -65
  35. package/src/hooks/useRedemptions.ts +467 -467
  36. package/src/hooks/useTenants.ts +72 -72
  37. package/src/hooks/useTokenBalances.ts +385 -385
  38. package/src/hooks/useTokens.ts +313 -313
  39. package/src/hooks/useTransactionSigner.ts +611 -611
  40. package/src/hooks/useTransactions.ts +299 -299
  41. package/src/hooks/useTriggerSources.ts +301 -301
  42. package/src/hooks/useUserStatus.ts +61 -61
  43. package/src/hooks/useUsers.ts +167 -167
  44. package/src/hooks/useWeb3.ts +355 -355
  45. package/src/index.ts +777 -777
  46. package/src/polyfills/index.ts +160 -160
  47. package/src/polyfills/web3-polyfills.ts +97 -97
  48. package/src/providers/PersSDKProvider.tsx +393 -374
  49. package/src/providers/react-native-auth-provider.ts +110 -110
  50. package/src/providers/react-native-http-client.ts +150 -145
  51. package/src/providers/rn-dpop-provider.ts +190 -190
  52. package/src/storage/async-storage-token-storage.ts +185 -185
  53. package/src/storage/rn-secure-storage.ts +182 -170
  54. package/src/types/react-native-globals.d.ts +45 -45
  55. package/src/utils/index.ts +8 -8
  56. package/src/utils/platform-detection.ts +86 -86
  57. package/dist/index-CzLxqePZ.js +0 -7717
  58. package/dist/index-CzLxqePZ.js.map +0 -1
@@ -1,67 +1,67 @@
1
- import { useCallback } from 'react';
2
- import { usePersSDK } from '../providers/PersSDKProvider';
3
- import type { DonationTypeDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
4
-
5
- /**
6
- * React hook for donation operations in the PERS SDK
7
- *
8
- * Provides methods for managing donations and donation types within the platform.
9
- * Supports retrieving available donation categories and types.
10
- *
11
- * @returns Donation hook with methods for donation management
12
- *
13
- * @example
14
- * ```typescript
15
- * function DonationsComponent() {
16
- * const { getDonationTypes } = useDonations();
17
- *
18
- * const loadDonationTypes = async () => {
19
- * try {
20
- * const types = await getDonationTypes();
21
- * console.log('Available donation types:', types);
22
- * } catch (error) {
23
- * console.error('Failed to load donation types:', error);
24
- * }
25
- * };
26
- *
27
- * return <button onClick={loadDonationTypes}>Load Donation Types</button>;
28
- * }
29
- * ```
30
- */
31
- export const useDonations = () => {
32
- const { sdk, isInitialized } = usePersSDK();
33
-
34
- /**
35
- * Retrieves all available donation types in the system
36
- *
37
- * @returns Promise resolving to array of donation types
38
- * @throws Error if SDK is not initialized
39
- *
40
- * @example
41
- * ```typescript
42
- * const { getDonationTypes } = useDonations();
43
- * const types = await getDonationTypes();
44
- * console.log('Donation types:', types.map(t => t.name));
45
- * ```
46
- */
47
- const getDonationTypes = useCallback(async (): Promise<PaginatedResponseDTO<DonationTypeDTO>> => {
48
- if (!isInitialized || !sdk) {
49
- throw new Error('SDK not initialized. Call initialize() first.');
50
- }
51
-
52
- try {
53
- const result = await sdk.donations.getDonationTypes();
54
- return result;
55
- } catch (error) {
56
- console.error('Failed to fetch donation types:', error);
57
- throw error;
58
- }
59
- }, [sdk, isInitialized]);
60
-
61
- return {
62
- getDonationTypes,
63
- isAvailable: isInitialized && !!sdk?.donations,
64
- };
65
- };
66
-
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ import type { DonationTypeDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
4
+
5
+ /**
6
+ * React hook for donation operations in the PERS SDK
7
+ *
8
+ * Provides methods for managing donations and donation types within the platform.
9
+ * Supports retrieving available donation categories and types.
10
+ *
11
+ * @returns Donation hook with methods for donation management
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * function DonationsComponent() {
16
+ * const { getDonationTypes } = useDonations();
17
+ *
18
+ * const loadDonationTypes = async () => {
19
+ * try {
20
+ * const types = await getDonationTypes();
21
+ * console.log('Available donation types:', types);
22
+ * } catch (error) {
23
+ * console.error('Failed to load donation types:', error);
24
+ * }
25
+ * };
26
+ *
27
+ * return <button onClick={loadDonationTypes}>Load Donation Types</button>;
28
+ * }
29
+ * ```
30
+ */
31
+ export const useDonations = () => {
32
+ const { sdk, isInitialized } = usePersSDK();
33
+
34
+ /**
35
+ * Retrieves all available donation types in the system
36
+ *
37
+ * @returns Promise resolving to array of donation types
38
+ * @throws Error if SDK is not initialized
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const { getDonationTypes } = useDonations();
43
+ * const types = await getDonationTypes();
44
+ * console.log('Donation types:', types.map(t => t.name));
45
+ * ```
46
+ */
47
+ const getDonationTypes = useCallback(async (): Promise<PaginatedResponseDTO<DonationTypeDTO>> => {
48
+ if (!isInitialized || !sdk) {
49
+ throw new Error('SDK not initialized. Call initialize() first.');
50
+ }
51
+
52
+ try {
53
+ const result = await sdk.donations.getDonationTypes();
54
+ return result;
55
+ } catch (error) {
56
+ console.error('Failed to fetch donation types:', error);
57
+ throw error;
58
+ }
59
+ }, [sdk, isInitialized]);
60
+
61
+ return {
62
+ getDonationTypes,
63
+ isAvailable: isInitialized && !!sdk?.donations,
64
+ };
65
+ };
66
+
67
67
  export type DonationHook = ReturnType<typeof useDonations>;