@propel-nsl/propel-react-native-sdk 1.0.0

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.
Files changed (221) hide show
  1. package/assets/fonts/Lexend-Black.ttf +0 -0
  2. package/assets/fonts/Lexend-Bold.ttf +0 -0
  3. package/assets/fonts/Lexend-ExtraBold.ttf +0 -0
  4. package/assets/fonts/Lexend-ExtraLight.ttf +0 -0
  5. package/assets/fonts/Lexend-Light.ttf +0 -0
  6. package/assets/fonts/Lexend-Medium.ttf +0 -0
  7. package/assets/fonts/Lexend-Regular.ttf +0 -0
  8. package/assets/fonts/Lexend-SemiBold.ttf +0 -0
  9. package/assets/fonts/Lexend-Thin.ttf +0 -0
  10. package/assets/images/HomeGoods.png +0 -0
  11. package/assets/images/accessories.png +0 -0
  12. package/assets/images/amazon.png +0 -0
  13. package/assets/images/apnaClubLogo.png +0 -0
  14. package/assets/images/apparel.png +0 -0
  15. package/assets/images/backgroundblue.png +0 -0
  16. package/assets/images/bannerCard.png +0 -0
  17. package/assets/images/bottomWave.png +0 -0
  18. package/assets/images/coin_1_1.png +0 -0
  19. package/assets/images/flipkart.png +0 -0
  20. package/assets/images/frame_1171278967.png +0 -0
  21. package/assets/images/gift.png +0 -0
  22. package/assets/images/herobanner.png +0 -0
  23. package/assets/images/hinduPencilsLogo.png +0 -0
  24. package/assets/images/icons/addwhiteicon.png +0 -0
  25. package/assets/images/icons/arrow-back.png +0 -0
  26. package/assets/images/icons/arrowgreen.png +0 -0
  27. package/assets/images/icons/arrowred.png +0 -0
  28. package/assets/images/icons/arrowright.png +0 -0
  29. package/assets/images/icons/arrowup.png +0 -0
  30. package/assets/images/icons/blackarrowdown.png +0 -0
  31. package/assets/images/icons/blackarrowup.png +0 -0
  32. package/assets/images/icons/blackcross.png +0 -0
  33. package/assets/images/icons/call.png +0 -0
  34. package/assets/images/icons/camera.png +0 -0
  35. package/assets/images/icons/cart.png +0 -0
  36. package/assets/images/icons/chat.png +0 -0
  37. package/assets/images/icons/circleblack.png +0 -0
  38. package/assets/images/icons/copy.png +0 -0
  39. package/assets/images/icons/cross.png +0 -0
  40. package/assets/images/icons/delete.png +0 -0
  41. package/assets/images/icons/delivery.png +0 -0
  42. package/assets/images/icons/eVoucher.png +0 -0
  43. package/assets/images/icons/editIcon.png +0 -0
  44. package/assets/images/icons/email.png +0 -0
  45. package/assets/images/icons/eye.png +0 -0
  46. package/assets/images/icons/faq.png +0 -0
  47. package/assets/images/icons/filtericon.png +0 -0
  48. package/assets/images/icons/greyDownArrow.png +0 -0
  49. package/assets/images/icons/help.png +0 -0
  50. package/assets/images/icons/home.png +0 -0
  51. package/assets/images/icons/homeinactive.png +0 -0
  52. package/assets/images/icons/i_blackicon.png +0 -0
  53. package/assets/images/icons/i_icon.png +0 -0
  54. package/assets/images/icons/location.png +0 -0
  55. package/assets/images/icons/logout.png +0 -0
  56. package/assets/images/icons/minus.png +0 -0
  57. package/assets/images/icons/myOrders.png +0 -0
  58. package/assets/images/icons/orders.png +0 -0
  59. package/assets/images/icons/pencillogo.png +0 -0
  60. package/assets/images/icons/pending.png +0 -0
  61. package/assets/images/icons/plus.png +0 -0
  62. package/assets/images/icons/redCross.png +0 -0
  63. package/assets/images/icons/redCrossicon.png +0 -0
  64. package/assets/images/icons/redWarningicon.png +0 -0
  65. package/assets/images/icons/redeem.png +0 -0
  66. package/assets/images/icons/redeemactive.png +0 -0
  67. package/assets/images/icons/redemptionHistory.png +0 -0
  68. package/assets/images/icons/redhelpicon.png +0 -0
  69. package/assets/images/icons/search.png +0 -0
  70. package/assets/images/icons/stopwatch.png +0 -0
  71. package/assets/images/icons/successTick.gif +0 -0
  72. package/assets/images/icons/tick.png +0 -0
  73. package/assets/images/icons/tnc.png +0 -0
  74. package/assets/images/icons/user.png +0 -0
  75. package/assets/images/icons/userredicon.png +0 -0
  76. package/assets/images/icons/wavecorner.png +0 -0
  77. package/assets/images/logo.png +0 -0
  78. package/assets/images/myntra_copy.png +0 -0
  79. package/assets/images/nike.png +0 -0
  80. package/assets/images/oq3p0u0_1.png +0 -0
  81. package/assets/images/profileicon.png +0 -0
  82. package/assets/images/topWave.png +0 -0
  83. package/assets/images/zagglePropelLogo.png +0 -0
  84. package/index.ts +23 -0
  85. package/lib/index.ts +25 -0
  86. package/package.json +70 -0
  87. package/src/PropelSDKScreen.tsx +98 -0
  88. package/src/SDKApp.tsx +540 -0
  89. package/src/bridge/SDKBridge.ts +104 -0
  90. package/src/bridge/index.ts +3 -0
  91. package/src/components/SDKBackHandler.tsx +187 -0
  92. package/src/components/SDKProfile.tsx +87 -0
  93. package/src/components/SDKProfileWrapper.tsx +51 -0
  94. package/src/constants.ts +10 -0
  95. package/src/contexts/SDKContext.tsx +72 -0
  96. package/src/hooks/useSDKBackNavigation.ts +61 -0
  97. package/src/navigation/SDKMainTabNavigator.tsx +315 -0
  98. package/src/navigation/SDKNavigator.tsx +41 -0
  99. package/src/redux/store.ts +32 -0
  100. package/src/screens/Dashboard/index.tsx +531 -0
  101. package/src/screens/Dashboard/styles.ts +512 -0
  102. package/src/screens/DeliveryAddress/index.tsx +221 -0
  103. package/src/screens/DeliveryAddress/styles.ts +122 -0
  104. package/src/screens/E-Vouchers/index.tsx +157 -0
  105. package/src/screens/E-Vouchers/styles.ts +106 -0
  106. package/src/screens/Faq/Faq.constants.ts +164 -0
  107. package/src/screens/Faq/index.tsx +114 -0
  108. package/src/screens/Faq/styles.ts +131 -0
  109. package/src/screens/Help/index.tsx +128 -0
  110. package/src/screens/Help/styles.ts +121 -0
  111. package/src/screens/Login/index.tsx +215 -0
  112. package/src/screens/Login/styles.ts +134 -0
  113. package/src/screens/MyCart/MyCart.constants.ts +13 -0
  114. package/src/screens/MyCart/index.tsx +318 -0
  115. package/src/screens/MyCart/styles.ts +249 -0
  116. package/src/screens/MyOrders/index.tsx +87 -0
  117. package/src/screens/MyOrders/styles.ts +281 -0
  118. package/src/screens/MyProfile/index.tsx +72 -0
  119. package/src/screens/MyProfile/styles.ts +47 -0
  120. package/src/screens/NewDeliveryAddress/index.tsx +360 -0
  121. package/src/screens/NewDeliveryAddress/styles.ts +68 -0
  122. package/src/screens/Onboarding/index.tsx +57 -0
  123. package/src/screens/Onboarding/styles.ts +60 -0
  124. package/src/screens/OrdersDetails/index.tsx +333 -0
  125. package/src/screens/OrdersDetails/styles.ts +262 -0
  126. package/src/screens/OtpVerification/index.tsx +283 -0
  127. package/src/screens/OtpVerification/styles.ts +197 -0
  128. package/src/screens/PaymentMethod/index.tsx +389 -0
  129. package/src/screens/PaymentMethod/styles.ts +246 -0
  130. package/src/screens/PointsLog/index.tsx +286 -0
  131. package/src/screens/PointsLog/styles.ts +156 -0
  132. package/src/screens/ProductDetails/index.tsx +682 -0
  133. package/src/screens/ProductDetails/styles.ts +372 -0
  134. package/src/screens/Profile/index.tsx +368 -0
  135. package/src/screens/Profile/styles.ts +158 -0
  136. package/src/screens/RedemptionHistory/RedemptionHistory.constants.ts +4 -0
  137. package/src/screens/RedemptionHistory/index.tsx +304 -0
  138. package/src/screens/RedemptionHistory/styles.ts +84 -0
  139. package/src/screens/Reedem/index.tsx +345 -0
  140. package/src/screens/Reedem/styles.ts +269 -0
  141. package/src/screens/TnC/TnC.constants.ts +169 -0
  142. package/src/screens/TnC/index.tsx +83 -0
  143. package/src/screens/TnC/styles.ts +88 -0
  144. package/src/screens/TransactionSuccessful/index.tsx +77 -0
  145. package/src/screens/TransactionSuccessful/styles.ts +77 -0
  146. package/src/screens/Verification/index.tsx +58 -0
  147. package/src/screens/Verification/styles.ts +74 -0
  148. package/src/screens/index.ts +23 -0
  149. package/src/types/index.ts +46 -0
  150. package/src-app/components/AmountBreakDownModal/index.tsx +86 -0
  151. package/src-app/components/AmountBreakDownModal/styles.ts +110 -0
  152. package/src-app/components/BottomNavIcons.tsx +125 -0
  153. package/src-app/components/Button.tsx +120 -0
  154. package/src-app/components/Card.tsx +47 -0
  155. package/src-app/components/ConfirmPopup/ConfirmPopup.constants.ts +25 -0
  156. package/src-app/components/ConfirmPopup/index.tsx +48 -0
  157. package/src-app/components/ConfirmPopup/styles.ts +167 -0
  158. package/src-app/components/CustomButton/index.tsx +67 -0
  159. package/src-app/components/CustomButton/styles.ts +44 -0
  160. package/src-app/components/CustomCard/index.tsx +221 -0
  161. package/src-app/components/CustomCard/styles.ts +184 -0
  162. package/src-app/components/CustomError/index.tsx +54 -0
  163. package/src-app/components/CustomError/styles.ts +41 -0
  164. package/src-app/components/CustomImage/index.tsx +37 -0
  165. package/src-app/components/CustomImage/styles.ts +5 -0
  166. package/src-app/components/CustomLoader/index.tsx +45 -0
  167. package/src-app/components/CustomLoader/styles.ts +35 -0
  168. package/src-app/components/CustomMessagePopUp/index.tsx +51 -0
  169. package/src-app/components/CustomMessagePopUp/styles.ts +74 -0
  170. package/src-app/components/CustomProductCard/index.tsx +13 -0
  171. package/src-app/components/CustomProductCard/styles.ts +5 -0
  172. package/src-app/components/FilterModal.tsx +372 -0
  173. package/src-app/components/Footer/index.tsx +23 -0
  174. package/src-app/components/Footer/styles.ts +37 -0
  175. package/src-app/components/Icon.tsx +80 -0
  176. package/src-app/components/Logout/index.tsx +82 -0
  177. package/src-app/components/Logout/styles.ts +116 -0
  178. package/src-app/components/MobileHeader.tsx +141 -0
  179. package/src-app/components/NoDataFound/index.tsx +18 -0
  180. package/src-app/components/NoDataFound/styles.ts +26 -0
  181. package/src-app/components/OTPModal.tsx +747 -0
  182. package/src-app/components/ProfileField.tsx +47 -0
  183. package/src-app/components/QuantityModal/index.tsx +113 -0
  184. package/src-app/components/QuantityModal/styles.ts +84 -0
  185. package/src-app/components/TabBarIcons.tsx +110 -0
  186. package/src-app/components/TextInput.tsx +79 -0
  187. package/src-app/components/ToastConfig.tsx +60 -0
  188. package/src-app/components/index.ts +18 -0
  189. package/src-app/config/env.ts +22 -0
  190. package/src-app/constants/Fonts.ts +12 -0
  191. package/src-app/constants/Formatter.ts +39 -0
  192. package/src-app/constants/HtmlSanitization.ts +46 -0
  193. package/src-app/constants/Images.ts +81 -0
  194. package/src-app/constants/Labels.ts +8 -0
  195. package/src-app/constants/Messages.ts +108 -0
  196. package/src-app/constants/Routes.ts +17 -0
  197. package/src-app/constants/Scaling.ts +5 -0
  198. package/src-app/constants/Text.ts +8 -0
  199. package/src-app/constants/offSets.ts +18 -0
  200. package/src-app/hooks/useAppDispatch.ts +4 -0
  201. package/src-app/hooks/useAppSelector.ts +4 -0
  202. package/src-app/hooks/useBackHandler.ts +47 -0
  203. package/src-app/hooks/useScreenBackHandler.ts +91 -0
  204. package/src-app/navigation/AppNavigator.tsx +34 -0
  205. package/src-app/navigation/MainTabNavigator.tsx +294 -0
  206. package/src-app/redux/authSaga.ts +605 -0
  207. package/src-app/redux/authSlice.ts +754 -0
  208. package/src-app/redux/rootSaga.ts +6 -0
  209. package/src-app/redux/store.ts +25 -0
  210. package/src-app/services/api.ts +14 -0
  211. package/src-app/services/endpoints.ts +33 -0
  212. package/src-app/services/index.ts +574 -0
  213. package/src-app/services/sdkCredentials.ts +44 -0
  214. package/src-app/styles/colors.ts +85 -0
  215. package/src-app/styles/shared.ts +112 -0
  216. package/src-app/types/authTypes.ts +155 -0
  217. package/src-app/types/navigation.ts +99 -0
  218. package/src-app/utils/Validation.ts +48 -0
  219. package/src-app/utils/filterPins.ts +29 -0
  220. package/src-app/utils/navigationUtils.ts +43 -0
  221. package/src-app/utils/useHardwareBack.ts +21 -0
