@tagadapay/plugin-sdk 1.0.19 → 1.0.21
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/dist/react/hooks/useOffers.js +10 -13
- package/package.json +1 -1
|
@@ -12,19 +12,16 @@ export function useOffers(options) {
|
|
|
12
12
|
setIsLoading(true);
|
|
13
13
|
setError(null);
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new Error(`Failed to fetch offer ${offerId}: ${response.statusText}`);
|
|
24
|
-
}
|
|
25
|
-
return response.json();
|
|
15
|
+
const response = await fetch(`${environment.apiConfig.baseUrl}/api/v1/${apiService.getStoredStoreId()}/offers`, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
},
|
|
26
20
|
});
|
|
27
|
-
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
throw new Error(`Failed to fetch offers: ${response.statusText}`);
|
|
23
|
+
}
|
|
24
|
+
const fetchedOffers = await response.json();
|
|
28
25
|
setOffers(fetchedOffers);
|
|
29
26
|
}
|
|
30
27
|
catch (err) {
|
|
@@ -35,7 +32,7 @@ export function useOffers(options) {
|
|
|
35
32
|
finally {
|
|
36
33
|
setIsLoading(false);
|
|
37
34
|
}
|
|
38
|
-
}, [
|
|
35
|
+
}, [environment.apiConfig.baseUrl, offerIds, enabled]);
|
|
39
36
|
const createCheckoutSession = useCallback(async (offerId, sessionOptions) => {
|
|
40
37
|
const response = await fetch(`${environment.apiConfig.baseUrl}/api/v1/offers/${offerId}/checkout`, {
|
|
41
38
|
method: 'POST',
|