@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,531 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import {
3
+ View,
4
+ Text,
5
+ TouchableOpacity,
6
+ ScrollView,
7
+ Platform,
8
+ FlatList,
9
+ ImageBackground,
10
+ Dimensions,
11
+ NativeModules,
12
+ } from "react-native";
13
+ import { StackNavigationProp } from "@react-navigation/stack";
14
+ import { AppStackParamList } from "../../../src-app/types/navigation";
15
+ import styles from "./styles";
16
+ import { CustomImage, CustomMessagePopUp } from "../../../src-app/components";
17
+ import Images from "../../../src-app/constants/Images";
18
+ import OTPModal from "../../../src-app/components/OTPModal";
19
+ import { useAppDispatch } from "../../../src-app/hooks/useAppDispatch";
20
+ import {
21
+ clearAllAuthState,
22
+ dashboardInfoRequest,
23
+ generateEVouchersRequest,
24
+ myOrdersGenerateOtpRequest,
25
+ myOrdersValidateOtpRequest,
26
+ resetAuthState,
27
+ sdkAuthRequest,
28
+ validateEVouchersRequest,
29
+ viewMyCartRequest,
30
+ } from "../../../src-app/redux/authSlice";
31
+ import DeviceInfo from "react-native-device-info";
32
+ import { useAppSelector } from "../../../src-app/hooks/useAppSelector";
33
+ import { RootState } from "../../../src-app/redux/store";
34
+ import { SafeAreaView } from "react-native-safe-area-context";
35
+ import { useFocusEffect } from "@react-navigation/native";
36
+ import { pointsFromCentsFixed } from "../../../src-app/constants/Formatter";
37
+ import CustomLoader from "../../../src-app/components/CustomLoader";
38
+ import { ROUTES } from "../../../src-app/constants/Routes";
39
+
40
+ type DashboardNavigationProp = StackNavigationProp<
41
+ AppStackParamList,
42
+ "Dashboard",
43
+ "MyEVouchers"
44
+ >;
45
+
46
+ interface Props {
47
+ navigation: DashboardNavigationProp;
48
+ }
49
+
50
+ const Dashboard: React.FC<Props> = ({ navigation }) => {
51
+ const [otpModalVisible, setOtpModalVisible] = useState(false);
52
+ const dispatch = useAppDispatch();
53
+ const [resetOtpTrigger, setResetOtpTrigger] = useState(0);
54
+ const [messagepopUpVisible, setMessagepopUpVisible] = useState(false);
55
+ const [screen, setScreen] = useState("");
56
+
57
+ // Debug screen state changes
58
+ useEffect(() => {
59
+ console.log("🔍 Dashboard screen state changed to:", screen);
60
+ }, [screen]);
61
+
62
+ const {
63
+ dashboardInfoData,
64
+ myOrdersGenerateOtpError,
65
+ myOrdersValidateOtpError,
66
+ myOrdersValidateOtpSuccessMessage,
67
+ validateEVouchersData,
68
+ validateEVouchersSuccessMessage,
69
+ validateEVouchersError,
70
+ cartId,
71
+ viewMyCartData,
72
+ myOrdersValidateOtpLoading,
73
+ validateEVouchersLoading,
74
+ sdkAuthLoading,
75
+ sdkAuthError,
76
+ sdkAuthData,
77
+ } = useAppSelector((state: RootState) => state.auth);
78
+
79
+ const backPressedOnce = useRef(false);
80
+ const dashboardInfoLoading = useAppSelector(
81
+ (s: RootState) => s.auth.dashboardInfoLoading,
82
+ );
83
+
84
+ console.log(
85
+ "myOrdersValidateOtpSuccessMessage",
86
+ myOrdersValidateOtpSuccessMessage,
87
+ );
88
+ console.log("otpModalVisible", otpModalVisible);
89
+
90
+ useEffect(() => {
91
+ if (otpModalVisible && myOrdersValidateOtpSuccessMessage) {
92
+ setOtpModalVisible(false);
93
+ // Navigate based on which screen triggered the OTP flow
94
+ if (screen === ROUTES.REDEMPTION_HISTORY) {
95
+ navigateToDashboardScreen("RedemptionHistory", { from: "Dashboard" });
96
+ } else {
97
+ navigateToDashboardScreen("MyOrders", { from: "Dashboard" });
98
+ }
99
+ dispatch(resetAuthState("myOrdersValidateOtpSuccessMessage"));
100
+ dispatch(resetAuthState("myOrdersValidateOtpError"));
101
+ }
102
+ }, [
103
+ otpModalVisible,
104
+ screen,
105
+ myOrdersValidateOtpSuccessMessage,
106
+ navigation,
107
+ dispatch,
108
+ ]);
109
+
110
+ useEffect(() => {
111
+ if (
112
+ otpModalVisible &&
113
+ screen === ROUTES.MY_E_VOUCHERS &&
114
+ validateEVouchersSuccessMessage
115
+ ) {
116
+ setOtpModalVisible(false);
117
+ // navigation.navigate(ROUTES.MY_E_VOUCHERS as any);
118
+ navigateToDashboardScreen("MyEVouchers", { from: "Dashboard" });
119
+ dispatch(resetAuthState("validateEVouchersSuccessMessage"));
120
+ dispatch(resetAuthState("validateEVouchersError"));
121
+ }
122
+ }, [
123
+ otpModalVisible,
124
+ screen,
125
+ validateEVouchersSuccessMessage,
126
+ navigation,
127
+ dispatch,
128
+ ]);
129
+
130
+ useEffect(() => {
131
+ if (
132
+ otpModalVisible &&
133
+ (myOrdersGenerateOtpError || myOrdersValidateOtpError)
134
+ ) {
135
+ setMessagepopUpVisible(true);
136
+ }
137
+ }, [otpModalVisible, myOrdersGenerateOtpError, myOrdersValidateOtpError]);
138
+
139
+ useEffect(() => {
140
+ if (otpModalVisible && validateEVouchersError) {
141
+ setMessagepopUpVisible(true);
142
+ }
143
+ }, [otpModalVisible, validateEVouchersError]);
144
+
145
+ // Remove the hardware back handler - let SDKBackHandler handle it
146
+ // The SDKBackHandler will properly handle exit behavior for the Dashboard
147
+
148
+ useEffect(() => {
149
+ // Only call auth API if not already authenticated
150
+ if (!sdkAuthData?.session?.token) {
151
+ dispatch(sdkAuthRequest({}));
152
+ }
153
+ }, [dispatch, sdkAuthData?.session?.token]);
154
+
155
+ useEffect(() => {
156
+ if (sdkAuthError) {
157
+ console.log("🔴 SDK Auth failed, closing SDK:", sdkAuthError);
158
+ if (NativeModules.PropelSDKBridge?.closeSDKWithError) {
159
+ NativeModules.PropelSDKBridge.closeSDKWithError(sdkAuthError);
160
+ } else if (NativeModules.PropelSDKBridge?.closeSDK) {
161
+ NativeModules.PropelSDKBridge.closeSDK();
162
+ } else if (NativeModules.PropelSDKBridge?.dismiss) {
163
+ NativeModules.PropelSDKBridge.dismiss();
164
+ }
165
+ }
166
+ }, [sdkAuthError]);
167
+
168
+ useEffect(() => {
169
+ if (sdkAuthData?.session?.token) {
170
+ dispatch(dashboardInfoRequest({}));
171
+ }
172
+ }, [sdkAuthData, dispatch]);
173
+
174
+ // Refresh dashboard info when screen comes into focus (e.g., after order completion)
175
+ useFocusEffect(
176
+ useCallback(() => {
177
+ if (sdkAuthData?.session?.token) {
178
+ dispatch(dashboardInfoRequest({}));
179
+ }
180
+ }, [sdkAuthData?.session?.token, dispatch])
181
+ );
182
+
183
+ // Close modals when screen loses focus
184
+ useFocusEffect(
185
+ useCallback(() => {
186
+ return () => {
187
+ // This runs when the screen loses focus (unmounts or navigates away)
188
+ console.log('🔍 Dashboard: Screen losing focus, closing modals');
189
+ setOtpModalVisible(false);
190
+ setMessagepopUpVisible(false);
191
+ };
192
+ }, [])
193
+ );
194
+
195
+ useEffect(() => {
196
+ dispatch(viewMyCartRequest({ id: cartId }));
197
+ }, [cartId, dispatch]);
198
+
199
+ const navigateToDashboardScreen = (screenName: string, params?: any) => {
200
+ // Navigate within DashboardStack for screens that are part of the stack
201
+ // For screens like MyCart, we need to navigate within the stack
202
+ console.log("🧭 Dashboard navigateToDashboardScreen:", screenName, params);
203
+
204
+ // Get parent navigator (Tab navigator) to navigate to hidden tabs
205
+ const parentNav = (navigation as any).getParent?.();
206
+ if (parentNav?.navigate) {
207
+ console.log("🧭 Using parent tab navigator for:", screenName);
208
+ parentNav.navigate(screenName, params);
209
+ } else {
210
+ // Fallback to direct navigation within stack
211
+ console.log("🧭 Using direct navigation for:", screenName);
212
+ (navigation as any).navigate(screenName, params);
213
+ }
214
+ };
215
+
216
+ const handleRedemptionHistoryPress = () => {
217
+ console.log("🟢 Dashboard action pressed: RedemptionHistory");
218
+ setScreen(ROUTES.REDEMPTION_HISTORY); // Set screen state for API call condition
219
+ setOtpModalVisible(true);
220
+ dispatch(myOrdersGenerateOtpRequest({}));
221
+ };
222
+
223
+ const handleMyOrdersPress = () => {
224
+ console.log("🟢 Dashboard action pressed: MyOrders");
225
+ setScreen(ROUTES.MY_ORDERS); // Set screen state for API call condition
226
+ setOtpModalVisible(true);
227
+ dispatch(myOrdersGenerateOtpRequest({}));
228
+ // navigateToDashboardScreen("MyOrders", { from: "Dashboard" });
229
+ };
230
+
231
+ const handleMyVouchersPress = () => {
232
+ console.log("🟢 Dashboard action pressed: MyEVouchers");
233
+ // navigateToDashboardScreen("MyEVouchers", { from: "Dashboard" });
234
+ setScreen(ROUTES.MY_E_VOUCHERS);
235
+ dispatch(resetAuthState("validateEVouchersError" as any));
236
+ dispatch(resetAuthState("validateEVouchersSuccessMessage" as any));
237
+ setOtpModalVisible(true);
238
+ dispatch(generateEVouchersRequest({}));
239
+ };
240
+
241
+ const handleVerify = async (otp: string) => {
242
+ console.log("🔍 Dashboard handleVerify called with:", { otp, screen });
243
+ try {
244
+ if (screen === ROUTES.MY_ORDERS || screen === ROUTES.REDEMPTION_HISTORY) {
245
+ console.log(
246
+ "🚀 Dashboard dispatching myOrdersValidateOtpRequest with OTP:",
247
+ otp,
248
+ );
249
+ dispatch(
250
+ myOrdersValidateOtpRequest({
251
+ otp: otp,
252
+ }),
253
+ );
254
+ } else if (screen === ROUTES.MY_E_VOUCHERS) {
255
+ console.log(
256
+ "🚀 Dashboard dispatching validateEVouchersRequest with OTP:",
257
+ otp,
258
+ );
259
+ dispatch(
260
+ validateEVouchersRequest({
261
+ otp: otp,
262
+ }),
263
+ );
264
+ } else {
265
+ console.log("⚠️ Dashboard handleVerify: No matching screen condition", {
266
+ screen,
267
+ MY_ORDERS: ROUTES.MY_ORDERS,
268
+ MY_E_VOUCHERS: ROUTES.MY_E_VOUCHERS,
269
+ REDEMPTION_HISTORY: ROUTES.REDEMPTION_HISTORY,
270
+ });
271
+ }
272
+ } catch (error) {
273
+ console.error("Error getting dynamic headers:", error);
274
+ }
275
+ };
276
+
277
+ const navigateToCart = () => {
278
+ console.log("🧭 Dashboard navigateToCart called");
279
+ // Use the same logic as navigateToDashboardScreen for consistency
280
+ navigateToDashboardScreen("MyCart", { from: "Dashboard" });
281
+ };
282
+
283
+ const handleBackToHost = () => {
284
+ // Clear all auth state before exiting SDK to prevent stale data on next launch
285
+ dispatch(clearAllAuthState());
286
+ if (NativeModules.PropelSDKBridge?.closeSDK) {
287
+ NativeModules.PropelSDKBridge.closeSDK();
288
+ } else if (NativeModules.PropelSDKBridge?.dismiss) {
289
+ NativeModules.PropelSDKBridge.dismiss();
290
+ }
291
+ };
292
+
293
+ // Categories data with actual images
294
+ const categoriesData = [
295
+ { id: "1", name: "Apparel", image: Images.categoryApparel },
296
+ { id: "2", name: "Home Goods", image: Images.categoryHomeGoods },
297
+ { id: "3", name: "Footwear", image: Images.categoryFootwear },
298
+ { id: "4", name: "Accessories", image: Images.categoryAccessories },
299
+ ];
300
+
301
+ // E-vouchers data with actual logos
302
+ const eVouchersData = [
303
+ { id: "1", name: "Myntra", logo: Images.myntraLogo },
304
+ { id: "2", name: "Flipkart", logo: Images.flipkartLogo },
305
+ { id: "3", name: "Amazon", logo: Images.amazonLogo },
306
+ { id: "4", name: "Nike", logo: Images.nikeLogo },
307
+ ];
308
+
309
+ const renderCategoryItem = ({ item }: { item: any }) => (
310
+ <TouchableOpacity style={styles.categoryItem} activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
311
+ <View style={styles.categoryImageContainer}>
312
+ <CustomImage source={item.image} imgStyle={styles.categoryImage} />
313
+ </View>
314
+ <Text style={styles.categoryName}>{item.name}</Text>
315
+ </TouchableOpacity>
316
+ );
317
+
318
+ const renderEVoucherItem = ({ item }: { item: any }) => (
319
+ <TouchableOpacity style={styles.eVoucherItem} activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
320
+ <View style={styles.eVoucherImageContainer}>
321
+ <CustomImage source={item.logo} imgStyle={styles.eVoucherLogo} />
322
+ </View>
323
+ <Text style={styles.eVoucherName}>{item.name}</Text>
324
+ </TouchableOpacity>
325
+ );
326
+
327
+ return (
328
+ <SafeAreaView style={[styles.container]}>
329
+ <ScrollView
330
+ style={styles.scrollView}
331
+ contentContainerStyle={styles.scrollViewContent}
332
+ showsVerticalScrollIndicator={false}
333
+ bounces={true}
334
+ nestedScrollEnabled={true}
335
+ >
336
+ <View style={styles.headerSection}>
337
+ <View style={styles.userInfo}>
338
+ <TouchableOpacity
339
+ activeOpacity={0.7}
340
+ style={styles.backButton}
341
+ onPress={handleBackToHost}
342
+ >
343
+ <CustomImage
344
+ source={Images.arrowBack}
345
+ imgStyle={styles.backArrowIcon}
346
+ />
347
+ </TouchableOpacity>
348
+ <TouchableOpacity
349
+ activeOpacity={0.7}
350
+ style={styles.avatar}
351
+ onPress={() => navigation.navigate("Profile")}
352
+ >
353
+ <Text style={styles.avatarText}>
354
+ {dashboardInfoData?.name?.slice(0, 2)?.toUpperCase() || "BK"}
355
+ </Text>
356
+ </TouchableOpacity>
357
+ <View style={styles.userDetails}>
358
+ <Text style={styles.greeting}>Hello!</Text>
359
+ <Text style={styles.userName}>{dashboardInfoData?.name || ''}</Text>
360
+ </View>
361
+ </View>
362
+ <View style={styles.headerIcons}>
363
+ <TouchableOpacity
364
+ activeOpacity={0.7}
365
+ style={styles.cartButton}
366
+ onPress={() => navigateToCart()}
367
+ >
368
+ <View style={styles.cartCountContainer}>
369
+ <Text style={styles.cartCountText}>
370
+ {viewMyCartData?.items?.length || 0}
371
+ </Text>
372
+ </View>
373
+ <CustomImage source={Images.cart} imgStyle={styles.headerIcon} />
374
+ </TouchableOpacity>
375
+ </View>
376
+ </View>
377
+
378
+ {/* Header Section with Floral Background */}
379
+ <ImageBackground
380
+ source={Images.floralBackground}
381
+ style={styles.headerBackground}
382
+ resizeMode="cover"
383
+ >
384
+ {/* Points Card */}
385
+ <View style={styles.pointsCardContainer}>
386
+ <View style={styles.pointsCard}>
387
+ <View style={styles.pointsCardLeft}>
388
+ <CustomImage
389
+ source={Images.coinIcon}
390
+ imgStyle={styles.coinIcon}
391
+ />
392
+ </View>
393
+ <View style={styles.pointsCardCenter}>
394
+ <Text style={styles.yourPointsLabel}>Your Points</Text>
395
+ <Text style={styles.pointsValue} numberOfLines={1}>
396
+ {dashboardInfoData?.current_balance || '0'}
397
+ </Text>
398
+ </View>
399
+ <TouchableOpacity
400
+ activeOpacity={0.7}
401
+ style={styles.redeemButton}
402
+ onPress={() => navigateToDashboardScreen("Redeem")}
403
+ >
404
+ <Text style={styles.redeemButtonText}>Redeem Now</Text>
405
+ </TouchableOpacity>
406
+ </View>
407
+ </View>
408
+ </ImageBackground>
409
+
410
+ {/* Action Buttons */}
411
+ <View style={styles.actionsSection}>
412
+ <TouchableOpacity
413
+ style={styles.actionItem}
414
+ onPress={handleRedemptionHistoryPress}
415
+ activeOpacity={0.7}
416
+ >
417
+ <CustomImage
418
+ source={Images.redemptionHistory}
419
+ imgStyle={styles.actionIcon}
420
+ />
421
+ <Text style={styles.actionLabel}>Redemption{"\n"}History</Text>
422
+ </TouchableOpacity>
423
+ <TouchableOpacity
424
+ activeOpacity={0.7}
425
+ style={styles.actionItem}
426
+ onPress={handleMyOrdersPress}
427
+ >
428
+ <CustomImage
429
+ source={Images.myOrders}
430
+ imgStyle={styles.actionIcon}
431
+ />
432
+ <Text style={styles.actionLabel}>My Orders</Text>
433
+ </TouchableOpacity>
434
+ <TouchableOpacity
435
+ activeOpacity={0.7}
436
+ onPress={handleMyVouchersPress}
437
+ style={styles.actionItem}
438
+ >
439
+ <CustomImage
440
+ source={Images.eVoucher}
441
+ imgStyle={styles.actionIcon}
442
+ />
443
+ <Text style={styles.actionLabel}>My Vouchers</Text>
444
+ </TouchableOpacity>
445
+ </View>
446
+
447
+ {/* Discount Banner */}
448
+ <View style={styles.bannerSection}>
449
+ <CustomImage
450
+ source={Images.discountBanner}
451
+ imgStyle={styles.discountBanner}
452
+ />
453
+ </View>
454
+
455
+ {/* Our Categories Section */}
456
+ <TouchableOpacity style={styles.sectionContainer} activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
457
+ <View style={styles.sectionHeader}>
458
+ <Text style={styles.sectionTitle}>Our Categories</Text>
459
+ <TouchableOpacity activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
460
+ <Text style={styles.viewAllText}>View all</Text>
461
+ </TouchableOpacity>
462
+ </View>
463
+ <FlatList
464
+ data={categoriesData}
465
+ renderItem={renderCategoryItem}
466
+ keyExtractor={(item) => item.id}
467
+ horizontal
468
+ showsHorizontalScrollIndicator={false}
469
+ contentContainerStyle={styles.categoriesList}
470
+ />
471
+ </TouchableOpacity>
472
+
473
+ {/* E-Vouchers Section */}
474
+ <TouchableOpacity style={styles.sectionContainer} activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
475
+ <View style={styles.sectionHeader}>
476
+ <Text style={styles.sectionTitle}>E-Vouchers</Text>
477
+ <TouchableOpacity activeOpacity={0.7} onPress={() => navigateToDashboardScreen("Redeem")}>
478
+ <Text style={styles.viewAllText}>View all</Text>
479
+ </TouchableOpacity>
480
+ </View>
481
+ <FlatList
482
+ data={eVouchersData}
483
+ renderItem={renderEVoucherItem}
484
+ keyExtractor={(item) => item.id}
485
+ horizontal
486
+ showsHorizontalScrollIndicator={false}
487
+ contentContainerStyle={styles.eVouchersList}
488
+ />
489
+ </TouchableOpacity>
490
+ </ScrollView>
491
+ <OTPModal
492
+ visible={otpModalVisible}
493
+ onClose={() => {
494
+ setOtpModalVisible(false);
495
+ setScreen("");
496
+ dispatch(resetAuthState("myOrdersGenerateOtpError"));
497
+ dispatch(resetAuthState("myOrdersValidateOtpError"));
498
+ dispatch(resetAuthState("myOrdersValidateOtpSuccessMessage"));
499
+ dispatch(resetAuthState("validateEVouchersError"));
500
+ dispatch(resetAuthState("validateEVouchersSuccessMessage"));
501
+ }}
502
+ onVerify={(otp) => {
503
+ handleVerify(otp);
504
+ setResetOtpTrigger((prev) => prev + 1);
505
+ }}
506
+ onResend={() => {
507
+ dispatch(resetAuthState("myOrdersGenerateOtpError" as any));
508
+ dispatch(resetAuthState("myOrdersValidateOtpError" as any));
509
+ dispatch(resetAuthState("validateEVouchersError" as any));
510
+
511
+ if (screen === ROUTES.MY_ORDERS || screen === ROUTES.REDEMPTION_HISTORY) {
512
+ dispatch(myOrdersGenerateOtpRequest({}));
513
+ } else if (screen === ROUTES.MY_E_VOUCHERS) {
514
+ dispatch(generateEVouchersRequest({}));
515
+ }
516
+ }}
517
+ onNavigateToOrders={() => {}}
518
+ resetOtpTrigger={resetOtpTrigger}
519
+ otpLength={4}
520
+ screen={screen}
521
+ />
522
+ <CustomLoader
523
+ loading={!!sdkAuthLoading || !!dashboardInfoLoading}
524
+ text={sdkAuthLoading ? "Authenticating..." : "Please wait..."}
525
+ fullScreen
526
+ />
527
+ </SafeAreaView>
528
+ );
529
+ };
530
+
531
+ export default Dashboard;