@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.
- package/assets/fonts/Lexend-Black.ttf +0 -0
- package/assets/fonts/Lexend-Bold.ttf +0 -0
- package/assets/fonts/Lexend-ExtraBold.ttf +0 -0
- package/assets/fonts/Lexend-ExtraLight.ttf +0 -0
- package/assets/fonts/Lexend-Light.ttf +0 -0
- package/assets/fonts/Lexend-Medium.ttf +0 -0
- package/assets/fonts/Lexend-Regular.ttf +0 -0
- package/assets/fonts/Lexend-SemiBold.ttf +0 -0
- package/assets/fonts/Lexend-Thin.ttf +0 -0
- package/assets/images/HomeGoods.png +0 -0
- package/assets/images/accessories.png +0 -0
- package/assets/images/amazon.png +0 -0
- package/assets/images/apnaClubLogo.png +0 -0
- package/assets/images/apparel.png +0 -0
- package/assets/images/backgroundblue.png +0 -0
- package/assets/images/bannerCard.png +0 -0
- package/assets/images/bottomWave.png +0 -0
- package/assets/images/coin_1_1.png +0 -0
- package/assets/images/flipkart.png +0 -0
- package/assets/images/frame_1171278967.png +0 -0
- package/assets/images/gift.png +0 -0
- package/assets/images/herobanner.png +0 -0
- package/assets/images/hinduPencilsLogo.png +0 -0
- package/assets/images/icons/addwhiteicon.png +0 -0
- package/assets/images/icons/arrow-back.png +0 -0
- package/assets/images/icons/arrowgreen.png +0 -0
- package/assets/images/icons/arrowred.png +0 -0
- package/assets/images/icons/arrowright.png +0 -0
- package/assets/images/icons/arrowup.png +0 -0
- package/assets/images/icons/blackarrowdown.png +0 -0
- package/assets/images/icons/blackarrowup.png +0 -0
- package/assets/images/icons/blackcross.png +0 -0
- package/assets/images/icons/call.png +0 -0
- package/assets/images/icons/camera.png +0 -0
- package/assets/images/icons/cart.png +0 -0
- package/assets/images/icons/chat.png +0 -0
- package/assets/images/icons/circleblack.png +0 -0
- package/assets/images/icons/copy.png +0 -0
- package/assets/images/icons/cross.png +0 -0
- package/assets/images/icons/delete.png +0 -0
- package/assets/images/icons/delivery.png +0 -0
- package/assets/images/icons/eVoucher.png +0 -0
- package/assets/images/icons/editIcon.png +0 -0
- package/assets/images/icons/email.png +0 -0
- package/assets/images/icons/eye.png +0 -0
- package/assets/images/icons/faq.png +0 -0
- package/assets/images/icons/filtericon.png +0 -0
- package/assets/images/icons/greyDownArrow.png +0 -0
- package/assets/images/icons/help.png +0 -0
- package/assets/images/icons/home.png +0 -0
- package/assets/images/icons/homeinactive.png +0 -0
- package/assets/images/icons/i_blackicon.png +0 -0
- package/assets/images/icons/i_icon.png +0 -0
- package/assets/images/icons/location.png +0 -0
- package/assets/images/icons/logout.png +0 -0
- package/assets/images/icons/minus.png +0 -0
- package/assets/images/icons/myOrders.png +0 -0
- package/assets/images/icons/orders.png +0 -0
- package/assets/images/icons/pencillogo.png +0 -0
- package/assets/images/icons/pending.png +0 -0
- package/assets/images/icons/plus.png +0 -0
- package/assets/images/icons/redCross.png +0 -0
- package/assets/images/icons/redCrossicon.png +0 -0
- package/assets/images/icons/redWarningicon.png +0 -0
- package/assets/images/icons/redeem.png +0 -0
- package/assets/images/icons/redeemactive.png +0 -0
- package/assets/images/icons/redemptionHistory.png +0 -0
- package/assets/images/icons/redhelpicon.png +0 -0
- package/assets/images/icons/search.png +0 -0
- package/assets/images/icons/stopwatch.png +0 -0
- package/assets/images/icons/successTick.gif +0 -0
- package/assets/images/icons/tick.png +0 -0
- package/assets/images/icons/tnc.png +0 -0
- package/assets/images/icons/user.png +0 -0
- package/assets/images/icons/userredicon.png +0 -0
- package/assets/images/icons/wavecorner.png +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/myntra_copy.png +0 -0
- package/assets/images/nike.png +0 -0
- package/assets/images/oq3p0u0_1.png +0 -0
- package/assets/images/profileicon.png +0 -0
- package/assets/images/topWave.png +0 -0
- package/assets/images/zagglePropelLogo.png +0 -0
- package/index.ts +23 -0
- package/lib/index.ts +25 -0
- package/package.json +70 -0
- package/src/PropelSDKScreen.tsx +98 -0
- package/src/SDKApp.tsx +540 -0
- package/src/bridge/SDKBridge.ts +104 -0
- package/src/bridge/index.ts +3 -0
- package/src/components/SDKBackHandler.tsx +187 -0
- package/src/components/SDKProfile.tsx +87 -0
- package/src/components/SDKProfileWrapper.tsx +51 -0
- package/src/constants.ts +10 -0
- package/src/contexts/SDKContext.tsx +72 -0
- package/src/hooks/useSDKBackNavigation.ts +61 -0
- package/src/navigation/SDKMainTabNavigator.tsx +315 -0
- package/src/navigation/SDKNavigator.tsx +41 -0
- package/src/redux/store.ts +32 -0
- package/src/screens/Dashboard/index.tsx +531 -0
- package/src/screens/Dashboard/styles.ts +512 -0
- package/src/screens/DeliveryAddress/index.tsx +221 -0
- package/src/screens/DeliveryAddress/styles.ts +122 -0
- package/src/screens/E-Vouchers/index.tsx +157 -0
- package/src/screens/E-Vouchers/styles.ts +106 -0
- package/src/screens/Faq/Faq.constants.ts +164 -0
- package/src/screens/Faq/index.tsx +114 -0
- package/src/screens/Faq/styles.ts +131 -0
- package/src/screens/Help/index.tsx +128 -0
- package/src/screens/Help/styles.ts +121 -0
- package/src/screens/Login/index.tsx +215 -0
- package/src/screens/Login/styles.ts +134 -0
- package/src/screens/MyCart/MyCart.constants.ts +13 -0
- package/src/screens/MyCart/index.tsx +318 -0
- package/src/screens/MyCart/styles.ts +249 -0
- package/src/screens/MyOrders/index.tsx +87 -0
- package/src/screens/MyOrders/styles.ts +281 -0
- package/src/screens/MyProfile/index.tsx +72 -0
- package/src/screens/MyProfile/styles.ts +47 -0
- package/src/screens/NewDeliveryAddress/index.tsx +360 -0
- package/src/screens/NewDeliveryAddress/styles.ts +68 -0
- package/src/screens/Onboarding/index.tsx +57 -0
- package/src/screens/Onboarding/styles.ts +60 -0
- package/src/screens/OrdersDetails/index.tsx +333 -0
- package/src/screens/OrdersDetails/styles.ts +262 -0
- package/src/screens/OtpVerification/index.tsx +283 -0
- package/src/screens/OtpVerification/styles.ts +197 -0
- package/src/screens/PaymentMethod/index.tsx +389 -0
- package/src/screens/PaymentMethod/styles.ts +246 -0
- package/src/screens/PointsLog/index.tsx +286 -0
- package/src/screens/PointsLog/styles.ts +156 -0
- package/src/screens/ProductDetails/index.tsx +682 -0
- package/src/screens/ProductDetails/styles.ts +372 -0
- package/src/screens/Profile/index.tsx +368 -0
- package/src/screens/Profile/styles.ts +158 -0
- package/src/screens/RedemptionHistory/RedemptionHistory.constants.ts +4 -0
- package/src/screens/RedemptionHistory/index.tsx +304 -0
- package/src/screens/RedemptionHistory/styles.ts +84 -0
- package/src/screens/Reedem/index.tsx +345 -0
- package/src/screens/Reedem/styles.ts +269 -0
- package/src/screens/TnC/TnC.constants.ts +169 -0
- package/src/screens/TnC/index.tsx +83 -0
- package/src/screens/TnC/styles.ts +88 -0
- package/src/screens/TransactionSuccessful/index.tsx +77 -0
- package/src/screens/TransactionSuccessful/styles.ts +77 -0
- package/src/screens/Verification/index.tsx +58 -0
- package/src/screens/Verification/styles.ts +74 -0
- package/src/screens/index.ts +23 -0
- package/src/types/index.ts +46 -0
- package/src-app/components/AmountBreakDownModal/index.tsx +86 -0
- package/src-app/components/AmountBreakDownModal/styles.ts +110 -0
- package/src-app/components/BottomNavIcons.tsx +125 -0
- package/src-app/components/Button.tsx +120 -0
- package/src-app/components/Card.tsx +47 -0
- package/src-app/components/ConfirmPopup/ConfirmPopup.constants.ts +25 -0
- package/src-app/components/ConfirmPopup/index.tsx +48 -0
- package/src-app/components/ConfirmPopup/styles.ts +167 -0
- package/src-app/components/CustomButton/index.tsx +67 -0
- package/src-app/components/CustomButton/styles.ts +44 -0
- package/src-app/components/CustomCard/index.tsx +221 -0
- package/src-app/components/CustomCard/styles.ts +184 -0
- package/src-app/components/CustomError/index.tsx +54 -0
- package/src-app/components/CustomError/styles.ts +41 -0
- package/src-app/components/CustomImage/index.tsx +37 -0
- package/src-app/components/CustomImage/styles.ts +5 -0
- package/src-app/components/CustomLoader/index.tsx +45 -0
- package/src-app/components/CustomLoader/styles.ts +35 -0
- package/src-app/components/CustomMessagePopUp/index.tsx +51 -0
- package/src-app/components/CustomMessagePopUp/styles.ts +74 -0
- package/src-app/components/CustomProductCard/index.tsx +13 -0
- package/src-app/components/CustomProductCard/styles.ts +5 -0
- package/src-app/components/FilterModal.tsx +372 -0
- package/src-app/components/Footer/index.tsx +23 -0
- package/src-app/components/Footer/styles.ts +37 -0
- package/src-app/components/Icon.tsx +80 -0
- package/src-app/components/Logout/index.tsx +82 -0
- package/src-app/components/Logout/styles.ts +116 -0
- package/src-app/components/MobileHeader.tsx +141 -0
- package/src-app/components/NoDataFound/index.tsx +18 -0
- package/src-app/components/NoDataFound/styles.ts +26 -0
- package/src-app/components/OTPModal.tsx +747 -0
- package/src-app/components/ProfileField.tsx +47 -0
- package/src-app/components/QuantityModal/index.tsx +113 -0
- package/src-app/components/QuantityModal/styles.ts +84 -0
- package/src-app/components/TabBarIcons.tsx +110 -0
- package/src-app/components/TextInput.tsx +79 -0
- package/src-app/components/ToastConfig.tsx +60 -0
- package/src-app/components/index.ts +18 -0
- package/src-app/config/env.ts +22 -0
- package/src-app/constants/Fonts.ts +12 -0
- package/src-app/constants/Formatter.ts +39 -0
- package/src-app/constants/HtmlSanitization.ts +46 -0
- package/src-app/constants/Images.ts +81 -0
- package/src-app/constants/Labels.ts +8 -0
- package/src-app/constants/Messages.ts +108 -0
- package/src-app/constants/Routes.ts +17 -0
- package/src-app/constants/Scaling.ts +5 -0
- package/src-app/constants/Text.ts +8 -0
- package/src-app/constants/offSets.ts +18 -0
- package/src-app/hooks/useAppDispatch.ts +4 -0
- package/src-app/hooks/useAppSelector.ts +4 -0
- package/src-app/hooks/useBackHandler.ts +47 -0
- package/src-app/hooks/useScreenBackHandler.ts +91 -0
- package/src-app/navigation/AppNavigator.tsx +34 -0
- package/src-app/navigation/MainTabNavigator.tsx +294 -0
- package/src-app/redux/authSaga.ts +605 -0
- package/src-app/redux/authSlice.ts +754 -0
- package/src-app/redux/rootSaga.ts +6 -0
- package/src-app/redux/store.ts +25 -0
- package/src-app/services/api.ts +14 -0
- package/src-app/services/endpoints.ts +33 -0
- package/src-app/services/index.ts +574 -0
- package/src-app/services/sdkCredentials.ts +44 -0
- package/src-app/styles/colors.ts +85 -0
- package/src-app/styles/shared.ts +112 -0
- package/src-app/types/authTypes.ts +155 -0
- package/src-app/types/navigation.ts +99 -0
- package/src-app/utils/Validation.ts +48 -0
- package/src-app/utils/filterPins.ts +29 -0
- package/src-app/utils/navigationUtils.ts +43 -0
- 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;
|