@@ -0,0 +1,6 @@
1
+ import { all } from 'redux-saga/effects';
2
+ import { authSaga } from './authSaga';
3
+
4
+ export default function* rootSaga() {
5
+ yield all([authSaga()]);
6
+ }
@@ -0,0 +1,25 @@
1
+ import { configureStore } from '@reduxjs/toolkit';
2
+ import authReducer from './authSlice';
3
+ import rootSaga from './rootSaga';
4
+
5
+ const createSagaMiddleware = require('redux-saga').default;
6
+ const sagaMiddleware = createSagaMiddleware();
7
+
8
+ export const store = configureStore({
9
+ reducer: {
10
+ auth: authReducer,
11
+ },
12
+ middleware: getDefaultMiddleware =>
13
+ getDefaultMiddleware({
14
+ thunk: false,
15
+ serializableCheck: {
16
+ ignoredActions: ['auth/uploadProfileImageRequest'],
17
+ ignoredActionPaths: ['payload'],
18
+ },
19
+ }).concat(sagaMiddleware),
20
+ });
21
+
22
+ sagaMiddleware.run(rootSaga);
23
+
24
+ export type RootState = ReturnType<typeof store.getState>;
25
+ export type AppDispatch = typeof store.dispatch;
@@ -0,0 +1,14 @@
1
+ import ENV from '../config/env';
2
+ import axios from 'axios';
3
+
4
+ const api = axios.create({
5
+ baseURL: ENV.apiUrl,
6
+ timeout: 10000,
7
+ });
8
+
9
+ export const api1 = axios.create({
10
+ baseURL: ENV.apiUrl1,
11
+ timeout: 10000,
12
+ });
13
+
14
+ export default api;
@@ -0,0 +1,33 @@
1
+ const ENDPOINTS = {
2
+ SDK_AUTH_INIT: 'api/v1/propel/sdk/auth/init',
3
+ GENERATE_OTP: 'api/v1/auth/client/generate_otp',
4
+ VERIFY_MOBILE_OTP: 'api/v1/auth/client',
5
+ MY_ORDERS: 'api/v1/orders',
6
+ PRODUCTS_LIST: 'api/v1/propel/product_catalogues',
7
+ MY_PROFILE: 'api/v1/propel/client/profile_info',
8
+ UPLOAD_PROFILE_IMAGE: 'api/v1/propel/client/update_profile',
9
+ PRODUCT_DETAILS_BY_ID: 'api/v1/products',
10
+ MY_ORDERS_GENERATE_OTP: 'api/v1/orders/generate_order_otp',
11
+ MY_ORDERS_VALIDATE_OTP: 'api/v1/orders/validate_order_confirmation_otp',
12
+ REDEMPTION_HISTORY: 'api/v1/propel/user_transactions/redemption_history',
13
+ PRODUCT_TYPES: 'api/v1/products/product_types',
14
+ PRODUCT_CATEGORIES_BY_TYPE: 'propel/product_catalogues/categories',
15
+ VIEW_MY_CART: 'api/v1/orders',
16
+ DASHBOARD_INFO: 'api/v1/propel/dashboard/info',
17
+ GET_ADDRESS_LIST: 'api/v1/orders/addresses',
18
+ CREATE_ADDRESS: 'api/v1/orders/addresses',
19
+ UPDATE_ADDRESS: 'api/v1/orders/addresses',
20
+ DELETE_ADDRESS: 'api/v1/orders/addresses',
21
+ UPDATE_CART: (orderId: string | number) => `api/v1/orders/${orderId}/items`,
22
+ DELETE_CART: (orderId: string | number) => `api/v1/orders/${orderId}/items`,
23
+ ADD_TO_CART: 'api/v1/orders',
24
+ ADD_TO_EXISTING_CART: (orderId: string | number) =>
25
+ `api/v1/propel/orders/${orderId}/items`,
26
+ POINTS_LOG: 'api/v1/propel/user_transactions/details',
27
+ GENERATE_E_VOUCERS: 'api/v1/orders/evouchers/generate_evoucher_otp',
28
+ E_VOUCERS_VALIDATE_OTP: 'api/v1/orders/evouchers',
29
+ CHECKOUT: (orderId: string | number) => `api/v1/orders/${orderId}/complete`,
30
+ DELIVERHERE: (orderId: string | number) => `api/v1/orders/${orderId}`,
31
+ };
32
+
33
+ export default ENDPOINTS;
@@ -0,0 +1,574 @@
1
+ import AsyncStorage from "@react-native-async-storage/async-storage";
2
+ import {
3
+ AddToCartPayload,
4
+ CheckoutPayload,
5
+ CreateAddressPayload,
6
+ DeliverHerePayload,
7
+ generateOtpPayload,
8
+ UpdateAddressPayload,
9
+ UploadProfileImagePayload,
10
+ VerifyMobileOtpPayload,
11
+ } from "../types/authTypes";
12
+ import api, { api1 } from "./api";
13
+ import ENDPOINTS from "./endpoints";
14
+ import DeviceInfo from "react-native-device-info";
15
+ import { getSDKCredentials } from "./sdkCredentials";
16
+
17
+ let cachedDeviceId: string | null = null;
18
+
19
+ const getDeviceId = async (): Promise<string> => {
20
+ if (cachedDeviceId) {
21
+ return cachedDeviceId;
22
+ }
23
+ try {
24
+ const id = await DeviceInfo.getUniqueId();
25
+ cachedDeviceId = String(id);
26
+ return cachedDeviceId;
27
+ } catch (error) {
28
+ console.log("Error getting device ID:", error);
29
+ return "fallback-device-id";
30
+ }
31
+ };
32
+
33
+
34
+
35
+ const createAuthHeader = async (token: string): Promise<string> => {
36
+ const deviceId = await getDeviceId();
37
+ return `Token token=${token};client_key=mobile_app;device_id=device123;client_id=7b170ef2-c0a0-4968-a832-d308d54a8419;user_type=end_user;language_code=en;`;
38
+ };
39
+
40
+
41
+
42
+
43
+ const getAuthHeader = async (): Promise<{ Authorization: string }> => {
44
+ const token = await AsyncStorage.getItem("accessToken");
45
+ if (!token || token === "null") {
46
+ throw new Error("No valid access token");
47
+ }
48
+ return {
49
+ Authorization: await createAuthHeader(token),
50
+ };
51
+ };
52
+
53
+
54
+ export const generateOtpApi = (payload: generateOtpPayload) => {
55
+ return api1.post(ENDPOINTS.GENERATE_OTP, payload);
56
+ };
57
+
58
+ export const verifyMobileOtpApi = (payload: VerifyMobileOtpPayload) => {
59
+ return api1.post(ENDPOINTS.VERIFY_MOBILE_OTP, payload);
60
+ };
61
+
62
+ export const sdkAuthApi = async () => {
63
+ const payload = {
64
+ device_id: "device123",
65
+ client_name: "AndroidApp",
66
+ client_version: "1.0.0",
67
+ environment: "PRODUCTION",
68
+ user: {
69
+ user_id: "uuid",
70
+ name: "abc12345",
71
+ mobile: "9030992316",
72
+ email: "abc12345@yopmail.com",
73
+ },
74
+ };
75
+
76
+ const headers = {
77
+ "X-Auth-Token": "8540f0e5-029c-4a80-bbc8-7da952e1b1d3:7630a8c22d0c9dbcbf1b86b03bd58bf2",
78
+ "X-Auth-Id": "NUZIVEEDUS",
79
+ "Content-Type": "application/json",
80
+ };
81
+
82
+ return api1.post(ENDPOINTS.SDK_AUTH_INIT, payload, { headers });
83
+ };
84
+ export const myOrdersApi = async () => {
85
+ try {
86
+ const headers = await getAuthHeader();
87
+ const response = await api.get(ENDPOINTS.MY_ORDERS, {
88
+ headers,
89
+ });
90
+ return response;
91
+ } catch (error: any) {
92
+ throw error;
93
+ }
94
+ };
95
+
96
+ export const myProductListApi = async (
97
+ name?: string,
98
+ product_types?: string,
99
+ category_ids?: string
100
+ ) => {
101
+ try {
102
+ const headers = await getAuthHeader();
103
+ const params: any = {
104
+ include: "variations,variation_types",
105
+ per: "12",
106
+ payment_method: "zaggle_card",
107
+ };
108
+
109
+ if (name) {
110
+ params.by_name = name;
111
+ }
112
+
113
+ if (product_types) {
114
+ params.product_types = product_types;
115
+ }
116
+
117
+ if (category_ids) {
118
+ params.category_ids = category_ids;
119
+ }
120
+
121
+ const response = await api.get(ENDPOINTS.PRODUCTS_LIST, {
122
+ headers,
123
+ params,
124
+ });
125
+
126
+ return response;
127
+ } catch (error: any) {
128
+ throw error;
129
+ }
130
+ };
131
+
132
+ export const myProfileApi = async () => {
133
+ try {
134
+ const headers = await getAuthHeader();
135
+ const response = await api1.get(ENDPOINTS.MY_PROFILE, {
136
+ headers,
137
+ });
138
+ return response;
139
+ } catch (error: any) {
140
+ throw error;
141
+ }
142
+ };
143
+
144
+ // export const uploadProfileImageApi = async (
145
+ // payload: UploadProfileImagePayload
146
+ // ) => {
147
+ // try {
148
+ // const headers = await getAuthHeader();
149
+ // const response = await api.put(ENDPOINTS.UPLOAD_PROFILE_IMAGE, payload, {
150
+ // headers,
151
+ // });
152
+ // return response;
153
+ // } catch (error: any) {
154
+ // throw error;
155
+ // }
156
+ // };
157
+
158
+ export const uploadProfileImageApi = async (
159
+ payload: UploadProfileImagePayload
160
+ ) => {
161
+ try {
162
+ const token = await AsyncStorage.getItem("accessToken");
163
+ if (!token || token === "null") {
164
+ throw new Error("No valid access token found");
165
+ }
166
+
167
+ // Include all required headers like other API calls
168
+ const authHeader = await createAuthHeader(token);
169
+
170
+ console.log("Uploading profile image with headers:", {
171
+ Authorization: authHeader.substring(0, 50) + "...",
172
+ "Content-Type": "multipart/form-data",
173
+ });
174
+
175
+ const response = await api.put(ENDPOINTS.UPLOAD_PROFILE_IMAGE, payload, {
176
+ headers: {
177
+ Authorization: authHeader,
178
+ "Content-Type": "multipart/form-data",
179
+ },
180
+ timeout: 30000, // 30 second timeout for file uploads
181
+ });
182
+
183
+ console.log("Upload successful:", response.status);
184
+ return response;
185
+ } catch (error: any) {
186
+ console.error("Upload profile image API error:", {
187
+ status: error?.response?.status,
188
+ message: error?.response?.data?.message || error.message,
189
+ data: error?.response?.data,
190
+ });
191
+
192
+ // Provide more specific error messages
193
+ if (error?.response?.status === 401) {
194
+ throw new Error("Authentication failed. Please login again.");
195
+ } else if (error?.response?.status === 413) {
196
+ throw new Error("File size too large. Please select a smaller image.");
197
+ } else if (error?.response?.status === 415) {
198
+ throw new Error("Unsupported file type. Please select a valid image.");
199
+ } else if (error?.code === "NETWORK_ERROR") {
200
+ throw new Error("Network error. Please check your connection.");
201
+ }
202
+
203
+ throw error;
204
+ }
205
+ };
206
+
207
+ export const productDetailsByIdApi = async (productId: string) => {
208
+ try {
209
+ const headers = await getAuthHeader();
210
+
211
+ const response = await api.get(
212
+ `${ENDPOINTS.PRODUCT_DETAILS_BY_ID}/${productId}`,
213
+ {
214
+ headers,
215
+ }
216
+ );
217
+ return response;
218
+ } catch (error: any) {
219
+ throw error;
220
+ }
221
+ };
222
+
223
+ export const myOrdersGenerateOtpApi = async (params?: {
224
+ order_id?: string;
225
+ otp_type?: 'orders_confirm_otp';
226
+ }) => {
227
+ try {
228
+ const headers = await getAuthHeader();
229
+
230
+ const config: any = { headers };
231
+ if (params && (params.order_id || params.otp_type)) {
232
+ config.params = params;
233
+ }
234
+
235
+ const response = await api1.get(ENDPOINTS.MY_ORDERS_GENERATE_OTP, config);
236
+ return response;
237
+ } catch (error: any) {
238
+ throw error;
239
+ }
240
+ };
241
+
242
+ export const myOrdersValidateOtpApi = async (
243
+ arg: { otp: string; order_id?: string; otp_type?: 'orders_confirm_otp' } | string
244
+ ) => {
245
+ try {
246
+ console.log("🌐 API: myOrdersValidateOtpApi called with arg:", arg);
247
+ const headers = await getAuthHeader();
248
+ const params = typeof arg === 'string' ? { otp: arg } : arg;
249
+ const listRes = await api1.get(ENDPOINTS.MY_ORDERS, {
250
+ headers,
251
+ params: { otp: params.otp },
252
+ });
253
+ const raw = listRes?.data;
254
+ const orders =
255
+ raw?.orders ?? raw?.data ?? (Array.isArray(raw) ? raw : raw?.items ?? raw);
256
+
257
+ const result = { ...listRes, data: { orders } };
258
+ console.log("🌐 API: myOrdersValidateOtpApi returning:", result);
259
+ return result;
260
+ } catch (error: any) {
261
+ console.log("🌐 API: myOrdersValidateOtpApi ERROR DETAILS:");
262
+ console.log(" - Error message:", error?.message);
263
+ console.log(" - Status code:", error?.response?.status);
264
+ console.log(" - Status text:", error?.response?.statusText);
265
+ console.log(" - Response data:", JSON.stringify(error?.response?.data, null, 2));
266
+ console.log(" - Response headers:", JSON.stringify(error?.response?.headers, null, 2));
267
+ console.log(" - Full error object:", error);
268
+
269
+ const errMsg = error?.response?.data?.message || error.message || 'Unknown error';
270
+
271
+ throw error;
272
+ }
273
+ };
274
+
275
+ export const redemptionHistoryApi = async (id: string) => {
276
+ try {
277
+ const headers = await getAuthHeader();
278
+
279
+ const params = {
280
+ id: id,
281
+ client_id: "7b170ef2-c0a0-4968-a832-d308d54a8419",
282
+ };
283
+ console.log("params", params);
284
+ console.log("headers", headers);
285
+ const response = await api1.get(`${ENDPOINTS.REDEMPTION_HISTORY}`, {
286
+ headers,
287
+ params,
288
+ });
289
+
290
+ return response;
291
+ } catch (error: any) {
292
+ throw error;
293
+ }
294
+ };
295
+
296
+ export const productTypesApi = async () => {
297
+ try {
298
+ const headers = await getAuthHeader();
299
+
300
+ const response = await api.get(`${ENDPOINTS.PRODUCT_TYPES}`, {
301
+ headers,
302
+ });
303
+
304
+ return response;
305
+ } catch (error: any) {
306
+ throw error;
307
+ }
308
+ };
309
+
310
+ export const productCategoriesByTypeApi = async (product_type?: string) => {
311
+ try {
312
+ const headers = await getAuthHeader();
313
+
314
+ const params: any = {
315
+ "product_type[]": product_type,
316
+ include: "variations,variation_types",
317
+ payment_method: "zaggle_card",
318
+ };
319
+
320
+ const response = await api.get(
321
+ `/api/v1/propel/product_catalogues/categories`,
322
+ {
323
+ headers,
324
+ params,
325
+ }
326
+ );
327
+
328
+ return response;
329
+ } catch (error: any) {
330
+ throw error;
331
+ }
332
+ };
333
+
334
+ export const viewMyCartApi = async (productId: string) => {
335
+ try {
336
+ const headers = await getAuthHeader();
337
+ console.log("url", `${ENDPOINTS.VIEW_MY_CART}/${productId}`);
338
+
339
+ const response = await api.get(`${ENDPOINTS.VIEW_MY_CART}/${productId}`, {
340
+ headers,
341
+ });
342
+ return response;
343
+ } catch (error: any) {
344
+ throw error;
345
+ }
346
+ };
347
+
348
+ export const dashboardInfoApi = async () => {
349
+ try {
350
+ const headers = await getAuthHeader();
351
+ console.log("dashboard api",headers);
352
+ const response = await api1.get(`${ENDPOINTS.DASHBOARD_INFO}`, {
353
+ headers,
354
+ });
355
+ return response;
356
+ } catch (error: any) {
357
+ throw error;
358
+ }
359
+ };
360
+
361
+ export const getAddressListApi = async () => {
362
+ try {
363
+ const headers = await getAuthHeader();
364
+ const params = {
365
+ address_type: "billing_address",
366
+ };
367
+
368
+ const response = await api.get(`${ENDPOINTS.GET_ADDRESS_LIST}`, {
369
+ headers,
370
+ params,
371
+ });
372
+ return response;
373
+ } catch (error: any) {
374
+ throw error;
375
+ }
376
+ };
377
+
378
+ export const createAddressApi = async (payload: CreateAddressPayload) => {
379
+ try {
380
+ const headers = await getAuthHeader();
381
+
382
+ const response = await api.post(`${ENDPOINTS.CREATE_ADDRESS}`, payload, {
383
+ headers,
384
+ });
385
+ return response;
386
+ } catch (error: any) {
387
+ throw error;
388
+ }
389
+ };
390
+
391
+ export const updateAddressApi = async (
392
+ payload: UpdateAddressPayload,
393
+ id: string
394
+ ) => {
395
+ try {
396
+ const headers = await getAuthHeader();
397
+
398
+ const response = await api.put(
399
+ `${ENDPOINTS.UPDATE_ADDRESS}/${id}`,
400
+ payload,
401
+ {
402
+ headers,
403
+ }
404
+ );
405
+ return response;
406
+ } catch (error: any) {
407
+ throw error;
408
+ }
409
+ };
410
+
411
+ export const deleteAddressApi = async (id: string) => {
412
+ try {
413
+ const headers = await getAuthHeader();
414
+
415
+ const response = await api.delete(`${ENDPOINTS.DELETE_ADDRESS}/${id}`, {
416
+ headers,
417
+ });
418
+ return response;
419
+ } catch (error: any) {
420
+ throw error;
421
+ }
422
+ };
423
+
424
+ export const updateCartApi = async (orderId: string, payload: any) => {
425
+ try {
426
+ const headers = await getAuthHeader();
427
+ const response = await api.put(
428
+ `${ENDPOINTS.UPDATE_CART(orderId)}`,
429
+ payload,
430
+ {
431
+ headers,
432
+ }
433
+ );
434
+ return response;
435
+ } catch (error: any) {
436
+ throw error;
437
+ }
438
+ };
439
+
440
+ export const deleteCartApi = async (orderId: string, payload: any) => {
441
+ try {
442
+ const headers = await getAuthHeader();
443
+ const params = {
444
+ product_variation_id: payload.product_variation_id,
445
+ };
446
+ const response = await api1.delete(`${ENDPOINTS.DELETE_CART(orderId)}`, {
447
+ headers,
448
+ params,
449
+ });
450
+ return response;
451
+ } catch (error: any) {
452
+ throw error;
453
+ }
454
+ };
455
+
456
+ export const addToCartApi = async (payload: AddToCartPayload) => {
457
+ try {
458
+ const headers = await getAuthHeader();
459
+ console.log("Headers object:", headers);
460
+ console.log("api url",api1.defaults.baseURL);
461
+ console.log("endpoints",ENDPOINTS.ADD_TO_CART);
462
+ console.log("payload",payload);
463
+
464
+ const response = await api1.post(`${ENDPOINTS.ADD_TO_CART}`, payload, {
465
+ headers,
466
+ });
467
+ return response;
468
+ } catch (error: any) {
469
+ throw error;
470
+ }
471
+ };
472
+
473
+ export const getMyExistingCartApi = async (orderId: string, payload: any) => {
474
+ try {
475
+ const headers = await getAuthHeader();
476
+ console.log("Headers object:", headers);
477
+ console.log("api url",api1.defaults.baseURL);
478
+ console.log("endpoints",ENDPOINTS.ADD_TO_EXISTING_CART(orderId));
479
+ console.log("payload",payload);
480
+
481
+
482
+ const response = await api1.post(
483
+ `${ENDPOINTS.ADD_TO_EXISTING_CART(orderId)}`,
484
+ payload,
485
+ {
486
+ headers,
487
+ }
488
+ );
489
+ return response;
490
+ } catch (error: any) {
491
+ throw error;
492
+ }
493
+ };
494
+
495
+ export const pointsLogApi = async () => {
496
+ try {
497
+ const headers = await getAuthHeader();
498
+ const params = {
499
+ tab_type: "ezsc",
500
+ };
501
+ const response = await api.get(`${ENDPOINTS.POINTS_LOG}`, {
502
+ headers,
503
+ params,
504
+ });
505
+ return response;
506
+ } catch (error: any) {
507
+ throw error;
508
+ }
509
+ };
510
+
511
+ export const generateEVouchersApi = async () => {
512
+ try {
513
+ const headers = await getAuthHeader();
514
+
515
+ const response = await api.get(`${ENDPOINTS.GENERATE_E_VOUCERS}`, {
516
+ headers,
517
+ });
518
+ return response;
519
+ } catch (error: any) {
520
+ throw error;
521
+ }
522
+ };
523
+
524
+ export const validateEVouchersApi = async (otp: string) => {
525
+ try {
526
+ const headers = await getAuthHeader();
527
+ console.log("headers",headers);
528
+
529
+
530
+ const params = {
531
+ otp: otp,
532
+ };
533
+
534
+ const response = await api.get(`${ENDPOINTS.E_VOUCERS_VALIDATE_OTP}`, {
535
+ headers,
536
+ params,
537
+ });
538
+ console.log("vouchers response",response);
539
+ return response;
540
+ } catch (error: any) {
541
+ throw error;
542
+ }
543
+ };
544
+
545
+ export const checkoutApi = async (
546
+ orderId: string,
547
+ payload: CheckoutPayload
548
+ ) => {
549
+ try {
550
+ const headers = await getAuthHeader();
551
+ console.log("headers", `${ENDPOINTS.CHECKOUT(orderId)}`);
552
+ console.log(" checkout payload", payload);
553
+
554
+ const response = await api.put(`${ENDPOINTS.CHECKOUT(orderId)}`, payload, {
555
+ headers,
556
+ });
557
+ return response;
558
+ } catch (error: any) {
559
+ throw error;
560
+ }
561
+ };
562
+
563
+ export const deliverHereApi = async (orderId: string, payload: DeliverHerePayload) => {
564
+ try {
565
+ const headers = await getAuthHeader();
566
+ const response = await api.put(`${ENDPOINTS.DELIVERHERE(orderId)}`, payload, {
567
+ headers,
568
+ });
569
+ return response;
570
+ } catch (error: any) {
571
+ throw error;
572
+ }
573
+ };
574
+
@@ -0,0 +1,44 @@
1
+ /**
2
+ * SDK Credentials Store
3
+ *
4
+ * Stores authentication credentials passed from the host app via the native bridge.
5
+ * These credentials are used by sdkAuthApi to authenticate with the backend.
6
+ */
7
+
8
+ export interface SDKCredentials {
9
+ authToken: string;
10
+ authId: string;
11
+ userId?: string;
12
+ userName?: string;
13
+ userMobile?: string;
14
+ userEmail?: string;
15
+ deviceId?: string;
16
+ clientName?: string;
17
+ clientVersion?: string;
18
+ environment?: string;
19
+ }
20
+
21
+ let _credentials: SDKCredentials | null = null;
22
+
23
+ /**
24
+ * Set SDK credentials from host app params.
25
+ * Must be called before sdkAuthApi is invoked.
26
+ */
27
+ export const setSDKCredentials = (credentials: SDKCredentials): void => {
28
+ _credentials = credentials;
29
+ };
30
+
31
+ /**
32
+ * Get the current SDK credentials.
33
+ * Returns null if credentials have not been set.
34
+ */
35
+ export const getSDKCredentials = (): SDKCredentials | null => {
36
+ return _credentials;
37
+ };
38
+
39
+ /**
40
+ * Clear stored SDK credentials (called on SDK exit).
41
+ */
42
+ export const clearSDKCredentials = (): void => {
43
+ _credentials = null;
44
+ };