@explorins/pers-sdk-react-native 2.1.13 → 2.1.17
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/README.md +108 -14
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useAnalytics.d.ts +1 -1
- package/dist/hooks/useAnalytics.d.ts.map +1 -1
- package/dist/hooks/useAuth.d.ts +3 -3
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +5 -17
- package/dist/hooks/useBusiness.d.ts +3 -2
- package/dist/hooks/useBusiness.d.ts.map +1 -1
- package/dist/hooks/useBusiness.js +28 -2
- package/dist/hooks/useCampaigns.d.ts +12 -4
- package/dist/hooks/useCampaigns.d.ts.map +1 -1
- package/dist/hooks/useCampaigns.js +36 -8
- package/dist/hooks/useDonations.d.ts +1 -1
- package/dist/hooks/useDonations.d.ts.map +1 -1
- package/dist/hooks/usePurchases.d.ts +2 -2
- package/dist/hooks/usePurchases.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.d.ts +28 -5
- package/dist/hooks/useRedemptions.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.js +58 -1
- package/dist/hooks/useTenants.d.ts +1 -1
- package/dist/hooks/useTenants.d.ts.map +1 -1
- package/dist/hooks/useTokenBalances.d.ts +1 -1
- package/dist/hooks/useTokenBalances.d.ts.map +1 -1
- package/dist/hooks/useTokenBalances.js +1 -1
- package/dist/hooks/useTokens.d.ts +1 -1
- package/dist/hooks/useTokens.d.ts.map +1 -1
- package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
- package/dist/hooks/useTransactionSigner.js +38 -11
- package/dist/hooks/useTransactions.d.ts +1 -1
- package/dist/hooks/useTransactions.d.ts.map +1 -1
- package/dist/hooks/useTriggerSources.d.ts +1 -1
- package/dist/hooks/useTriggerSources.d.ts.map +1 -1
- package/dist/hooks/useUserStatus.d.ts +1 -1
- package/dist/hooks/useUserStatus.d.ts.map +1 -1
- package/dist/hooks/useUsers.d.ts +1 -1
- package/dist/hooks/useUsers.d.ts.map +1 -1
- package/dist/index-CzLxqePZ.js +7717 -0
- package/dist/index-CzLxqePZ.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1896 -317
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +7 -17
- package/dist/providers/rn-dpop-provider.d.ts.map +1 -1
- package/dist/providers/rn-dpop-provider.js +48 -12
- package/package.json +3 -3
- package/src/hooks/index.ts +5 -2
- package/src/hooks/useAnalytics.ts +1 -1
- package/src/hooks/useAuth.ts +6 -20
- package/src/hooks/useBusiness.ts +32 -3
- package/src/hooks/useCampaigns.ts +49 -12
- package/src/hooks/useDonations.ts +1 -1
- package/src/hooks/usePurchases.ts +1 -1
- package/src/hooks/useRedemptions.ts +91 -6
- package/src/hooks/useTenants.ts +1 -1
- package/src/hooks/useTokenBalances.ts +1 -1
- package/src/hooks/useTokens.ts +1 -1
- package/src/hooks/useTransactionSigner.ts +41 -10
- package/src/hooks/useTransactions.ts +1 -1
- package/src/hooks/useTriggerSources.ts +1 -1
- package/src/hooks/useUserStatus.ts +1 -1
- package/src/hooks/useUsers.ts +1 -1
- package/src/index.ts +6 -3
- package/src/providers/PersSDKProvider.tsx +8 -17
- package/src/providers/rn-dpop-provider.ts +57 -11
package/README.md
CHANGED
|
@@ -48,15 +48,110 @@ The SDK automatically installs the following native libraries. **You must rebuil
|
|
|
48
48
|
npm install react-native-url-polyfill
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
### Metro Configuration (Required)
|
|
52
|
+
|
|
53
|
+
The PERS SDK uses subpath exports (`@explorins/pers-sdk/core`, etc.) which require Metro to be configured. Add to your `metro.config.js`:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
57
|
+
// or for bare RN: const { getDefaultConfig } = require('@react-native/metro-config');
|
|
58
|
+
|
|
59
|
+
const config = getDefaultConfig(__dirname);
|
|
60
|
+
|
|
61
|
+
// REQUIRED: Enable package exports for PERS SDK subpath imports
|
|
62
|
+
config.resolver.unstable_enablePackageExports = true;
|
|
63
|
+
|
|
64
|
+
module.exports = config;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ⚠️ Android Architecture Requirements
|
|
70
|
+
|
|
71
|
+
**The SDK requires React Native New Architecture** starting from v2.1.x.
|
|
72
|
+
|
|
73
|
+
### Why?
|
|
74
|
+
|
|
75
|
+
`react-native-quick-crypto` v1.0+ (used for high-performance cryptographic operations) uses [Nitro Modules](https://github.com/margelo/nitro), which require New Architecture.
|
|
76
|
+
|
|
77
|
+
### Quick Check
|
|
78
|
+
|
|
79
|
+
If you see errors like:
|
|
80
|
+
```
|
|
81
|
+
NitroModulesProxy.createHybridObject(...) threw an unknown std::runtime_error
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Your app is running with **Old Architecture** (`newArchEnabled=false`).
|
|
85
|
+
|
|
86
|
+
### Solution 1: Enable New Architecture (Recommended)
|
|
87
|
+
|
|
88
|
+
React Native 0.76+ has stable New Architecture support. Enable it in `android/gradle.properties`:
|
|
89
|
+
|
|
90
|
+
```properties
|
|
91
|
+
# android/gradle.properties
|
|
92
|
+
|
|
93
|
+
# Use this property to enable support to the new architecture.
|
|
94
|
+
newArchEnabled=true
|
|
95
|
+
|
|
96
|
+
# Use this property to enable or disable the Hermes JS engine.
|
|
97
|
+
hermesEnabled=true
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then clean and rebuild:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cd android && ./gradlew clean && cd ..
|
|
104
|
+
npx react-native start --reset-cache
|
|
105
|
+
npx react-native run-android
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> **Reference**: See the [VQ Demo App's gradle.properties](https://github.com/explorins/vq-pers-integration-demo/blob/main/android/gradle.properties) for a working configuration with Expo SDK 54 and React Native 0.81.5.
|
|
109
|
+
|
|
110
|
+
### Solution 2: Downgrade quick-crypto (For Old Architecture)
|
|
111
|
+
|
|
112
|
+
If you must stay on Old Architecture, pin to v0.7.x:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"resolutions": {
|
|
117
|
+
"react-native-quick-crypto": "0.7.17"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Or for npm (in `package.json`):
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"overrides": {
|
|
127
|
+
"react-native-quick-crypto": "0.7.17"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Compatibility Matrix
|
|
133
|
+
|
|
134
|
+
| RN Version | Architecture | quick-crypto | Status |
|
|
135
|
+
|------------|--------------|--------------|--------|
|
|
136
|
+
| 0.76+ | New (`newArchEnabled=true`) | 1.0.6+ | ✅ Recommended |
|
|
137
|
+
| 0.76+ | Old (`newArchEnabled=false`) | 0.7.17 | ⚠️ Requires downgrade |
|
|
138
|
+
| < 0.76 | Old | 0.7.x | ⚠️ Use older quick-crypto |
|
|
139
|
+
|
|
140
|
+
> **See [Android Compatibility FAQ](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/docs/ANDROID_COMPATIBILITY_FAQ.md)** for detailed troubleshooting.
|
|
141
|
+
|
|
142
|
+
---
|
|
51
143
|
|
|
52
144
|
## Critical Setup Requirement: Passkeys
|
|
53
145
|
|
|
54
|
-
To enable Passkey authentication (WebAuthn) on iOS and Android, you **must
|
|
146
|
+
To enable Passkey authentication (WebAuthn) on iOS and Android, you **must**:
|
|
147
|
+
|
|
148
|
+
1. **Register your app with PERS backend** - Contact **support@explorins.com** with:
|
|
149
|
+
- iOS: Bundle ID + Apple Team ID
|
|
150
|
+
- Android: Package Name + SHA-256 fingerprint
|
|
151
|
+
|
|
152
|
+
2. **Configure native files** - See [Passkey Setup Guide](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/REACT_NATIVE_PASSKEY_SETUP.md)
|
|
55
153
|
|
|
56
|
-
|
|
57
|
-
- Registering your app with the PERS backend (required for OS trust)
|
|
58
|
-
- Native configuration (Info.plist, AndroidManifest.xml)
|
|
59
|
-
- Expo/development build setup
|
|
154
|
+
3. **For Expo**: Use development builds (`npx expo run:android`), not Expo Go
|
|
60
155
|
|
|
61
156
|
## Quick Start
|
|
62
157
|
|
|
@@ -1027,16 +1122,15 @@ const tokens = (await getTokens()).data;
|
|
|
1027
1122
|
|
|
1028
1123
|
## Documentation
|
|
1029
1124
|
|
|
1030
|
-
|
|
1031
|
-
- **[AUTH_STATE_HANDLING.md](./docs/AUTH_STATE_HANDLING.md)** - Comprehensive guide for handling authentication state changes
|
|
1032
|
-
- Pattern examples for observing `isAuthenticated` state
|
|
1033
|
-
- Custom UI for session expiration
|
|
1034
|
-
- Platform-specific details (iOS Keychain, Android Keystore, Web)
|
|
1035
|
-
- Best practices for auth state observation
|
|
1125
|
+
All documentation is available on GitHub:
|
|
1036
1126
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1127
|
+
| Guide | Description |
|
|
1128
|
+
|-------|-------------|
|
|
1129
|
+
| [Quick Setup Guide](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/docs/QUICK_SETUP_GUIDE.md) | Android + Passkey setup in one page |
|
|
1130
|
+
| [Passkey Setup](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/REACT_NATIVE_PASSKEY_SETUP.md) | WebAuthn/Passkey configuration |
|
|
1131
|
+
| [Android Compatibility](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/docs/ANDROID_COMPATIBILITY_FAQ.md) | New Architecture troubleshooting |
|
|
1132
|
+
| [Auth State Handling](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/docs/AUTH_STATE_HANDLING.md) | Session management patterns |
|
|
1133
|
+
| [Changelog](https://github.com/eXplorins/pers-sdk/blob/main/packages/pers-sdk-react-native/CHANGELOG.md) | Version history |
|
|
1040
1134
|
|
|
1041
1135
|
---
|
|
1042
1136
|
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -21,8 +21,9 @@ export type { TransactionSignerHook, SubmissionResult, AuthenticatedUser, Transa
|
|
|
21
21
|
export type { AccountOwnedTokensResult, Web3Hook } from './useWeb3';
|
|
22
22
|
export type { EventsHook, PersEvent, EventHandler, EventFilter, Unsubscribe } from './useEvents';
|
|
23
23
|
export type { TokenBalanceWithToken, UseTokenBalancesOptions, UseTokenBalancesResult } from './useTokenBalances';
|
|
24
|
-
export type { CampaignClaimFilters, CampaignHook, GetCampaignsOptions } from './useCampaigns';
|
|
25
|
-
export type { RedemptionRedeemFilters, RedemptionHook } from './useRedemptions';
|
|
24
|
+
export type { CampaignClaimFilters, CampaignFilterOptions, CampaignHook, GetCampaignsOptions } from './useCampaigns';
|
|
25
|
+
export type { RedemptionRedeemFilters, RedemptionFilterOptions, RedemptionHook, GetRedemptionsOptions } from './useRedemptions';
|
|
26
|
+
export type { BusinessFilterOptions, BusinessHook } from './useBusiness';
|
|
26
27
|
export type { TransactionQueryOptions, TransactionHook } from './useTransactions';
|
|
27
28
|
export type { TriggerSourceQueryOptions, TriggerSourceHook } from './useTriggerSources';
|
|
28
29
|
export type { AnalyticsHook } from './useAnalytics';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;A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,EACnC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjG,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrH,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGhI,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzE,YAAY,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGlF,YAAY,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxF,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransactionAnalyticsRequestDTO, TransactionAnalyticsResponseDTO, CampaignClaimAnalyticsRequestDTO, CampaignClaimAnalyticsResponseDTO, UserAnalyticsRequestDTO, UserAnalyticsResponseDTO, UserRankingAnalyticsRequestDTO, UserRankingAnalyticsResponseDTO, BusinessRankingAnalyticsRequestDTO, BusinessRankingAnalyticsResponseDTO, RetentionAnalyticsRequestDTO, RetentionAnalyticsResponseDTO } from '@explorins/pers-
|
|
1
|
+
import { TransactionAnalyticsRequestDTO, TransactionAnalyticsResponseDTO, CampaignClaimAnalyticsRequestDTO, CampaignClaimAnalyticsResponseDTO, UserAnalyticsRequestDTO, UserAnalyticsResponseDTO, UserRankingAnalyticsRequestDTO, UserRankingAnalyticsResponseDTO, BusinessRankingAnalyticsRequestDTO, BusinessRankingAnalyticsResponseDTO, RetentionAnalyticsRequestDTO, RetentionAnalyticsResponseDTO } from '@explorins/pers-sdk';
|
|
2
2
|
/**
|
|
3
3
|
* React hook for analytics operations in the PERS SDK
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnalytics.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnalytics.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,YAAY;uCAqBZ,8BAA8B,KACtC,QAAQ,+BAA+B,CAAC;yCAoChC,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC;iCA+ClC,uBAAuB,KAC/B,QAAQ,wBAAwB,CAAC;+BAkDzB,8BAA8B,KACtC,QAAQ,+BAA+B,CAAC;mCAuChC,kCAAkC,KAC1C,QAAQ,mCAAmC,CAAC;sCAuCpC,4BAA4B,KACpC,QAAQ,6BAA6B,CAAC;;CAuB1C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RawUserData } from '@explorins/pers-sdk/core';
|
|
2
2
|
import { AccountOwnerType } from '@explorins/pers-sdk/core';
|
|
3
|
-
import type { UserDTO,
|
|
3
|
+
import type { UserDTO, SessionAuthContextResponseDTO } from '@explorins/pers-sdk';
|
|
4
4
|
export type { RawUserData };
|
|
5
5
|
/**
|
|
6
6
|
* React hook for authentication operations in the PERS SDK
|
|
@@ -42,14 +42,14 @@ export type { RawUserData };
|
|
|
42
42
|
export declare const useAuth: () => {
|
|
43
43
|
isInitialized: boolean;
|
|
44
44
|
isAuthenticated: boolean;
|
|
45
|
-
user: UserDTO | AdminDTO | null;
|
|
45
|
+
user: UserDTO | import("@explorins/pers-sdk").AdminDTO | null;
|
|
46
46
|
login: (jwtToken: string, userType?: AccountOwnerType) => Promise<SessionAuthContextResponseDTO>;
|
|
47
47
|
loginWithRawData: (rawUserData: RawUserData) => Promise<void>;
|
|
48
48
|
logout: () => Promise<void>;
|
|
49
49
|
refreshUserData: () => Promise<void>;
|
|
50
50
|
getCurrentUser: () => Promise<UserDTO>;
|
|
51
51
|
checkIsAuthenticated: () => Promise<boolean>;
|
|
52
|
-
refreshTokens: (refreshToken?: string) => Promise<import("@explorins/pers-
|
|
52
|
+
refreshTokens: (refreshToken?: string) => Promise<import("@explorins/pers-sdk").SessionAuthResponseDTO>;
|
|
53
53
|
clearAuth: () => Promise<void>;
|
|
54
54
|
hasValidAuth: () => Promise<boolean>;
|
|
55
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAGlF,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,OAAO;;;;sBA0ByB,MAAM,aAAY,gBAAgB,KAA2B,QAAQ,6BAA6B,CAAC;oCAgCrF,WAAW,KAAG,QAAQ,IAAI,CAAC;kBAgC/C,QAAQ,IAAI,CAAC;;0BA0BL,QAAQ,OAAO,CAAC;gCAmBV,QAAQ,OAAO,CAAC;mCAqBX,MAAM;qBAmBtB,QAAQ,IAAI,CAAC;wBAoBV,QAAQ,OAAO,CAAC;CAwB5D,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -63,21 +63,15 @@ export const useAuth = () => {
|
|
|
63
63
|
// Set token in auth provider
|
|
64
64
|
await authProvider.setAccessToken(jwtToken);
|
|
65
65
|
// Perform login using the manager
|
|
66
|
+
// SDK emits login_success event with user data - PersSDKProvider handles state sync
|
|
66
67
|
const result = await sdk.auth.loginWithToken(jwtToken, userType);
|
|
67
|
-
|
|
68
|
-
if (userData) {
|
|
69
|
-
setAuthenticationState(userData, true);
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
throw new Error('No user data returned from login');
|
|
74
|
-
}
|
|
68
|
+
return result;
|
|
75
69
|
}
|
|
76
70
|
catch (error) {
|
|
77
71
|
console.error('Login failed:', error);
|
|
78
72
|
throw error;
|
|
79
73
|
}
|
|
80
|
-
}, [sdk, authProvider
|
|
74
|
+
}, [sdk, authProvider]);
|
|
81
75
|
/**
|
|
82
76
|
* Logs in a user using raw user data (direct authentication bypass)
|
|
83
77
|
*
|
|
@@ -96,24 +90,18 @@ export const useAuth = () => {
|
|
|
96
90
|
}
|
|
97
91
|
try {
|
|
98
92
|
// Use the raw data login from the auth manager
|
|
93
|
+
// SDK emits login_success event with user data - PersSDKProvider handles state sync
|
|
99
94
|
const result = await sdk.auth.loginWithRawData(rawUserData);
|
|
100
95
|
// Set token from result
|
|
101
96
|
if (result.accessToken) {
|
|
102
97
|
await authProvider.setAccessToken(result.accessToken);
|
|
103
98
|
}
|
|
104
|
-
const userData = result.user;
|
|
105
|
-
if (userData) {
|
|
106
|
-
setAuthenticationState(userData, true);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
throw new Error('No user data returned from raw data login');
|
|
110
|
-
}
|
|
111
99
|
}
|
|
112
100
|
catch (error) {
|
|
113
101
|
console.error('Raw data login failed:', error);
|
|
114
102
|
throw error;
|
|
115
103
|
}
|
|
116
|
-
}, [sdk, authProvider
|
|
104
|
+
}, [sdk, authProvider]);
|
|
117
105
|
/**
|
|
118
106
|
* Logs out the current user and clears authentication state
|
|
119
107
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BusinessDTO, BusinessTypeDTO, BusinessUpdateRequestDTO, BusinessToggleActiveRequestDTO, PaginatedResponseDTO } from '@explorins/pers-
|
|
1
|
+
import type { BusinessDTO, BusinessTypeDTO, BusinessUpdateRequestDTO, BusinessToggleActiveRequestDTO, PaginatedResponseDTO, BusinessFilterOptions } from '@explorins/pers-sdk';
|
|
2
|
+
export type { BusinessFilterOptions } from '@explorins/pers-sdk';
|
|
2
3
|
/**
|
|
3
4
|
* React hook for business operations in the PERS SDK
|
|
4
5
|
*
|
|
@@ -36,7 +37,7 @@ import type { BusinessDTO, BusinessTypeDTO, BusinessUpdateRequestDTO, BusinessTo
|
|
|
36
37
|
export declare const useBusiness: () => {
|
|
37
38
|
getActiveBusinesses: () => Promise<PaginatedResponseDTO<BusinessDTO>>;
|
|
38
39
|
getBusinessTypes: () => Promise<PaginatedResponseDTO<BusinessTypeDTO>>;
|
|
39
|
-
getBusinesses: () => Promise<PaginatedResponseDTO<BusinessDTO>>;
|
|
40
|
+
getBusinesses: (options?: BusinessFilterOptions) => Promise<PaginatedResponseDTO<BusinessDTO>>;
|
|
40
41
|
getBusinessById: (businessId: string) => Promise<BusinessDTO | null>;
|
|
41
42
|
getBusinessByAccount: (accountAddress: string) => Promise<BusinessDTO>;
|
|
42
43
|
getBusinessesByType: (typeId: string) => Promise<PaginatedResponseDTO<BusinessDTO>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBusiness.d.ts","sourceRoot":"","sources":["../../src/hooks/useBusiness.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useBusiness.d.ts","sourceRoot":"","sources":["../../src/hooks/useBusiness.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG/K,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,WAAW;+BAgB4B,QAAQ,qBAAqB,WAAW,CAAC,CAAC;4BA2B7C,QAAQ,qBAAqB,eAAe,CAAC,CAAC;8BAsD1C,qBAAqB,KAAG,QAAQ,qBAAqB,WAAW,CAAC,CAAC;kCAxC9D,MAAM,KAAG,QAAQ,WAAW,GAAG,IAAI,CAAC;2CAsD3B,MAAM,KAAG,QAAQ,WAAW,CAAC;kCActC,MAAM,KAAG,QAAQ,qBAAqB,WAAW,CAAC,CAAC;kCA6BnD,MAAM,KAAG,QAAQ,WAAW,CAAC;iCAc9B,MAAM,gBAAgB,wBAAwB,KAAG,QAAQ,WAAW,CAAC;uCAc/D,MAAM,cAAc,8BAA8B,KAAG,QAAQ,WAAW,CAAC;;CA0BtI,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -101,12 +101,38 @@ export const useBusiness = () => {
|
|
|
101
101
|
throw error;
|
|
102
102
|
}
|
|
103
103
|
}, [sdk, isInitialized]);
|
|
104
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Admin: Get all businesses with optional filtering
|
|
106
|
+
*
|
|
107
|
+
* @param options - Filter and pagination options
|
|
108
|
+
* @returns Promise resolving to paginated businesses
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Get all businesses
|
|
113
|
+
* const { data } = await getBusinesses();
|
|
114
|
+
*
|
|
115
|
+
* // Filter by tag
|
|
116
|
+
* const tagged = await getBusinesses({ tag: 'restaurant' });
|
|
117
|
+
*
|
|
118
|
+
* // Multiple tags (OR match)
|
|
119
|
+
* const multiTag = await getBusinesses({ tag: ['restaurant', 'cafe'] });
|
|
120
|
+
*
|
|
121
|
+
* // With search and pagination
|
|
122
|
+
* const filtered = await getBusinesses({
|
|
123
|
+
* search: 'coffee',
|
|
124
|
+
* active: true,
|
|
125
|
+
* page: 1,
|
|
126
|
+
* limit: 20
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
const getBusinesses = useCallback(async (options) => {
|
|
105
131
|
if (!isInitialized || !sdk) {
|
|
106
132
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
107
133
|
}
|
|
108
134
|
try {
|
|
109
|
-
const result = await sdk.businesses.getBusinesses();
|
|
135
|
+
const result = await sdk.businesses.getBusinesses(options);
|
|
110
136
|
return result;
|
|
111
137
|
}
|
|
112
138
|
catch (error) {
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import type { CampaignClaimRequestDTO, CampaignDTO, CampaignClaimDTO, CampaignTriggerDTO, PaginatedResponseDTO, CampaignClaimIncludeRelation, CampaignIncludeRelation, SortOrder } from '@explorins/pers-
|
|
1
|
+
import type { CampaignClaimRequestDTO, CampaignDTO, CampaignClaimDTO, CampaignTriggerDTO, PaginatedResponseDTO, CampaignClaimIncludeRelation, CampaignIncludeRelation, SortOrder } from '@explorins/pers-sdk';
|
|
2
2
|
import type { CampaignClaimFilters } from '@explorins/pers-sdk/campaign';
|
|
3
3
|
export type { CampaignClaimFilters } from '@explorins/pers-sdk/campaign';
|
|
4
|
+
export type { CampaignFilterOptions } from '@explorins/pers-sdk';
|
|
4
5
|
/**
|
|
5
6
|
* Options for fetching campaigns
|
|
7
|
+
* @deprecated Use CampaignFilterOptions from '@explorins/pers-sdk/campaign' instead
|
|
6
8
|
*/
|
|
7
9
|
export interface GetCampaignsOptions {
|
|
8
|
-
/** Filter by tag */
|
|
9
|
-
|
|
10
|
+
/** Filter by tag(s) - single tag or array for OR match */
|
|
11
|
+
tags?: string | string[];
|
|
12
|
+
/** Free text search across name and description (case-insensitive) */
|
|
13
|
+
search?: string;
|
|
10
14
|
/** Filter by business ID */
|
|
11
15
|
businessId?: string;
|
|
16
|
+
/** Filter campaigns starting on or after this date */
|
|
17
|
+
startDate?: Date | string;
|
|
18
|
+
/** Filter campaigns ending on or before this date */
|
|
19
|
+
endDate?: Date | string;
|
|
12
20
|
/** Page number (1-indexed) */
|
|
13
21
|
page?: number;
|
|
14
22
|
/** Items per page */
|
|
@@ -17,7 +25,7 @@ export interface GetCampaignsOptions {
|
|
|
17
25
|
sortBy?: 'name' | 'createdAt' | 'startDate';
|
|
18
26
|
/** Sort order */
|
|
19
27
|
sortOrder?: SortOrder;
|
|
20
|
-
/** Relations to include: 'triggerSources', 'businesses' */
|
|
28
|
+
/** Relations to include: 'triggerSources', 'businesses', 'claimCount' */
|
|
21
29
|
include?: CampaignIncludeRelation[];
|
|
22
30
|
}
|
|
23
31
|
export declare const useCampaigns: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCampaigns.d.ts","sourceRoot":"","sources":["../../src/hooks/useCampaigns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,SAAS,
|
|
1
|
+
{"version":3,"file":"useCampaigns.d.ts","sourceRoot":"","sources":["../../src/hooks/useCampaigns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,SAAS,EAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,qDAAqD;IACrD,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,WA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
-
* const { data } = await getActiveCampaigns({
|
|
23
|
+
* // Filter by date range
|
|
24
|
+
* const { data } = await getActiveCampaigns({
|
|
25
|
+
* startDate: '2026-05-01',
|
|
26
|
+
* endDate: '2026-12-31'
|
|
27
|
+
* });
|
|
25
28
|
*
|
|
26
|
-
* //
|
|
27
|
-
* const { data } = await getActiveCampaigns({
|
|
29
|
+
* // Get campaigns with claim count
|
|
30
|
+
* const { data } = await getActiveCampaigns({ include: ['claimCount'] });
|
|
31
|
+
* data.forEach(c => console.log(`${c.name}: ${c.claimCount} claims`));
|
|
28
32
|
* ```
|
|
29
33
|
*/
|
|
30
34
|
const getActiveCampaigns = useCallback(async (options) => {
|
|
@@ -47,7 +51,7 @@ export const useCampaigns = () => {
|
|
|
47
51
|
* Get campaign by ID with optional include relations
|
|
48
52
|
*
|
|
49
53
|
* @param campaignId - The campaign ID
|
|
50
|
-
* @param include - Relations to include: 'triggerSources', 'businesses'
|
|
54
|
+
* @param include - Relations to include: 'triggerSources', 'businesses', 'claimCount'
|
|
51
55
|
* @returns Promise resolving to campaign data
|
|
52
56
|
*
|
|
53
57
|
* @example
|
|
@@ -55,6 +59,10 @@ export const useCampaigns = () => {
|
|
|
55
59
|
* // Get campaign with all related data
|
|
56
60
|
* const campaign = await getCampaignById('campaign-123', ['triggerSources', 'businesses']);
|
|
57
61
|
* console.log('Trigger sources:', campaign.included?.triggerSources);
|
|
62
|
+
*
|
|
63
|
+
* // Get campaign with claim count
|
|
64
|
+
* const campaign = await getCampaignById('campaign-123', ['claimCount']);
|
|
65
|
+
* console.log('Total claims:', campaign.claimCount);
|
|
58
66
|
* ```
|
|
59
67
|
*/
|
|
60
68
|
const getCampaignById = useCallback(async (campaignId, include) => {
|
|
@@ -206,8 +214,13 @@ export const useCampaigns = () => {
|
|
|
206
214
|
* // Get only active campaigns with trigger sources
|
|
207
215
|
* const { data } = await getAllCampaigns({ active: true, include: ['triggerSources'] });
|
|
208
216
|
*
|
|
209
|
-
* //
|
|
210
|
-
* const { data } = await getAllCampaigns({
|
|
217
|
+
* // Filter by date range with claim count
|
|
218
|
+
* const { data } = await getAllCampaigns({
|
|
219
|
+
* startDate: '2026-05-01',
|
|
220
|
+
* endDate: '2026-12-31',
|
|
221
|
+
* include: ['claimCount']
|
|
222
|
+
* });
|
|
223
|
+
* data.forEach(c => console.log(`${c.name}: ${c.claimCount} claims`));
|
|
211
224
|
*
|
|
212
225
|
* // With pagination and sorting
|
|
213
226
|
* const { data } = await getAllCampaigns({
|
|
@@ -234,7 +247,16 @@ export const useCampaigns = () => {
|
|
|
234
247
|
/**
|
|
235
248
|
* Admin: Get campaign claims with optional filters and include relations
|
|
236
249
|
*
|
|
237
|
-
* @param filters - Optional filters for campaign, user,
|
|
250
|
+
* @param filters - Optional filters for campaign, user, business, and date range
|
|
251
|
+
* @param filters.campaignId - Filter by specific campaign ID
|
|
252
|
+
* @param filters.userId - Filter by user ID
|
|
253
|
+
* @param filters.businessId - Filter by business ID
|
|
254
|
+
* @param filters.dateFrom - Filter claims created on or after this date (ISO 8601 format)
|
|
255
|
+
* @param filters.dateTo - Filter claims created on or before this date (ISO 8601 format)
|
|
256
|
+
* @param filters.page - Page number (1-indexed)
|
|
257
|
+
* @param filters.limit - Items per page
|
|
258
|
+
* @param filters.sortBy - Field to sort by
|
|
259
|
+
* @param filters.sortOrder - Sort direction
|
|
238
260
|
* @param include - Relations to include: 'campaign', 'user', 'business'
|
|
239
261
|
* @returns Promise resolving to paginated campaign claims
|
|
240
262
|
*
|
|
@@ -245,6 +267,12 @@ export const useCampaigns = () => {
|
|
|
245
267
|
*
|
|
246
268
|
* // Get claims for a specific campaign
|
|
247
269
|
* const { data } = await getCampaignClaims({ campaignId: 'campaign-123' }, ['user', 'business']);
|
|
270
|
+
*
|
|
271
|
+
* // Filter by date range
|
|
272
|
+
* const { data } = await getCampaignClaims({
|
|
273
|
+
* dateFrom: '2026-01-01',
|
|
274
|
+
* dateTo: '2026-03-31'
|
|
275
|
+
* }, ['campaign']);
|
|
248
276
|
* ```
|
|
249
277
|
*/
|
|
250
278
|
const getCampaignClaims = useCallback(async (filters, include) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDonations.d.ts","sourceRoot":"","sources":["../../src/hooks/useDonations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useDonations.d.ts","sourceRoot":"","sources":["../../src/hooks/useDonations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,YAAY;4BAgBwB,QAAQ,qBAAqB,eAAe,CAAC,CAAC;;CAkB9F,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PurchaseTokenDTO, PurchaseDTO, PaginatedResponseDTO } from '@explorins/pers-
|
|
1
|
+
import type { PurchaseTokenDTO, PurchaseDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
|
|
2
2
|
export declare const usePurchases: () => {
|
|
3
|
-
createPaymentIntent: (amount: number, currency: string, receiptEmail: string, description: string) => Promise<import("@explorins/pers-
|
|
3
|
+
createPaymentIntent: (amount: number, currency: string, receiptEmail: string, description: string) => Promise<import("@explorins/pers-sdk").PaymentIntentDTO>;
|
|
4
4
|
getActivePurchaseTokens: () => Promise<PaginatedResponseDTO<PurchaseTokenDTO>>;
|
|
5
5
|
getAllUserPurchases: () => Promise<PaginatedResponseDTO<PurchaseDTO>>;
|
|
6
6
|
isAvailable: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePurchases.d.ts","sourceRoot":"","sources":["../../src/hooks/usePurchases.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"usePurchases.d.ts","sourceRoot":"","sources":["../../src/hooks/usePurchases.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE/F,eAAO,MAAM,YAAY;kCAIb,MAAM,YACJ,MAAM,gBACF,MAAM,eACP,MAAM;mCAeiC,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;+BAcnD,QAAQ,qBAAqB,WAAW,CAAC,CAAC;;CAuB7F,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { OnStatusUpdateFn } from './useTransactionSigner';
|
|
2
|
-
import type { RedemptionCreateRequestDTO, RedemptionDTO, RedemptionRedeemDTO, RedemptionRedeemRequestResponseDTO, RedemptionTypeDTO, PaginatedResponseDTO, RedemptionRedeemIncludeRelation, ProcessRecordStatus, DynamicContext } from '@explorins/pers-
|
|
2
|
+
import type { RedemptionCreateRequestDTO, RedemptionDTO, RedemptionRedeemDTO, RedemptionRedeemRequestResponseDTO, RedemptionTypeDTO, PaginatedResponseDTO, RedemptionRedeemIncludeRelation, RedemptionIncludeRelation, ProcessRecordStatus, DynamicContext, SortOrder } from '@explorins/pers-sdk';
|
|
3
3
|
import type { RedemptionRedeemFilters } from '@explorins/pers-sdk/redemption';
|
|
4
4
|
import type { PaginationOptions } from '@explorins/pers-sdk';
|
|
5
|
-
export type { RedemptionRedeemFilters } from '@explorins/pers-sdk/redemption';
|
|
5
|
+
export type { RedemptionRedeemFilters, RedemptionFilterOptions } from '@explorins/pers-sdk/redemption';
|
|
6
|
+
/**
|
|
7
|
+
* Options for fetching redemptions with filtering and pagination
|
|
8
|
+
*/
|
|
9
|
+
export interface GetRedemptionsOptions {
|
|
10
|
+
/** Filter by active status (Admin only - regular users always see active offers) */
|
|
11
|
+
active?: boolean;
|
|
12
|
+
/** Free text search across name, description, tags (case-insensitive) */
|
|
13
|
+
search?: string;
|
|
14
|
+
/** Filter by tag(s) - single tag or array for OR match */
|
|
15
|
+
tags?: string | string[];
|
|
16
|
+
/** Filter redemptions starting on or after this date */
|
|
17
|
+
startDate?: Date | string;
|
|
18
|
+
/** Filter redemptions ending on or before this date */
|
|
19
|
+
endDate?: Date | string;
|
|
20
|
+
/** Relations to include: 'redeemCount' */
|
|
21
|
+
include?: RedemptionIncludeRelation[];
|
|
22
|
+
/** Page number (1-indexed) */
|
|
23
|
+
page?: number;
|
|
24
|
+
/** Results per page */
|
|
25
|
+
limit?: number;
|
|
26
|
+
/** Field to sort by */
|
|
27
|
+
sortBy?: 'name' | 'createdAt' | 'startDate';
|
|
28
|
+
/** Sort direction */
|
|
29
|
+
sortOrder?: SortOrder;
|
|
30
|
+
}
|
|
6
31
|
export declare const useRedemptions: () => {
|
|
7
|
-
getRedemptions: (options?:
|
|
8
|
-
active?: boolean;
|
|
9
|
-
}) => Promise<PaginatedResponseDTO<RedemptionDTO>>;
|
|
32
|
+
getRedemptions: (options?: GetRedemptionsOptions) => Promise<PaginatedResponseDTO<RedemptionDTO>>;
|
|
10
33
|
getUserRedemptions: (filters?: {
|
|
11
34
|
redemptionId?: string;
|
|
12
35
|
status?: ProcessRecordStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedemptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useRedemptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kCAAkC,EAClC,iBAAiB,EACjB,oBAAoB,EACpB,+BAA+B,EAC/B,mBAAmB,EACnB,cAAc,
|
|
1
|
+
{"version":3,"file":"useRedemptions.d.ts","sourceRoot":"","sources":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AC,MAAM,CAAC,EAAE,mBAAmB,CAAA;KAAE,YACvD,iBAAiB,YACjB,+BAA+B,EAAE,KAC1C,QAAQ,qBAAqB,mBAAmB,CAAC,CAAC;2BAkErC,MAAM,YACV;QAAE,OAAO,CAAC,EAAE,cAAc,CAAC;QAAC,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAAE,KACxE,QAAQ,kCAAkC,CAAC;8BAmHG,QAAQ,qBAAqB,iBAAiB,CAAC,CAAC;qCA9BrF,uBAAuB,YACvB,+BAA+B,EAAE,KAC1C,QAAQ,qBAAqB,mBAAmB,CAAC,CAAC;uCAcO,0BAA0B,KAAG,QAAQ,aAAa,CAAC;qCA4BrD,MAAM,kBAAkB,0BAA0B,KAAG,QAAQ,aAAa,CAAC;2CAcrE,MAAM,KAAG,QAAQ,aAAa,CAAC;;;;CA4BhG,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -11,6 +11,47 @@ export const useRedemptions = () => {
|
|
|
11
11
|
* **Administrators:** Can see all redemptions and filter by active/inactive status
|
|
12
12
|
*
|
|
13
13
|
* The backend enforces permission-based filtering automatically.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Filter and pagination options
|
|
16
|
+
* @param options.active - Filter by active status (Admin only)
|
|
17
|
+
* @param options.search - Free text search across name, description, tags
|
|
18
|
+
* @param options.startDate - Filter redemptions starting on or after this date
|
|
19
|
+
* @param options.endDate - Filter redemptions ending on or before this date
|
|
20
|
+
* @param options.include - Relations to include: 'redeemCount'
|
|
21
|
+
* @param options.page - Page number (1-indexed)
|
|
22
|
+
* @param options.limit - Results per page
|
|
23
|
+
* @param options.sortBy - Field to sort by ('name' | 'createdAt')
|
|
24
|
+
* @param options.sortOrder - Sort direction ('ASC' | 'DESC')
|
|
25
|
+
*
|
|
26
|
+
* @example Basic usage
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const { data: offers } = await getRedemptions();
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Filter by date range
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const { data: dateFiltered } = await getRedemptions({
|
|
34
|
+
* startDate: '2026-05-01',
|
|
35
|
+
* endDate: '2026-06-30'
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example Get redemptions with redeem count
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const { data: offers } = await getRedemptions({ include: ['redeemCount'] });
|
|
42
|
+
* offers.forEach(o => console.log(`${o.name}: ${o.redeemCount} redeems`));
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example Search with pagination
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const { data, pagination } = await getRedemptions({
|
|
48
|
+
* search: 'discount',
|
|
49
|
+
* page: 1,
|
|
50
|
+
* limit: 10,
|
|
51
|
+
* sortBy: 'name',
|
|
52
|
+
* sortOrder: 'ASC'
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
14
55
|
*/
|
|
15
56
|
const getRedemptions = useCallback(async (options) => {
|
|
16
57
|
if (!isInitialized || !sdk) {
|
|
@@ -166,7 +207,17 @@ export const useRedemptions = () => {
|
|
|
166
207
|
*
|
|
167
208
|
* Retrieves all redemption redeems across the platform with filtering.
|
|
168
209
|
*
|
|
169
|
-
* @param filters - Optional filters for user, redemption, and pagination
|
|
210
|
+
* @param filters - Optional filters for user, redemption, date range, and pagination
|
|
211
|
+
* @param filters.userId - Filter by user ID
|
|
212
|
+
* @param filters.redemptionId - Filter by redemption offer ID
|
|
213
|
+
* @param filters.businessId - Filter by business ID (admin only)
|
|
214
|
+
* @param filters.status - Filter by processing status (PENDING, PROCESSING, COMPLETED, FAILED)
|
|
215
|
+
* @param filters.dateFrom - Filter redeems created on or after this date (ISO 8601 format)
|
|
216
|
+
* @param filters.dateTo - Filter redeems created on or before this date (ISO 8601 format)
|
|
217
|
+
* @param filters.page - Page number (1-indexed)
|
|
218
|
+
* @param filters.limit - Items per page
|
|
219
|
+
* @param filters.sortBy - Field to sort by
|
|
220
|
+
* @param filters.sortOrder - Sort direction
|
|
170
221
|
* @param include - Relations to include: 'redemption', 'user', 'business'
|
|
171
222
|
* @returns Promise resolving to paginated redemption redeems
|
|
172
223
|
*
|
|
@@ -180,6 +231,12 @@ export const useRedemptions = () => {
|
|
|
180
231
|
* { userId: 'user-123' },
|
|
181
232
|
* ['redemption']
|
|
182
233
|
* );
|
|
234
|
+
*
|
|
235
|
+
* // Filter by date range
|
|
236
|
+
* const { data } = await getRedemptionRedeems({
|
|
237
|
+
* dateFrom: '2026-01-01',
|
|
238
|
+
* dateTo: '2026-03-31'
|
|
239
|
+
* }, ['user', 'redemption']);
|
|
183
240
|
* ```
|
|
184
241
|
*/
|
|
185
242
|
const getRedemptionRedeems = useCallback(async (filters, include) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TenantPublicDTO, TenantClientConfigDTO, AdminDTO, PaginatedResponseDTO } from '@explorins/pers-
|
|
1
|
+
import type { TenantPublicDTO, TenantClientConfigDTO, AdminDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
|
|
2
2
|
export declare const useTenants: () => {
|
|
3
3
|
getTenantInfo: () => Promise<TenantPublicDTO>;
|
|
4
4
|
getClientConfig: () => Promise<TenantClientConfigDTO>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenants.d.ts","sourceRoot":"","sources":["../../src/hooks/useTenants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useTenants.d.ts","sourceRoot":"","sources":["../../src/hooks/useTenants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAElH,eAAO,MAAM,UAAU;yBAGuB,QAAQ,eAAe,CAAC;2BActB,QAAQ,qBAAqB,CAAC;yBAchC,QAAQ,MAAM,CAAC;qBAcnB,QAAQ,qBAAqB,QAAQ,CAAC,CAAC;;CAqBhF,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC"}
|