react-native-salespanda 0.4.3 → 0.4.5
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/lib/module/SalespandaApp.js +16 -8
- package/lib/module/SalespandaApp.js.map +1 -1
- package/lib/module/assets/images/index.js +20 -0
- package/lib/module/assets/images/index.js.map +1 -0
- package/lib/module/components/Loader.js +45 -0
- package/lib/module/components/Loader.js.map +1 -0
- package/lib/module/config/SalespandaConfig.js +17 -0
- package/lib/module/config/SalespandaConfig.js.map +1 -1
- package/lib/module/index.js +1 -32
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/Tabs/HomeScreen.js +174 -83
- package/lib/module/screens/Tabs/HomeScreen.js.map +1 -1
- package/lib/module/services/api.js +132 -0
- package/lib/module/services/api.js.map +1 -0
- package/lib/module/services/authService.js +59 -0
- package/lib/module/services/authService.js.map +1 -0
- package/lib/module/store/index.js +13 -0
- package/lib/module/store/index.js.map +1 -0
- package/lib/typescript/src/SalespandaApp.d.ts.map +1 -1
- package/lib/typescript/src/components/Loader.d.ts +11 -0
- package/lib/typescript/src/components/Loader.d.ts.map +1 -0
- package/lib/typescript/src/config/SalespandaConfig.d.ts +14 -0
- package/lib/typescript/src/config/SalespandaConfig.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -12
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/Tabs/HomeScreen.d.ts.map +1 -1
- package/lib/typescript/src/services/api.d.ts +638 -0
- package/lib/typescript/src/services/api.d.ts.map +1 -0
- package/lib/typescript/src/services/authService.d.ts +13 -0
- package/lib/typescript/src/services/authService.d.ts.map +1 -0
- package/lib/typescript/src/store/index.d.ts +36 -0
- package/lib/typescript/src/store/index.d.ts.map +1 -0
- package/package.json +9 -3
- package/react-native.config.js +8 -5
- package/src/SalespandaApp.tsx +18 -10
- package/src/components/Loader.tsx +48 -0
- package/src/config/SalespandaConfig.ts +37 -0
- package/src/index.tsx +8 -30
- package/src/screens/Tabs/HomeScreen.tsx +220 -61
- package/src/services/api.ts +173 -0
- package/src/services/authService.ts +75 -0
- package/src/store/index.ts +16 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
2
|
+
salespandaApi: import("@reduxjs/toolkit/query").CombinedState<{
|
|
3
|
+
authenticate: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
4
|
+
agent_id?: string;
|
|
5
|
+
clientId?: string;
|
|
6
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").AuthenticateResponse, "salespandaApi", unknown>;
|
|
7
|
+
spssoLogin: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
8
|
+
access_token: string;
|
|
9
|
+
app_version?: string;
|
|
10
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").SsoLoginResponse, "salespandaApi", unknown>;
|
|
11
|
+
getHome: import("@reduxjs/toolkit/query").QueryDefinition<{
|
|
12
|
+
app_version?: string;
|
|
13
|
+
tokenOverride?: string;
|
|
14
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").HomeResponse, "salespandaApi", unknown>;
|
|
15
|
+
}, never, "salespandaApi">;
|
|
16
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
17
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
18
|
+
salespandaApi: import("@reduxjs/toolkit/query").CombinedState<{
|
|
19
|
+
authenticate: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
20
|
+
agent_id?: string;
|
|
21
|
+
clientId?: string;
|
|
22
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").AuthenticateResponse, "salespandaApi", unknown>;
|
|
23
|
+
spssoLogin: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
24
|
+
access_token: string;
|
|
25
|
+
app_version?: string;
|
|
26
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").SsoLoginResponse, "salespandaApi", unknown>;
|
|
27
|
+
getHome: import("@reduxjs/toolkit/query").QueryDefinition<{
|
|
28
|
+
app_version?: string;
|
|
29
|
+
tokenOverride?: string;
|
|
30
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, import("../services/api").HomeResponse, "salespandaApi", unknown>;
|
|
31
|
+
}, never, "salespandaApi">;
|
|
32
|
+
}, undefined, import("redux").UnknownAction>;
|
|
33
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
34
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
35
|
+
export type AppDispatch = typeof store.dispatch;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/store/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAMhB,CAAC;AAIH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-salespanda",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.5",
|
|
4
|
+
"description": "React Native SDK for multi-tenant enterprise applications with product flavors support",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@eslint/eslintrc": "^3.3.1",
|
|
66
66
|
"@eslint/js": "^9.35.0",
|
|
67
67
|
"@evilmartians/lefthook": "^1.12.3",
|
|
68
|
+
"@react-native-async-storage/async-storage": "^1.21.0",
|
|
68
69
|
"@react-native-community/cli": "20.0.1",
|
|
69
70
|
"@react-native/babel-preset": "0.81.1",
|
|
70
71
|
"@react-native/eslint-config": "^0.81.1",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"@react-navigation/drawer": "^7.7.2",
|
|
75
76
|
"@react-navigation/native": "^7.1.19",
|
|
76
77
|
"@react-navigation/native-stack": "^7.6.4",
|
|
78
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
77
79
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
78
80
|
"@types/jest": "^29.5.14",
|
|
79
81
|
"@types/react": "^19.1.0",
|
|
@@ -95,20 +97,24 @@
|
|
|
95
97
|
"react-native-screens": "^4.18.0",
|
|
96
98
|
"react-native-size-matters": "^0.4.2",
|
|
97
99
|
"react-native-vector-icons": "^10.2.0",
|
|
100
|
+
"react-redux": "^9.2.0",
|
|
98
101
|
"release-it": "^19.0.4",
|
|
99
102
|
"turbo": "^2.5.6",
|
|
100
103
|
"typescript": "^5.9.2"
|
|
101
104
|
},
|
|
102
105
|
"peerDependencies": {
|
|
106
|
+
"@react-native-async-storage/async-storage": ">=1.19.0",
|
|
103
107
|
"@react-navigation/bottom-tabs": ">=6.0.0",
|
|
104
108
|
"@react-navigation/drawer": ">=6.0.0",
|
|
105
109
|
"@react-navigation/native": ">=6.0.0",
|
|
110
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
106
111
|
"react": "*",
|
|
107
112
|
"react-native": "*",
|
|
108
113
|
"react-native-gesture-handler": ">=2.0.0",
|
|
109
114
|
"react-native-reanimated": ">=3.0.0",
|
|
110
115
|
"react-native-safe-area-context": ">=4.0.0",
|
|
111
|
-
"react-native-screens": ">=3.0.0"
|
|
116
|
+
"react-native-screens": ">=3.0.0",
|
|
117
|
+
"react-redux": "^9.2.0"
|
|
112
118
|
},
|
|
113
119
|
"workspaces": [
|
|
114
120
|
"example"
|
package/react-native.config.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
ios: {
|
|
5
|
+
podspecPath: 'Salespanda.podspec',
|
|
6
|
+
},
|
|
7
|
+
android: {
|
|
8
|
+
sourceDir: './android',
|
|
9
|
+
},
|
|
5
10
|
},
|
|
6
11
|
},
|
|
7
|
-
// Assets configuration for the library
|
|
8
|
-
assets: ['./src/assets'],
|
|
9
12
|
};
|
package/src/SalespandaApp.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
|
|
|
3
3
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
4
4
|
import { StyleSheet } from 'react-native';
|
|
5
5
|
import StackNavigator from './navigation/StackNavigator';
|
|
6
|
+
import { Provider } from 'react-redux';
|
|
7
|
+
import { store } from './store';
|
|
6
8
|
import {
|
|
7
9
|
SafeAreaProvider,
|
|
8
10
|
initialWindowMetrics,
|
|
@@ -83,7 +85,11 @@ const SalespandaApp: React.FC<SalespandaAppProps> = ({
|
|
|
83
85
|
// If standalone mode, don't wrap with NavigationContainer
|
|
84
86
|
// (parent app will provide it)
|
|
85
87
|
if (standalone) {
|
|
86
|
-
return
|
|
88
|
+
return (
|
|
89
|
+
<Provider store={store}>
|
|
90
|
+
<AppContent />
|
|
91
|
+
</Provider>
|
|
92
|
+
);
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
// Navigation content with SafeAreaProvider
|
|
@@ -100,15 +106,17 @@ const SalespandaApp: React.FC<SalespandaAppProps> = ({
|
|
|
100
106
|
};
|
|
101
107
|
|
|
102
108
|
const NavigationContent = (
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
<Provider store={store}>
|
|
110
|
+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
|
111
|
+
<NavigationContainer
|
|
112
|
+
ref={navigationRef}
|
|
113
|
+
onReady={onReady}
|
|
114
|
+
theme={navTheme}
|
|
115
|
+
>
|
|
116
|
+
<AppContent />
|
|
117
|
+
</NavigationContainer>
|
|
118
|
+
</SafeAreaProvider>
|
|
119
|
+
</Provider>
|
|
112
120
|
);
|
|
113
121
|
|
|
114
122
|
// Wrap with GestureHandlerRootView only if requested
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
+
import type { ViewStyle } from 'react-native';
|
|
4
|
+
import { Colors } from '../constants/Colors';
|
|
5
|
+
import { verticalScale, moderateScale, scale } from 'react-native-size-matters';
|
|
6
|
+
|
|
7
|
+
type LoaderProps = {
|
|
8
|
+
message?: string;
|
|
9
|
+
overlay?: boolean;
|
|
10
|
+
color?: string;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Loader: React.FC<LoaderProps> = ({
|
|
15
|
+
message = 'Loading...',
|
|
16
|
+
overlay = false,
|
|
17
|
+
color = Colors.primary,
|
|
18
|
+
style,
|
|
19
|
+
}) => {
|
|
20
|
+
return (
|
|
21
|
+
<View style={[styles.container, overlay ? styles.overlay : null, style]}>
|
|
22
|
+
<ActivityIndicator size="large" color={color} />
|
|
23
|
+
{message ? <Text style={styles.text}>{message}</Text> : null}
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Loader;
|
|
29
|
+
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
container: {
|
|
32
|
+
paddingVertical: verticalScale(16),
|
|
33
|
+
paddingHorizontal: scale(12),
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
backgroundColor: Colors.white,
|
|
37
|
+
},
|
|
38
|
+
overlay: {
|
|
39
|
+
...StyleSheet.absoluteFillObject,
|
|
40
|
+
zIndex: 10,
|
|
41
|
+
backgroundColor: Colors.white50,
|
|
42
|
+
},
|
|
43
|
+
text: {
|
|
44
|
+
marginTop: verticalScale(8),
|
|
45
|
+
fontSize: moderateScale(12),
|
|
46
|
+
color: Colors.black,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -23,6 +23,21 @@ export interface SalespandaConfig {
|
|
|
23
23
|
timeout?: number;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Authentication info supplied by host app
|
|
28
|
+
* If provided, SDK will use these tokens instead of performing login
|
|
29
|
+
*/
|
|
30
|
+
auth?: {
|
|
31
|
+
/**
|
|
32
|
+
* Token to be sent as `Token` header for protected APIs
|
|
33
|
+
*/
|
|
34
|
+
token?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Access token used for SSO or other flows when required
|
|
37
|
+
*/
|
|
38
|
+
accessToken?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
26
41
|
/**
|
|
27
42
|
* Feature flags
|
|
28
43
|
*/
|
|
@@ -62,6 +77,10 @@ let globalConfig: SalespandaConfig = {
|
|
|
62
77
|
* Initialize Salespanda SDK with custom configuration
|
|
63
78
|
*/
|
|
64
79
|
export function initializeSalespanda(config: SalespandaConfig): void {
|
|
80
|
+
// Debug log for toolkit usage
|
|
81
|
+
// Helps in verifying that initializeSalespanda is being called correctly from host app
|
|
82
|
+
console.log('[Salespanda][initializeSalespanda] called with config:', config);
|
|
83
|
+
|
|
65
84
|
globalConfig = {
|
|
66
85
|
...globalConfig,
|
|
67
86
|
...config,
|
|
@@ -74,12 +93,26 @@ export function initializeSalespanda(config: SalespandaConfig): void {
|
|
|
74
93
|
...config.features,
|
|
75
94
|
},
|
|
76
95
|
};
|
|
96
|
+
|
|
97
|
+
// If host app passes tokens, make them available runtime-wide
|
|
98
|
+
if (config.auth?.token || config.auth?.accessToken) {
|
|
99
|
+
// Lazy import to avoid circular dep
|
|
100
|
+
const { setRuntimeTokens } = require('../services/api');
|
|
101
|
+
setRuntimeTokens({
|
|
102
|
+
token: config.auth?.token || null,
|
|
103
|
+
accessToken: config.auth?.accessToken || null,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
77
106
|
}
|
|
78
107
|
|
|
79
108
|
/**
|
|
80
109
|
* Get current Salespanda configuration
|
|
81
110
|
*/
|
|
82
111
|
export function getSalespandaConfig(): SalespandaConfig {
|
|
112
|
+
console.log(
|
|
113
|
+
'[Salespanda][getSalespandaConfig] returning config:',
|
|
114
|
+
globalConfig
|
|
115
|
+
);
|
|
83
116
|
return globalConfig;
|
|
84
117
|
}
|
|
85
118
|
|
|
@@ -87,6 +120,10 @@ export function getSalespandaConfig(): SalespandaConfig {
|
|
|
87
120
|
* Reset configuration to defaults
|
|
88
121
|
*/
|
|
89
122
|
export function resetSalespandaConfig(): void {
|
|
123
|
+
console.log(
|
|
124
|
+
'[Salespanda][resetSalespandaConfig] resetting config to defaults'
|
|
125
|
+
);
|
|
126
|
+
|
|
90
127
|
globalConfig = {
|
|
91
128
|
theme: {
|
|
92
129
|
primaryColor: '#4a148c',
|
package/src/index.tsx
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Salespanda SDK
|
|
3
|
-
*
|
|
4
|
-
* This SDK can be used in two ways:
|
|
5
|
-
*
|
|
6
|
-
* 1. As a complete standalone app:
|
|
7
|
-
* import SalespandaApp from 'react-native-salespanda';
|
|
8
|
-
* <SalespandaApp />
|
|
9
|
-
*
|
|
10
|
-
* 2. As individual components/screens in your app:
|
|
11
|
-
* import { HomeScreen, ProfileScreen } from 'react-native-salespanda';
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Import gesture handler at the very top
|
|
15
|
-
|
|
16
|
-
// ============================================
|
|
17
|
-
// MAIN APP EXPORT (Default)
|
|
18
|
-
// ============================================
|
|
19
1
|
export { default } from './SalespandaApp';
|
|
20
2
|
export { default as SalespandaApp } from './SalespandaApp';
|
|
21
3
|
export type { SalespandaAppProps } from './SalespandaApp';
|
|
22
4
|
|
|
23
|
-
// ============================================
|
|
24
|
-
// CONFIGURATION
|
|
25
|
-
// ============================================
|
|
26
5
|
export {
|
|
27
6
|
initializeSalespanda,
|
|
28
7
|
getSalespandaConfig,
|
|
@@ -30,22 +9,21 @@ export {
|
|
|
30
9
|
} from './config/SalespandaConfig';
|
|
31
10
|
export type { SalespandaConfig } from './config/SalespandaConfig';
|
|
32
11
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
export {
|
|
13
|
+
login,
|
|
14
|
+
logout,
|
|
15
|
+
isAuthenticated,
|
|
16
|
+
getCurrentUser,
|
|
17
|
+
getCurrentToken,
|
|
18
|
+
} from './services/authService';
|
|
19
|
+
|
|
36
20
|
export { getFlavorConfig } from './config/FlavorConfig';
|
|
37
21
|
export { default as FlavorConfig } from './config/FlavorConfig';
|
|
38
22
|
|
|
39
|
-
// ============================================
|
|
40
|
-
// NAVIGATION COMPONENTS
|
|
41
|
-
// ============================================
|
|
42
23
|
export { default as AppNavigator } from './navigation/AppNavigator';
|
|
43
24
|
export { default as DrawerNavigator } from './navigation/DrawerNavigator';
|
|
44
25
|
export { default as BottomTabNavigator } from './navigation/BottomTabNavigator';
|
|
45
26
|
|
|
46
|
-
// ============================================
|
|
47
|
-
// SCREEN COMPONENTS (Library Mode)
|
|
48
|
-
// ============================================
|
|
49
27
|
export { default as HomeScreen } from './screens/Tabs/HomeScreen';
|
|
50
28
|
export { default as ProfileScreen } from './screens/Tabs/ActivityAnalytics';
|
|
51
29
|
export { default as NotificationsScreen } from './screens/Tabs/NotificationsScreen';
|