@tagadapay/plugin-sdk 2.6.12 → 2.6.13
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 +1129 -1129
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/v2/core/utils/pluginConfig.js +45 -12
- package/dist/v2/index.d.ts +2 -3
- package/dist/v2/index.js +1 -1
- package/dist/v2/react/index.d.ts +1 -3
- package/dist/v2/react/index.js +0 -1
- package/dist/v2/react/providers/TagadaProvider.js +5 -5
- package/package.json +91 -91
- package/dist/v2/react/hooks/useDiscountQuery.d.ts +0 -79
- package/dist/v2/react/hooks/useDiscountQuery.js +0 -24
|
@@ -38,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
38
38
|
borderTop: '1.5px solid #9ca3af',
|
|
39
39
|
borderRadius: '50%',
|
|
40
40
|
animation: 'tagada-spin 1s linear infinite',
|
|
41
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
-
@keyframes tagada-spin {
|
|
43
|
-
0% { transform: rotate(0deg); }
|
|
44
|
-
100% { transform: rotate(360deg); }
|
|
45
|
-
}
|
|
41
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
+
@keyframes tagada-spin {
|
|
43
|
+
0% { transform: rotate(0deg); }
|
|
44
|
+
100% { transform: rotate(360deg); }
|
|
45
|
+
}
|
|
46
46
|
` })] }));
|
|
47
47
|
const TagadaContext = createContext(null);
|
|
48
48
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
|
|
@@ -80,33 +80,66 @@ const loadLocalDevConfig = async (configVariant = 'default') => {
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Helper to get content from meta tag
|
|
85
|
+
*/
|
|
86
|
+
const getMetaContent = (name) => {
|
|
87
|
+
const metaTag = document.querySelector(`meta[name="${name}"]`);
|
|
88
|
+
return metaTag?.getAttribute('content') || undefined;
|
|
89
|
+
};
|
|
83
90
|
/**
|
|
84
91
|
* Load production config from headers and meta tags
|
|
85
92
|
*/
|
|
86
93
|
const loadProductionConfig = async () => {
|
|
87
94
|
try {
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
// Try to get headers first
|
|
96
|
+
let storeId;
|
|
97
|
+
let accountId;
|
|
98
|
+
let basePath;
|
|
99
|
+
try {
|
|
100
|
+
const response = await fetch(window.location.href, { method: 'HEAD' });
|
|
101
|
+
storeId = response.headers.get('X-Plugin-Store-Id') || undefined;
|
|
102
|
+
accountId = response.headers.get('X-Plugin-Account-Id') || undefined;
|
|
103
|
+
basePath = response.headers.get('X-Plugin-Base-Path') || undefined;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Headers fetch failed, will fallback to meta tags
|
|
107
|
+
}
|
|
108
|
+
// Fallback to meta tags if headers are not available
|
|
109
|
+
if (!storeId) {
|
|
110
|
+
storeId = getMetaContent('x-plugin-store-id');
|
|
111
|
+
}
|
|
112
|
+
if (!accountId) {
|
|
113
|
+
accountId = getMetaContent('x-plugin-account-id');
|
|
114
|
+
}
|
|
115
|
+
if (!basePath) {
|
|
116
|
+
basePath = getMetaContent('x-plugin-base-path') || '/';
|
|
117
|
+
}
|
|
93
118
|
// Get deployment config from meta tags
|
|
94
119
|
let config = {};
|
|
95
120
|
try {
|
|
96
|
-
const
|
|
97
|
-
const encodedConfig = configMeta?.getAttribute('content');
|
|
121
|
+
const encodedConfig = getMetaContent('x-plugin-config');
|
|
98
122
|
if (encodedConfig) {
|
|
99
123
|
const decodedConfig = decodeURIComponent(encodedConfig);
|
|
100
124
|
config = JSON.parse(decodedConfig);
|
|
101
125
|
}
|
|
102
126
|
}
|
|
103
|
-
catch {
|
|
104
|
-
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.warn('Failed to parse plugin config from meta tag:', error);
|
|
129
|
+
}
|
|
130
|
+
// Final validation and warnings
|
|
131
|
+
if (!storeId) {
|
|
132
|
+
console.warn('⚠️ Plugin config: Store ID not found in headers or meta tags');
|
|
105
133
|
}
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
if (!accountId) {
|
|
135
|
+
console.warn('⚠️ Plugin config: Account ID not found in headers or meta tags');
|
|
136
|
+
}
|
|
137
|
+
const result = { storeId, accountId, basePath: basePath || '/', config };
|
|
138
|
+
console.log('🏭 Using production plugin config:', result);
|
|
139
|
+
return result;
|
|
108
140
|
}
|
|
109
|
-
catch {
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.warn('Failed to load production config, using defaults:', error);
|
|
110
143
|
return { basePath: '/', config: {} };
|
|
111
144
|
}
|
|
112
145
|
};
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -20,6 +20,5 @@ export type { ShippingRate, ShippingRatesResponse } from './core/resources/shipp
|
|
|
20
20
|
export type { ApplyDiscountResponse, Discount, DiscountCodeValidation, RemoveDiscountResponse } from './core/resources/discounts';
|
|
21
21
|
export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './core/resources/vipOffers';
|
|
22
22
|
export type { StoreConfig } from './core/resources/storeConfig';
|
|
23
|
-
export type {
|
|
24
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency,
|
|
25
|
-
export type { StoreDiscount } from './react';
|
|
23
|
+
export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelContextUpdateRequest, FunnelContextUpdateResponse } from './core/resources/funnel';
|
|
24
|
+
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency, useDiscounts, useExpressPaymentMethods, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useShippingRates, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useVipOffers, useFunnel, useSimpleFunnel } from './react';
|
package/dist/v2/index.js
CHANGED
|
@@ -12,4 +12,4 @@ export * from './core/utils/currency';
|
|
|
12
12
|
export * from './core/utils/pluginConfig';
|
|
13
13
|
export * from './core/utils/products';
|
|
14
14
|
// React exports (hooks and components only, types are exported above)
|
|
15
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency,
|
|
15
|
+
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency, useDiscounts, useExpressPaymentMethods, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useShippingRates, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useVipOffers, useFunnel, useSimpleFunnel } from './react';
|
package/dist/v2/react/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { usePluginConfig } from './hooks/usePluginConfig';
|
|
|
15
15
|
export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQuery } from './hooks/useApiQuery';
|
|
16
16
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
17
17
|
export { useCurrency } from './hooks/useCurrency';
|
|
18
|
-
export { useDiscountQuery } from './hooks/useDiscountQuery';
|
|
19
18
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
20
19
|
export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
|
|
21
20
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
@@ -39,9 +38,7 @@ export type { ExtractedAddress, GooglePlaceDetails, GooglePrediction, UseGoogleA
|
|
|
39
38
|
export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
|
|
40
39
|
export type { UsePluginConfigOptions, UsePluginConfigResult } from './hooks/usePluginConfig';
|
|
41
40
|
export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
|
|
42
|
-
export type { StoreDiscount, UseDiscountQueryOptions as UseDiscountOptions, UseDiscountQueryResult as UseDiscountResult } from './hooks/useDiscountQuery';
|
|
43
41
|
export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
|
|
44
|
-
export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, UseFunnelOptions, UseFunnelResult } from './hooks/useFunnel';
|
|
45
42
|
export type { UseOffersQueryOptions as UseOffersOptions, UseOffersQueryResult as UseOffersResult } from './hooks/useOffersQuery';
|
|
46
43
|
export type { UseOrderBumpQueryOptions as UseOrderBumpOptions, UseOrderBumpQueryResult as UseOrderBumpResult } from './hooks/useOrderBumpQuery';
|
|
47
44
|
export type { UseOrderQueryOptions as UseOrderOptions, UseOrderQueryResult as UseOrderResult } from './hooks/useOrderQuery';
|
|
@@ -53,5 +50,6 @@ export type { UseShippingRatesQueryOptions as UseShippingRatesOptions, UseShippi
|
|
|
53
50
|
export type { UseStoreConfigQueryOptions as UseStoreConfigOptions, UseStoreConfigQueryResult as UseStoreConfigResult } from './hooks/useStoreConfigQuery';
|
|
54
51
|
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
|
|
55
52
|
export type { UseVipOffersQueryOptions as UseVipOffersOptions, UseVipOffersQueryResult as UseVipOffersResult } from './hooks/useVipOffersQuery';
|
|
53
|
+
export type { UseFunnelOptions, UseFunnelResult, FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext } from './hooks/useFunnel';
|
|
56
54
|
export { formatMoney } from '../../react/utils/money';
|
|
57
55
|
export type OrderItem = import('../core/utils/order').OrderLineItem;
|
package/dist/v2/react/index.js
CHANGED
|
@@ -19,7 +19,6 @@ export { usePluginConfig } from './hooks/usePluginConfig';
|
|
|
19
19
|
export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQuery } from './hooks/useApiQuery';
|
|
20
20
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
21
21
|
export { useCurrency } from './hooks/useCurrency';
|
|
22
|
-
export { useDiscountQuery } from './hooks/useDiscountQuery';
|
|
23
22
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
24
23
|
export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
|
|
25
24
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
@@ -41,11 +41,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
41
41
|
borderTop: '1.5px solid #9ca3af',
|
|
42
42
|
borderRadius: '50%',
|
|
43
43
|
animation: 'tagada-spin 1s linear infinite',
|
|
44
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
45
|
-
@keyframes tagada-spin {
|
|
46
|
-
0% { transform: rotate(0deg); }
|
|
47
|
-
100% { transform: rotate(360deg); }
|
|
48
|
-
}
|
|
44
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
45
|
+
@keyframes tagada-spin {
|
|
46
|
+
0% { transform: rotate(0deg); }
|
|
47
|
+
100% { transform: rotate(360deg); }
|
|
48
|
+
}
|
|
49
49
|
` })] }));
|
|
50
50
|
const TagadaContext = createContext(null);
|
|
51
51
|
// Global instance tracking for TagadaProvider
|
package/package.json
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "2.6.
|
|
4
|
-
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./react": {
|
|
14
|
-
"types": "./dist/react/index.d.ts",
|
|
15
|
-
"import": "./dist/react/index.js",
|
|
16
|
-
"require": "./dist/react/index.js"
|
|
17
|
-
},
|
|
18
|
-
"./v2": {
|
|
19
|
-
"types": "./dist/v2/index.d.ts",
|
|
20
|
-
"import": "./dist/v2/index.js",
|
|
21
|
-
"require": "./dist/v2/index.js"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"lint": "echo \"No linting configured\"",
|
|
28
|
-
"test": "echo \"No tests yet\" && exit 0",
|
|
29
|
-
"dev": "tsc --watch",
|
|
30
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
31
|
-
"publish:patch": "npm version patch && npm publish",
|
|
32
|
-
"publish:minor": "npm version minor && npm publish",
|
|
33
|
-
"publish:major": "npm version major && npm publish",
|
|
34
|
-
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
35
|
-
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
36
|
-
"version:patch": "npm version patch",
|
|
37
|
-
"version:minor": "npm version minor",
|
|
38
|
-
"version:major": "npm version major",
|
|
39
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
40
|
-
"version:alpha": "npm version prerelease --preid=alpha",
|
|
41
|
-
"version:check": "node version-sync.js check",
|
|
42
|
-
"version:sync": "node version-sync.js sync",
|
|
43
|
-
"version:list": "node version-sync.js list",
|
|
44
|
-
"version:next": "node version-sync.js next",
|
|
45
|
-
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
46
|
-
},
|
|
47
|
-
"keywords": [
|
|
48
|
-
"tagadapay",
|
|
49
|
-
"cms",
|
|
50
|
-
"plugin",
|
|
51
|
-
"sdk",
|
|
52
|
-
"react",
|
|
53
|
-
"typescript"
|
|
54
|
-
],
|
|
55
|
-
"author": "Tagada Pay",
|
|
56
|
-
"license": "MIT",
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
59
|
-
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
60
|
-
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
61
|
-
"@basis-theory/web-threeds": "^1.0.1",
|
|
62
|
-
"@google-pay/button-react": "^3.0.10",
|
|
63
|
-
"@tanstack/react-query": "^5.90.2",
|
|
64
|
-
"axios": "^1.10.0",
|
|
65
|
-
"iso3166-2-db": "^2.3.11",
|
|
66
|
-
"react-intl": "^7.1.11",
|
|
67
|
-
"swr": "^2.3.6"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@types/node": "^18.0.0",
|
|
71
|
-
"@types/react": "^19",
|
|
72
|
-
"@types/react-dom": "^19",
|
|
73
|
-
"typescript": "^5.0.0"
|
|
74
|
-
},
|
|
75
|
-
"peerDependencies": {
|
|
76
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
77
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
78
|
-
},
|
|
79
|
-
"files": [
|
|
80
|
-
"dist/**/*",
|
|
81
|
-
"README.md"
|
|
82
|
-
],
|
|
83
|
-
"repository": {
|
|
84
|
-
"type": "git",
|
|
85
|
-
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
86
|
-
},
|
|
87
|
-
"bugs": {
|
|
88
|
-
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
89
|
-
},
|
|
90
|
-
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
91
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "2.6.13",
|
|
4
|
+
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react/index.d.ts",
|
|
15
|
+
"import": "./dist/react/index.js",
|
|
16
|
+
"require": "./dist/react/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./v2": {
|
|
19
|
+
"types": "./dist/v2/index.d.ts",
|
|
20
|
+
"import": "./dist/v2/index.js",
|
|
21
|
+
"require": "./dist/v2/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"lint": "echo \"No linting configured\"",
|
|
28
|
+
"test": "echo \"No tests yet\" && exit 0",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
31
|
+
"publish:patch": "npm version patch && npm publish",
|
|
32
|
+
"publish:minor": "npm version minor && npm publish",
|
|
33
|
+
"publish:major": "npm version major && npm publish",
|
|
34
|
+
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
35
|
+
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
36
|
+
"version:patch": "npm version patch",
|
|
37
|
+
"version:minor": "npm version minor",
|
|
38
|
+
"version:major": "npm version major",
|
|
39
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
40
|
+
"version:alpha": "npm version prerelease --preid=alpha",
|
|
41
|
+
"version:check": "node version-sync.js check",
|
|
42
|
+
"version:sync": "node version-sync.js sync",
|
|
43
|
+
"version:list": "node version-sync.js list",
|
|
44
|
+
"version:next": "node version-sync.js next",
|
|
45
|
+
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"tagadapay",
|
|
49
|
+
"cms",
|
|
50
|
+
"plugin",
|
|
51
|
+
"sdk",
|
|
52
|
+
"react",
|
|
53
|
+
"typescript"
|
|
54
|
+
],
|
|
55
|
+
"author": "Tagada Pay",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
59
|
+
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
60
|
+
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
61
|
+
"@basis-theory/web-threeds": "^1.0.1",
|
|
62
|
+
"@google-pay/button-react": "^3.0.10",
|
|
63
|
+
"@tanstack/react-query": "^5.90.2",
|
|
64
|
+
"axios": "^1.10.0",
|
|
65
|
+
"iso3166-2-db": "^2.3.11",
|
|
66
|
+
"react-intl": "^7.1.11",
|
|
67
|
+
"swr": "^2.3.6"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/node": "^18.0.0",
|
|
71
|
+
"@types/react": "^19",
|
|
72
|
+
"@types/react-dom": "^19",
|
|
73
|
+
"typescript": "^5.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
77
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
78
|
+
},
|
|
79
|
+
"files": [
|
|
80
|
+
"dist/**/*",
|
|
81
|
+
"README.md"
|
|
82
|
+
],
|
|
83
|
+
"repository": {
|
|
84
|
+
"type": "git",
|
|
85
|
+
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
86
|
+
},
|
|
87
|
+
"bugs": {
|
|
88
|
+
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
89
|
+
},
|
|
90
|
+
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
91
|
+
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single Discount Hook using TanStack Query
|
|
3
|
-
* Fetches a specific discount for a given store
|
|
4
|
-
*/
|
|
5
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
6
|
-
export interface StoreDiscountRuleAmount {
|
|
7
|
-
rate: number;
|
|
8
|
-
amount: number;
|
|
9
|
-
lock: boolean;
|
|
10
|
-
date: string;
|
|
11
|
-
}
|
|
12
|
-
export interface StoreDiscountRule {
|
|
13
|
-
id: string;
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
promotionId: string;
|
|
17
|
-
type: string;
|
|
18
|
-
productId: string | null;
|
|
19
|
-
minimumQuantity: number | null;
|
|
20
|
-
minimumAmount: Record<string, StoreDiscountRuleAmount> | null;
|
|
21
|
-
variantIds: string[] | null;
|
|
22
|
-
}
|
|
23
|
-
export interface StoreDiscountAction {
|
|
24
|
-
id: string;
|
|
25
|
-
createdAt: string;
|
|
26
|
-
updatedAt: string;
|
|
27
|
-
promotionId: string;
|
|
28
|
-
type: string;
|
|
29
|
-
adjustmentAmount: number | null;
|
|
30
|
-
adjustmentPercentage: number | null;
|
|
31
|
-
adjustmentType: string | null;
|
|
32
|
-
freeShipping: boolean | null;
|
|
33
|
-
priceIdToAdd: string | null;
|
|
34
|
-
productIdToAdd: string | null;
|
|
35
|
-
variantIdToAdd: string | null;
|
|
36
|
-
subscriptionFreeTrialDuration: number | null;
|
|
37
|
-
subscriptionFreeTrialDurationType: string | null;
|
|
38
|
-
targetProductId: string | null;
|
|
39
|
-
targetVariantIds: string[] | null;
|
|
40
|
-
maxQuantityDiscounted: number | null;
|
|
41
|
-
appliesOnEachItem: boolean | null;
|
|
42
|
-
}
|
|
43
|
-
export interface StoreDiscount {
|
|
44
|
-
id: string;
|
|
45
|
-
createdAt: string;
|
|
46
|
-
updatedAt: string;
|
|
47
|
-
storeId: string;
|
|
48
|
-
accountId: string;
|
|
49
|
-
name: string;
|
|
50
|
-
code: string;
|
|
51
|
-
automatic: boolean;
|
|
52
|
-
usageLimit: number | null;
|
|
53
|
-
usageCount: number;
|
|
54
|
-
startDate: string;
|
|
55
|
-
endDate: string | null;
|
|
56
|
-
enabled: boolean;
|
|
57
|
-
archived: boolean;
|
|
58
|
-
ruleOperator: string;
|
|
59
|
-
externalId: string | null;
|
|
60
|
-
combinesWithOrderLevelDiscounts: boolean;
|
|
61
|
-
combinesWithLineItemDiscounts: boolean;
|
|
62
|
-
combinesWithShippingDiscounts: boolean;
|
|
63
|
-
forceCombine: boolean;
|
|
64
|
-
isTemporary: boolean;
|
|
65
|
-
rules: StoreDiscountRule[];
|
|
66
|
-
actions: StoreDiscountAction[];
|
|
67
|
-
}
|
|
68
|
-
export interface UseDiscountQueryOptions {
|
|
69
|
-
storeId?: string;
|
|
70
|
-
discountId?: string;
|
|
71
|
-
enabled?: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface UseDiscountQueryResult<TData = StoreDiscount> {
|
|
74
|
-
discount: TData | undefined;
|
|
75
|
-
isLoading: boolean;
|
|
76
|
-
error: Error | null;
|
|
77
|
-
refetch: UseQueryResult<TData>['refetch'];
|
|
78
|
-
}
|
|
79
|
-
export declare function useDiscountQuery<TData = StoreDiscount>(options: UseDiscountQueryOptions): UseDiscountQueryResult<TData>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single Discount Hook using TanStack Query
|
|
3
|
-
* Fetches a specific discount for a given store
|
|
4
|
-
*/
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import { useApiQuery } from './useApiQuery';
|
|
7
|
-
import { usePluginConfig } from './usePluginConfig';
|
|
8
|
-
export function useDiscountQuery(options) {
|
|
9
|
-
const { storeId: storeIdFromConfig } = usePluginConfig();
|
|
10
|
-
const { storeId = storeIdFromConfig, discountId, enabled = true } = options;
|
|
11
|
-
const key = useMemo(() => ['discount', storeId, discountId], [storeId, discountId]);
|
|
12
|
-
const url = useMemo(() => {
|
|
13
|
-
if (!storeId || !discountId)
|
|
14
|
-
return null;
|
|
15
|
-
return `/api/v1/stores/${storeId}/discounts/${discountId}`;
|
|
16
|
-
}, [storeId, discountId]);
|
|
17
|
-
const query = useApiQuery(key, url, { enabled });
|
|
18
|
-
return {
|
|
19
|
-
discount: query.data,
|
|
20
|
-
isLoading: query.isLoading,
|
|
21
|
-
error: query.error || null,
|
|
22
|
-
refetch: query.refetch,
|
|
23
|
-
};
|
|
24
|
-
}
|