omnipay-savings-sdk
Version:
Omnipay Savings SDK
39 lines (38 loc) • 2.44 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
require("react-native-gesture-handler");
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
const SDKConfigContext_1 = require("./contexts/SDKConfigContext");
const QueryClient_1 = require("./contexts/QueryClient");
const ToastProvider_1 = require("./contexts/ToastProvider");
const navigation_1 = require("./navigation");
const StoreContext_1 = require("./contexts/StoreContext");
const SavingsSDKCore = () => {
return ((0, jsx_runtime_1.jsx)(react_native_safe_area_context_1.SafeAreaProvider, { children: (0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureHandlerRootView, Object.assign({ style: { flex: 1 } }, { children: (0, jsx_runtime_1.jsx)(StoreContext_1.StoreProvider, { children: (0, jsx_runtime_1.jsx)(ToastProvider_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(QueryClient_1.QueryClientProvider, { children: (0, jsx_runtime_1.jsx)(navigation_1.NavigationLayout, {}) }) }) }) })) }));
};
const SavingsSDK = ({ config }) => {
// Default config values (fallbacks)
const defaultConfig = {
apiKey: '',
primaryColor: 'rgba(166, 130, 255, 1)',
onClose: () => {
console.log('SDK close requested - parent app should handle this');
},
onTokenExpired: () => {
console.log('Token expired - parent app should handle authentication refresh or logout');
},
env: 'dev',
};
// Merge provided config with defaults
const mergedConfig = {
apiKey: (config === null || config === void 0 ? void 0 : config.apiKey) || defaultConfig.apiKey,
primaryColor: (config === null || config === void 0 ? void 0 : config.primaryColor) || defaultConfig.primaryColor,
onClose: (config === null || config === void 0 ? void 0 : config.onClose) || defaultConfig.onClose,
onTokenExpired: (config === null || config === void 0 ? void 0 : config.onTokenExpired) || defaultConfig.onTokenExpired,
env: config === null || config === void 0 ? void 0 : config.env,
};
return ((0, jsx_runtime_1.jsx)(SDKConfigContext_1.SDKConfigProvider, Object.assign({ config: mergedConfig }, { children: (0, jsx_runtime_1.jsx)(SavingsSDKCore, {}) })));
};
exports.default = SavingsSDK;
;