@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,215 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import {
3
+ View,
4
+ Text,
5
+ TextInput,
6
+ TouchableWithoutFeedback,
7
+ Keyboard,
8
+ ScrollView,
9
+ KeyboardAvoidingView,
10
+ Platform,
11
+ } from "react-native";
12
+ import { StackNavigationProp } from "@react-navigation/stack";
13
+ import DeviceInfo from "react-native-device-info";
14
+ import styles from "./styles";
15
+ import { RootStackParamList } from "../../../src-app/types/navigation";
16
+ import Images from "../../../src-app/constants/Images";
17
+ import { generateOtpRequest, resetAuthState } from "../../../src-app/redux/authSlice";
18
+ import { useAppDispatch } from "../../../src-app/hooks/useAppDispatch";
19
+ import {
20
+ CustomButton,
21
+ CustomImage,
22
+ CustomLoader,
23
+ CustomMessagePopUp,
24
+ Footer,
25
+ } from "../../../src-app/components";
26
+ import { SafeAreaView } from "react-native-safe-area-context";
27
+ import AsyncStorage from "@react-native-async-storage/async-storage";
28
+ import { useAppSelector } from "../../../src-app/hooks/useAppSelector";
29
+ import { RouteProp, useRoute } from "@react-navigation/native";
30
+ import {
31
+ LOGIN_WELCOME_BACK_TITLE,
32
+ LOGIN_ENTER_MOBILE_TITLE,
33
+ LOGIN_SIGNIN_OR_SIGNUP_SUBTITLE,
34
+ LOGIN_BTN_SEND_OTP,
35
+ LOGIN_BTN_VERIFY,
36
+ SEND_OTP_LOADER,
37
+ } from "../../../src-app/constants/Messages";
38
+ import { colors } from "../../../src-app/styles/colors";
39
+
40
+ type LoginNavigationProp = StackNavigationProp<RootStackParamList, "Login">;
41
+ type LoginRouteProp = RouteProp<RootStackParamList, "Login">;
42
+
43
+ interface Props {
44
+ navigation: LoginNavigationProp;
45
+ }
46
+
47
+ const Login: React.FC<Props> = ({ navigation }) => {
48
+ const [phoneNumber, setPhoneNumber] = useState("");
49
+ const [isReturningUser, setIsReturningUser] = useState(false);
50
+ const route = useRoute<LoginRouteProp>();
51
+
52
+ const dispatch = useAppDispatch();
53
+ const otpError = useAppSelector((state) => state.auth.otpError);
54
+ const otpLoading = useAppSelector((state) => state.auth.otpLoading);
55
+ const otpData = useAppSelector((state) => state.auth.otpData);
56
+ const [messagepopUpVisible, setMessagepopUpVisible] = useState(false);
57
+ const [isOtpRequestTriggered, setIsOtpRequestTriggered] = useState(false);
58
+ const [deviceId, setDeviceId] = useState<string>("");
59
+
60
+ const handlePhoneChange = (text: string) => {
61
+ const digitsOnly = text.replace(/[^0-9]/g, "");
62
+ setPhoneNumber(digitsOnly);
63
+ };
64
+
65
+ // Decide which UI to show
66
+ useEffect(() => {
67
+ (async () => {
68
+ if (route?.params?.isReturning === true) {
69
+ setIsReturningUser(true);
70
+ return;
71
+ }
72
+ const hasLoggedInOnce = await AsyncStorage.getItem("HAS_LOGGED_IN_ONCE");
73
+ setIsReturningUser(hasLoggedInOnce === "true");
74
+ })();
75
+ }, [route?.params?.isReturning]);
76
+
77
+ const titleText = isReturningUser ? LOGIN_WELCOME_BACK_TITLE: LOGIN_ENTER_MOBILE_TITLE;
78
+ const subTitleText = isReturningUser ? LOGIN_SIGNIN_OR_SIGNUP_SUBTITLE: "";
79
+ const buttonText = isReturningUser ? LOGIN_BTN_SEND_OTP : LOGIN_BTN_VERIFY;
80
+
81
+ useEffect(() => {
82
+ if (otpError) {
83
+ setMessagepopUpVisible(true);
84
+ }
85
+ }, [otpError]);
86
+
87
+ useEffect(() => {
88
+ const getDeviceId = async () => {
89
+ try {
90
+ const id = await DeviceInfo.getUniqueId();
91
+ const device_id = String(id);
92
+ setDeviceId(device_id);
93
+ console.log("device_id", device_id);
94
+ } catch (error) {
95
+ console.log("Error getting device ID:", error);
96
+ }
97
+ };
98
+
99
+ getDeviceId();
100
+ }, []);
101
+
102
+ const handleGenerateOtp = () => {
103
+
104
+ dispatch(
105
+ generateOtpRequest({
106
+ client_name: "iOSApp",
107
+ client_series: "1930",
108
+ client_version: "17.2",
109
+ device_id: deviceId,
110
+ mobile: phoneNumber,
111
+ is_hppl_login: true,
112
+ })
113
+ );
114
+ };
115
+
116
+ useEffect(() => {
117
+ dispatch(resetAuthState("otpData"));
118
+ dispatch(resetAuthState("otpError"));
119
+ }, [dispatch]);
120
+
121
+ useEffect(() => {
122
+ if (isOtpRequestTriggered) {
123
+ if (!otpLoading && otpData && !otpError) {
124
+ AsyncStorage.setItem("HAS_LOGGED_IN_ONCE", "true");
125
+ navigation.navigate("OTPVerification", { phoneNumber });
126
+ setIsOtpRequestTriggered(false);
127
+ }
128
+ if (otpError) {
129
+ setMessagepopUpVisible(true);
130
+ setIsOtpRequestTriggered(false);
131
+ }
132
+ }
133
+ }, [isOtpRequestTriggered, otpData, otpError, otpLoading, navigation, phoneNumber]);
134
+
135
+ const handleVerify = () => {
136
+ if (phoneNumber.length >= 10) {
137
+ setIsOtpRequestTriggered(true);
138
+ dispatch(resetAuthState("otpData"));
139
+ dispatch(resetAuthState("otpError"));
140
+ handleGenerateOtp();
141
+ }
142
+ };
143
+
144
+ return (
145
+ <SafeAreaView style={styles.container} edges={["top", "bottom"]}>
146
+ <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
147
+ <ScrollView
148
+ contentContainerStyle={styles.scrollContainer}
149
+ keyboardShouldPersistTaps="handled"
150
+ showsVerticalScrollIndicator={false}
151
+ bounces={false}
152
+ >
153
+ <View style={styles.content}>
154
+ <CustomImage source={Images.topWave} imgStyle={styles.topShape} />
155
+ <CustomImage
156
+ source={Images.bottomWave}
157
+ imgStyle={styles.bottomShape}
158
+ />
159
+
160
+ <CustomImage source={Images?.logo} imgStyle={styles.logoSection} />
161
+
162
+ <View style={styles.formSection}>
163
+ <Text style={[[styles.formTitle, isReturningUser && styles.formTitleLarge]]}>{titleText}</Text>
164
+ {Boolean(subTitleText) && (
165
+ <Text style={styles.formSubtitle}>{subTitleText}</Text>
166
+ )}
167
+
168
+ <View style={styles.inputContainer}>
169
+ <View style={styles.countryCodeSection}>
170
+ <Text style={styles.countryCodeText}>+91</Text>
171
+ <CustomImage
172
+ source={Images?.greyDownArrow}
173
+ imgStyle={styles.arrow}
174
+ />
175
+ </View>
176
+ <View style={styles.divider} />
177
+ <TextInput
178
+ style={styles.phoneInput}
179
+ placeholder="Mobile number"
180
+ placeholderTextColor={colors.otpPlaceholderMobile}
181
+ value={phoneNumber}
182
+ onChangeText={handlePhoneChange}
183
+ keyboardType={Platform.OS === "ios" ? "number-pad" : "numeric"}
184
+ maxLength={10}
185
+ />
186
+ </View>
187
+ </View>
188
+
189
+ <CustomButton
190
+ title={buttonText}
191
+ onPress={handleVerify}
192
+ disabled={phoneNumber.length < 10}
193
+ customButtonContainerStyle={styles.buttonContainer}
194
+ />
195
+
196
+ <Footer />
197
+ </View>
198
+ <CustomMessagePopUp
199
+ title="Error"
200
+ message={otpError || ""}
201
+ visible={messagepopUpVisible}
202
+ onClose={() => {
203
+ setMessagepopUpVisible(false);
204
+ dispatch(resetAuthState("otpError"));
205
+ }}
206
+ icon={Images.pendingIcon}
207
+ />
208
+ </ScrollView>
209
+ </TouchableWithoutFeedback>
210
+ <CustomLoader loading={!!otpLoading} text={SEND_OTP_LOADER} fullScreen />
211
+ </SafeAreaView>
212
+ );
213
+ };
214
+
215
+ export default Login;
@@ -0,0 +1,134 @@
1
+ import { Platform, StyleSheet, Dimensions } from 'react-native';
2
+ import { SCALE, VSCALE, MSCALE } from '../../../src-app/constants/Scaling';
3
+ import FontFamily from '../../../src-app/constants/Fonts';
4
+
5
+ const { height: screenHeight } = Dimensions.get('window');
6
+
7
+ const styles = StyleSheet.create({
8
+ container: {
9
+ flex: 1,
10
+ backgroundColor: '#FFFFFF',
11
+ },
12
+ content: {
13
+ flex: 1,
14
+ // position: 'relative',
15
+ position: 'relative',
16
+ // paddingBottom: VSCALE(40),
17
+ },
18
+ topShape: {
19
+ position: 'absolute',
20
+ width: '100%',
21
+ height: VSCALE(250),
22
+ left: SCALE(70),
23
+ top: 0,
24
+ zIndex: -1,
25
+ },
26
+
27
+ formSubtitle: {
28
+ fontFamily: FontFamily.LEXEND_REGULAR,
29
+ fontSize: MSCALE(12),
30
+ color: '#6B7280',
31
+ marginBottom: VSCALE(16),
32
+ },
33
+ formTitleLarge: {
34
+ fontFamily: FontFamily.LEXEND_SEMIBOLD, // or LEXEND_BOLD
35
+ fontSize: 28,
36
+ marginBottom: VSCALE(8), // use fixed 28 to be obvious
37
+ },
38
+
39
+ bottomShape: {
40
+ position: 'absolute',
41
+ width: '100%',
42
+ height: VSCALE(200),
43
+ left: SCALE(-50),
44
+ bottom: VSCALE(0),
45
+ zIndex: -1,
46
+ },
47
+ logoSection: {
48
+ width: SCALE(177),
49
+ height: VSCALE(182),
50
+ resizeMode: 'contain',
51
+ alignSelf: 'center',
52
+ marginTop: screenHeight > 700 ? VSCALE(100) : VSCALE(80),
53
+ },
54
+ hindustanPencilsLogo: {
55
+ width: SCALE(180),
56
+ height: VSCALE(60),
57
+ resizeMode: 'contain',
58
+ },
59
+ formSection: {
60
+ paddingHorizontal: SCALE(20),
61
+ justifyContent: 'center',
62
+ marginTop: VSCALE(10),
63
+ },
64
+ formTitle: {
65
+ fontFamily: FontFamily.LEXEND_REGULAR,
66
+ fontSize: MSCALE(14),
67
+ color: '#1F2937',
68
+ marginBottom: VSCALE(16),
69
+ textTransform: 'capitalize',
70
+ },
71
+ inputContainer: {
72
+ flexDirection: 'row',
73
+ alignItems: 'center',
74
+ borderWidth: SCALE(1),
75
+ borderColor: '#D1D5DB',
76
+ borderRadius: SCALE(12),
77
+ backgroundColor: '#FFFFFF',
78
+ height: VSCALE(50),
79
+ paddingHorizontal: SCALE(20),
80
+ shadowColor: '#000',
81
+ shadowOffset: {
82
+ width: 0,
83
+ height: VSCALE(1),
84
+ },
85
+ shadowOpacity: 0.1,
86
+ shadowRadius: SCALE(2),
87
+ elevation: 2,
88
+ },
89
+ countryCodeSection: {
90
+ flexDirection: 'row',
91
+ alignItems: 'center',
92
+ gap: SCALE(8),
93
+ },
94
+ countryCodeText: {
95
+ fontFamily: FontFamily.LEXEND_REGULAR,
96
+ fontSize: MSCALE(14),
97
+ color: '#1F2937',
98
+ },
99
+ divider: {
100
+ width: SCALE(1),
101
+ height: VSCALE(24),
102
+ backgroundColor: '#D1D5DB',
103
+ marginHorizontal: SCALE(16),
104
+ },
105
+ phoneInput: {
106
+ flex: 1,
107
+ fontFamily: FontFamily.LEXEND_REGULAR,
108
+ fontSize: MSCALE(14),
109
+ color: '#1F2937',
110
+ height: '100%',
111
+ paddingVertical: 0,
112
+ },
113
+ arrow: {
114
+ height: VSCALE(4),
115
+ width: SCALE(8),
116
+ resizeMode: 'contain',
117
+ },
118
+ buttonContainer: {
119
+ paddingHorizontal: SCALE(20),
120
+ marginBottom: VSCALE(20),
121
+ },
122
+ footer: {
123
+ paddingBottom: Platform.OS === 'ios' ? VSCALE(0) : VSCALE(0),
124
+ paddingTop: VSCALE(10),
125
+ alignItems: 'center',
126
+ },
127
+ scrollContainer: {
128
+ flexGrow: 1,
129
+ // justifyContent: 'space-between',
130
+ }
131
+
132
+ });
133
+
134
+ export default styles;
@@ -0,0 +1,13 @@
1
+ export const MY_CART = "My Cart"
2
+ export const CONTINUE_SHOPPING = "Continue Shopping"
3
+ export const DELIVERY_ADDRESS = "DeliveryAddress"
4
+ export const PAYMENT_METHOD = "PaymentMethod"
5
+ export const MyCart = "MyCart"
6
+ export const EVOUCHER = 'EVOUCHER'
7
+ export const E_VOUCHER = "E-VOUCHER"
8
+ export const VIRTUAL = "VIRTUAL"
9
+ export const PHYSICAL = "PHYSICAL"
10
+ export const DELIVER = "DELIVER"
11
+ export const SHIPPED = "SHIPPED"
12
+ export const MERCHANDISE = "MERCHANDISE"
13
+ export const Checkout = "Checkout"
@@ -0,0 +1,318 @@
1
+ import { View, Text, TouchableOpacity, ScrollView} from 'react-native';
2
+ import React, {useCallback, useEffect, useState } from 'react';
3
+ import styles from './styles';
4
+ import { RouteProp, useFocusEffect, useIsFocused, useRoute } from '@react-navigation/native';
5
+ import { AppStackParamList } from '../../../src-app/types/navigation';
6
+ import MobileHeader from '../../../src-app/components/MobileHeader';
7
+ import CustomImage from '../../../src-app/components/CustomImage';
8
+ import { useAppDispatch } from '../../../src-app/hooks/useAppDispatch';
9
+ import { deleteCartRequest,updateCartRequest,viewMyCartRequest,dashboardInfoRequest,
10
+ } from '../../../src-app/redux/authSlice';
11
+ import { useAppSelector } from '../../../src-app/hooks/useAppSelector';
12
+ import { RootState } from '../../../src-app/redux/store';
13
+ import Images from '../../../src-app/constants/Images';
14
+ import { CustomButton, CustomLoader, QuantityModal} from '../../../src-app/components';
15
+ import { AMOUNT_TO_BE_PAID, EMPTY_CART_SUBTITLE, EMPTY_CART_TITLE, ITEM_DELETE_CANCEL, ITEM_DELETE_CONFIRM, ITEM_DELETE_TITLE, POINTS, REMAINING_AMOUNT } from '../../../src-app/constants/Messages';
16
+ import ConfirmPopup from '../../../src-app/components/ConfirmPopup';
17
+ import { colors } from '../../../src-app/styles/colors';
18
+ import { handleCustomGoBack } from '../../../src-app/utils/navigationUtils';
19
+ import { ROUTES } from '../../../src-app/constants/Routes';
20
+ import { useHardwareBack } from '../../../src-app/utils/useHardwareBack';
21
+ import { Checkout, CONTINUE_SHOPPING, DELIVER, DELIVERY_ADDRESS, E_VOUCHER, EVOUCHER, MERCHANDISE, MY_CART, PAYMENT_METHOD, PHYSICAL, SHIPPED, VIRTUAL } from './MyCart.constants';
22
+
23
+
24
+ interface MyCartProps {
25
+ navigation?: any;
26
+ }
27
+
28
+ type MyCartRouteProp = RouteProp<AppStackParamList, 'MyCart'>;
29
+
30
+ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
31
+ const route = useRoute<MyCartRouteProp>();
32
+ const from = route.params?.from;
33
+ const id = route.params?.id;
34
+ const dispatch = useAppDispatch();
35
+ const isFocus = useIsFocused();
36
+ const [visible, setVisible] = useState(false);
37
+ const [selectedQty, setSelectedQty] = useState<number | null>(null);
38
+ const [selectedItem, setSelectedItem] = useState<any | null>(null);
39
+ const cartId = useAppSelector((state: RootState) => state.auth.cartId);
40
+ const [selectedQuantity, setSelectedQuantity] = useState<number | null>(null);
41
+
42
+ const { viewMyCartData, viewMyCartLoading } = useAppSelector(
43
+ (state: RootState) => state.auth,
44
+ );
45
+ const [confirmVisible, setConfirmVisible] = useState(false);
46
+ const [itemToDelete, setItemToDelete] = useState<any | null>(null);
47
+
48
+
49
+ const cartNeedsAddress = (items: any[] = []) => {
50
+ if (!Array.isArray(items) || items?.length === 0) return false;
51
+
52
+ const isPhysical = (it: any) => {
53
+ const t = (it?.product?.product_type || '').toString().toUpperCase();
54
+ if (t.includes(EVOUCHER) || t.includes(E_VOUCHER) || t.includes(VIRTUAL)) return false;
55
+ if (t.includes(PHYSICAL) || t.includes(DELIVER) || t.includes(SHIPPED) || t.includes(MERCHANDISE)) return true;
56
+
57
+ if (it?.requires_address === true) return true;
58
+ if (it?.requires_address === false) return false;
59
+
60
+ return false;
61
+ };
62
+
63
+ return items?.some(isPhysical);
64
+ };
65
+
66
+ useFocusEffect(
67
+ useCallback(() => {
68
+ return () => {
69
+ setConfirmVisible(false);
70
+ };
71
+ }, [])
72
+ );
73
+
74
+
75
+ useEffect(() => {
76
+ setSelectedQty(viewMyCartData?.items?.[0]?.quantity);
77
+ }, [viewMyCartData]);
78
+
79
+ useEffect(() => {
80
+ dispatch(dashboardInfoRequest({}));
81
+ }, [dispatch]);
82
+
83
+ useEffect(() => {
84
+ if (isFocus) {
85
+ if (cartId) {
86
+ dispatch(viewMyCartRequest({ id: cartId }));
87
+ }
88
+ }
89
+ }, [dispatch, cartId, isFocus]);
90
+
91
+ const handleQuantitySelect = (quantity: number) => {
92
+ setSelectedQuantity(quantity);
93
+ setSelectedQty(quantity);
94
+ };
95
+
96
+ const handleItem = async (item: any) => {
97
+ setSelectedItem(item);
98
+ setSelectedQuantity(item.quantity);
99
+ };
100
+
101
+ const handleUpdate = () => {
102
+ dispatch(
103
+ updateCartRequest({
104
+ id: cartId,
105
+ item: {
106
+ product_variation_id: selectedItem?.variation?.id,
107
+ quantity: selectedQty,
108
+ shipping_address: {
109
+ email: selectedItem?.shipping_address?.email,
110
+ phone_numbers: selectedItem?.shipping_address?.phone_numbers[0],
111
+ },
112
+ },
113
+ skip_payable_validation: true,
114
+ }),
115
+ );
116
+ setVisible(false);
117
+ };
118
+
119
+ const handleCancel = () => {
120
+ setVisible(false);
121
+ };
122
+ const askDelete = (item: any) => {
123
+ setItemToDelete(item);
124
+ setConfirmVisible(true);
125
+ };
126
+
127
+ const confirmDelete = () => {
128
+ if (itemToDelete && cartId) {
129
+ dispatch(
130
+ deleteCartRequest({
131
+ id: cartId,
132
+ item: { product_variation_id: itemToDelete?.variation?.id },
133
+ }),
134
+ );
135
+ }
136
+ setConfirmVisible(false);
137
+ setItemToDelete(null);
138
+ };
139
+
140
+ const renderItem = ({ item }: any) => (
141
+ <View style={styles.productRow}>
142
+ <View style={styles.productLeft}>
143
+ <View style={styles.left}>
144
+ <View style={styles.productImageContainer}>
145
+ {item?.product?.image?.image?.url ? (
146
+ <CustomImage
147
+ source={{ uri: item?.product?.image?.image?.url }}
148
+ imgStyle={styles.productImage}
149
+ />
150
+ ) : (
151
+ <View
152
+ style={[styles.productImage, { backgroundColor: colors.productimagebackground }]}
153
+ />
154
+ )}
155
+ </View>
156
+ <View style={styles.productDetails}>
157
+ <Text numberOfLines={2} style={styles.productName}>
158
+ {item?.name}
159
+ </Text>
160
+ <Text style={[styles.productQuantity, { fontSize: 12 }]}>
161
+ {item?.product?.product_type}
162
+ </Text>
163
+ </View>
164
+ </View>
165
+ <TouchableOpacity
166
+ activeOpacity={0.7}
167
+ style={styles.iconRow}
168
+ onPress={() => askDelete(item)}
169
+ >
170
+ <CustomImage source={Images.delete} imgStyle={styles.deleteIcon} />
171
+ </TouchableOpacity>
172
+
173
+ </View>
174
+ <View style={styles.row}>
175
+ <TouchableOpacity
176
+ activeOpacity={0.7}
177
+ style={styles.productQuantityContainer}
178
+ onPress={() => {
179
+ handleItem(item);
180
+ setVisible(true);
181
+ }}
182
+ >
183
+ <Text style={styles.productQuantity}>
184
+ Qty :{' '}
185
+ <Text style={styles.productQuantityText}>{item?.quantity}</Text>
186
+ </Text>
187
+ <CustomImage source={Images.greyDownArrow} imgStyle={styles.icon} />
188
+ </TouchableOpacity>
189
+ <Text style={styles.productPoints}>{item?.amount_cents / 100} {POINTS}</Text>
190
+ </View>
191
+ </View>
192
+ );
193
+
194
+ const isEmpty = !viewMyCartData?.items || viewMyCartData.items?.length === 0;
195
+
196
+ const handleGoBack = () => {
197
+ // In SDK, Redeem and Dashboard are tabs, so navigate directly to them
198
+ const from = route.params?.from;
199
+ if (from === ROUTES.REDEEM) {
200
+ navigation.navigate(ROUTES.REDEEM);
201
+ return true;
202
+ }
203
+ if (navigation.canGoBack()) {
204
+ navigation.goBack();
205
+ return true;
206
+ }
207
+ // Fallback to Dashboard tab
208
+ navigation.navigate(ROUTES.DashboardTab, { screen: ROUTES.DASHBOARD });
209
+ return true;
210
+ };
211
+
212
+ useHardwareBack(handleGoBack)
213
+
214
+ return (
215
+ <View style={styles.container}>
216
+ <MobileHeader
217
+ title={MY_CART}
218
+ showBack
219
+ onBack={() => handleGoBack()}
220
+ disableSafeAreaPadding={true}
221
+ />
222
+
223
+ {viewMyCartLoading ? (
224
+ <CustomLoader loading={viewMyCartLoading} />
225
+ ) : isEmpty ? (
226
+ <View style={styles.container}>
227
+ <View style={styles.emptyCartCenter}>
228
+ <Text style={styles.emptyCartTitle}>{EMPTY_CART_TITLE}</Text>
229
+ <Text style={styles.emptyCartSubtitle}>
230
+ {EMPTY_CART_SUBTITLE}
231
+ </Text>
232
+ </View>
233
+
234
+ <View style={styles.emptyCartButtonContainer}>
235
+ <CustomButton
236
+ title={CONTINUE_SHOPPING}
237
+ onPress={() => navigation.navigate(ROUTES.REDEEM)}
238
+ />
239
+ </View>
240
+ </View>
241
+
242
+
243
+ ) : (
244
+ <ScrollView
245
+ showsVerticalScrollIndicator={false}
246
+ contentContainerStyle={styles.contentContainer}
247
+ >
248
+ <View style={styles.content}>
249
+ {viewMyCartData?.items?.map?.((item: any, index: number) => (
250
+ <React.Fragment key={item?.id ?? String(index)}>
251
+ {renderItem({ item })}
252
+ </React.Fragment>
253
+ ))}
254
+ </View>
255
+ </ScrollView>
256
+ )}
257
+
258
+
259
+ {!!viewMyCartData?.items?.length && (
260
+ <View style={styles.stickyButtonContainer}>
261
+ <View style={styles.bottomContent}>
262
+ <View style={styles.bottomRow}>
263
+ <Text style={styles.leftText}>{REMAINING_AMOUNT}</Text>
264
+ <Text style={styles.rightText}>
265
+ {viewMyCartData?.total_amount_cents / 100} {POINTS}
266
+ </Text>
267
+ </View>
268
+ <View style={styles.separator} />
269
+ <View style={styles.bottomRow}>
270
+ <Text style={styles.amountText}>{AMOUNT_TO_BE_PAID}</Text>
271
+ <Text style={styles.amountPoints}>
272
+ {viewMyCartData?.total_amount_cents / 100} {POINTS}
273
+ </Text>
274
+ </View>
275
+ </View>
276
+ <CustomButton
277
+ title={Checkout}
278
+ onPress={() => {
279
+ const items = viewMyCartData?.items || [];
280
+ const needsAddress = cartNeedsAddress(items);
281
+
282
+ if (needsAddress) {
283
+ navigation.navigate(DELIVERY_ADDRESS);
284
+ } else {
285
+ navigation.navigate(PAYMENT_METHOD , { skipAddress: true });
286
+ }
287
+ }}
288
+ disabled={false}
289
+ />
290
+
291
+ </View>
292
+ )}
293
+
294
+ <QuantityModal
295
+ visible={visible}
296
+ onClose={() => setVisible(false)}
297
+ onSelectQuantity={handleQuantitySelect}
298
+ onCancel={handleCancel}
299
+ onUpdate={handleUpdate}
300
+ selectedQuantity={selectedQuantity ?? 1}
301
+ />
302
+ <ConfirmPopup
303
+ visible={confirmVisible}
304
+ onClose={() => {
305
+ setConfirmVisible(false);
306
+ setItemToDelete(null);
307
+ }}
308
+ onConfirm={confirmDelete}
309
+ title={ITEM_DELETE_TITLE}
310
+ confirmText={ITEM_DELETE_CONFIRM}
311
+ cancelText={ITEM_DELETE_CANCEL}
312
+ />
313
+
314
+ </View>
315
+ );
316
+ };
317
+
318
+ export default MyCart;