@propel-nsl/propel-react-native-sdk 1.1.2 → 1.1.4
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/package.json +1 -1
- package/src/navigation/SDKMainTabNavigator.tsx +11 -7
- package/src/screens/Dashboard/index.tsx +2 -40
- package/src/screens/MyCart/index.tsx +1 -1
- package/src/screens/PaymentMethod/index.tsx +9 -66
- package/src-app/components/OTPModal.tsx +0 -403
- package/src-app/constants/Messages.ts +1 -1
- package/src-app/redux/authSlice.ts +0 -1
- package/src-app/services/index.ts +23 -17
package/package.json
CHANGED
|
@@ -54,12 +54,12 @@ const HIDDEN_SCREENS = [
|
|
|
54
54
|
|
|
55
55
|
const getTabBarHeight = (): number => {
|
|
56
56
|
if (Platform.OS === 'ios') {
|
|
57
|
-
return screenHeight > 800 ? VSCALE(
|
|
57
|
+
return screenHeight > 800 ? VSCALE(50) : VSCALE(55);
|
|
58
58
|
}
|
|
59
59
|
if (Platform.OS === 'android') {
|
|
60
|
-
return screenHeight > 800 ? VSCALE(
|
|
60
|
+
return screenHeight > 800 ? VSCALE(50) : VSCALE(60);
|
|
61
61
|
}
|
|
62
|
-
return VSCALE(
|
|
62
|
+
return VSCALE(55);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// DashboardStack - contains Dashboard and its nested screens
|
|
@@ -289,22 +289,26 @@ const styles = StyleSheet.create({
|
|
|
289
289
|
backgroundColor: '#FFFFFF',
|
|
290
290
|
borderTopWidth: 1,
|
|
291
291
|
borderTopColor: '#E5E7EB',
|
|
292
|
-
paddingTop: VSCALE(
|
|
292
|
+
paddingTop: VSCALE(6),
|
|
293
|
+
paddingHorizontal: SCALE(4),
|
|
293
294
|
},
|
|
294
295
|
tabItem: {
|
|
295
296
|
flex: 1,
|
|
296
297
|
alignItems: 'center',
|
|
297
298
|
justifyContent: 'center',
|
|
298
|
-
minHeight: VSCALE(
|
|
299
|
+
minHeight: VSCALE(50),
|
|
300
|
+
paddingVertical: VSCALE(4),
|
|
299
301
|
},
|
|
300
302
|
tabItemContent: {
|
|
301
303
|
alignItems: 'center',
|
|
302
304
|
justifyContent: 'center',
|
|
305
|
+
gap: VSCALE(2),
|
|
303
306
|
},
|
|
304
307
|
tabLabel: {
|
|
305
|
-
fontSize: SCALE(
|
|
306
|
-
marginTop: VSCALE(
|
|
308
|
+
fontSize: SCALE(9),
|
|
309
|
+
marginTop: VSCALE(2),
|
|
307
310
|
fontWeight: '400',
|
|
311
|
+
textAlign: 'center',
|
|
308
312
|
},
|
|
309
313
|
iconContainer: {
|
|
310
314
|
justifyContent: 'center',
|
|
@@ -59,7 +59,7 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
59
59
|
|
|
60
60
|
// Debug screen state changes
|
|
61
61
|
useEffect(() => {
|
|
62
|
-
|
|
62
|
+
// Screen state changed
|
|
63
63
|
}, [screen]);
|
|
64
64
|
|
|
65
65
|
const {
|
|
@@ -84,11 +84,6 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
84
84
|
(s: RootState) => s.auth.dashboardInfoLoading,
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
console.log(
|
|
88
|
-
"myOrdersValidateOtpSuccessMessage",
|
|
89
|
-
myOrdersValidateOtpSuccessMessage,
|
|
90
|
-
);
|
|
91
|
-
console.log("otpModalVisible", otpModalVisible);
|
|
92
87
|
|
|
93
88
|
useEffect(() => {
|
|
94
89
|
if (otpModalVisible && myOrdersValidateOtpSuccessMessage) {
|
|
@@ -157,7 +152,6 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
157
152
|
|
|
158
153
|
useEffect(() => {
|
|
159
154
|
if (sdkAuthError) {
|
|
160
|
-
console.log("🔴 SDK Auth failed, closing SDK:", sdkAuthError);
|
|
161
155
|
if (NativeModules.PropelSDKBridge?.closeSDKWithError) {
|
|
162
156
|
NativeModules.PropelSDKBridge.closeSDKWithError(sdkAuthError);
|
|
163
157
|
} else if (NativeModules.PropelSDKBridge?.closeSDK) {
|
|
@@ -188,7 +182,6 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
188
182
|
useCallback(() => {
|
|
189
183
|
return () => {
|
|
190
184
|
// This runs when the screen loses focus (unmounts or navigates away)
|
|
191
|
-
console.log('🔍 Dashboard: Screen losing focus, closing modals');
|
|
192
185
|
setOtpModalVisible(false);
|
|
193
186
|
setMessagepopUpVisible(false);
|
|
194
187
|
};
|
|
@@ -200,25 +193,18 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
200
193
|
}, [cartId, dispatch]);
|
|
201
194
|
|
|
202
195
|
const handleBackToHost = () => {
|
|
203
|
-
console.log('🔙 Dashboard: handleBackToHost called');
|
|
204
196
|
// Clear all auth state before exiting SDK to prevent stale data on next launch
|
|
205
197
|
dispatch(clearAllAuthState());
|
|
206
198
|
|
|
207
199
|
// Check if we're in RN host mode (hostNavigation or onClose available)
|
|
208
200
|
if (hostNavigation) {
|
|
209
|
-
console.log('🚀 Dashboard: RN Host Mode - Using hostNavigation.goBack()');
|
|
210
201
|
hostNavigation.goBack();
|
|
211
202
|
} else if (onClose) {
|
|
212
|
-
console.log('🚀 Dashboard: RN Host Mode - Using onClose callback');
|
|
213
203
|
onClose();
|
|
214
204
|
} else if (NativeModules.PropelSDKBridge?.closeSDK) {
|
|
215
|
-
console.log('🚀 Dashboard: Native Mode - Using NativeModules.PropelSDKBridge.closeSDK()');
|
|
216
205
|
NativeModules.PropelSDKBridge.closeSDK();
|
|
217
206
|
} else if (NativeModules.PropelSDKBridge?.dismiss) {
|
|
218
|
-
console.log('🚀 Dashboard: Native Mode - Using NativeModules.PropelSDKBridge.dismiss()');
|
|
219
207
|
NativeModules.PropelSDKBridge.dismiss();
|
|
220
|
-
} else {
|
|
221
|
-
console.log('⚠️ Dashboard: No closeSDK method available');
|
|
222
208
|
}
|
|
223
209
|
};
|
|
224
210
|
|
|
@@ -226,7 +212,6 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
226
212
|
useFocusEffect(
|
|
227
213
|
useCallback(() => {
|
|
228
214
|
const onBackPress = () => {
|
|
229
|
-
console.log('🔙 Dashboard: Hardware back pressed - calling handleBackToHost');
|
|
230
215
|
handleBackToHost();
|
|
231
216
|
return true; // Prevent default back behavior
|
|
232
217
|
};
|
|
@@ -240,29 +225,24 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
240
225
|
const navigateToDashboardScreen = (screenName: string, params?: any) => {
|
|
241
226
|
// Navigate within DashboardStack for screens that are part of the stack
|
|
242
227
|
// For screens like MyCart, we need to navigate within the stack
|
|
243
|
-
console.log("🧭 Dashboard navigateToDashboardScreen:", screenName, params);
|
|
244
228
|
|
|
245
229
|
// Get parent navigator (Tab navigator) to navigate to hidden tabs
|
|
246
230
|
const parentNav = (navigation as any).getParent?.();
|
|
247
231
|
if (parentNav?.navigate) {
|
|
248
|
-
console.log("🧭 Using parent tab navigator for:", screenName);
|
|
249
232
|
parentNav.navigate(screenName, params);
|
|
250
233
|
} else {
|
|
251
234
|
// Fallback to direct navigation within stack
|
|
252
|
-
console.log("🧭 Using direct navigation for:", screenName);
|
|
253
235
|
(navigation as any).navigate(screenName, params);
|
|
254
236
|
}
|
|
255
237
|
};
|
|
256
238
|
|
|
257
239
|
const handleRedemptionHistoryPress = () => {
|
|
258
|
-
console.log("🟢 Dashboard action pressed: RedemptionHistory");
|
|
259
240
|
setScreen(ROUTES.REDEMPTION_HISTORY); // Set screen state for API call condition
|
|
260
241
|
setOtpModalVisible(true);
|
|
261
242
|
dispatch(myOrdersGenerateOtpRequest({}));
|
|
262
243
|
};
|
|
263
244
|
|
|
264
245
|
const handleMyOrdersPress = () => {
|
|
265
|
-
console.log("🟢 Dashboard action pressed: MyOrders");
|
|
266
246
|
setScreen(ROUTES.MY_ORDERS); // Set screen state for API call condition
|
|
267
247
|
setOtpModalVisible(true);
|
|
268
248
|
dispatch(myOrdersGenerateOtpRequest({}));
|
|
@@ -270,7 +250,6 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
270
250
|
};
|
|
271
251
|
|
|
272
252
|
const handleMyVouchersPress = () => {
|
|
273
|
-
console.log("🟢 Dashboard action pressed: MyEVouchers");
|
|
274
253
|
// navigateToDashboardScreen("MyEVouchers", { from: "Dashboard" });
|
|
275
254
|
setScreen(ROUTES.MY_E_VOUCHERS);
|
|
276
255
|
dispatch(resetAuthState("validateEVouchersError" as any));
|
|
@@ -280,43 +259,26 @@ const Dashboard: React.FC<Props> = ({ navigation }) => {
|
|
|
280
259
|
};
|
|
281
260
|
|
|
282
261
|
const handleVerify = async (otp: string) => {
|
|
283
|
-
console.log("🔍 Dashboard handleVerify called with:", { otp, screen });
|
|
284
262
|
try {
|
|
285
263
|
if (screen === ROUTES.MY_ORDERS || screen === ROUTES.REDEMPTION_HISTORY) {
|
|
286
|
-
console.log(
|
|
287
|
-
"🚀 Dashboard dispatching myOrdersValidateOtpRequest with OTP:",
|
|
288
|
-
otp,
|
|
289
|
-
);
|
|
290
264
|
dispatch(
|
|
291
265
|
myOrdersValidateOtpRequest({
|
|
292
266
|
otp: otp,
|
|
293
267
|
}),
|
|
294
268
|
);
|
|
295
269
|
} else if (screen === ROUTES.MY_E_VOUCHERS) {
|
|
296
|
-
console.log(
|
|
297
|
-
"🚀 Dashboard dispatching validateEVouchersRequest with OTP:",
|
|
298
|
-
otp,
|
|
299
|
-
);
|
|
300
270
|
dispatch(
|
|
301
271
|
validateEVouchersRequest({
|
|
302
272
|
otp: otp,
|
|
303
273
|
}),
|
|
304
274
|
);
|
|
305
|
-
} else {
|
|
306
|
-
console.log("⚠️ Dashboard handleVerify: No matching screen condition", {
|
|
307
|
-
screen,
|
|
308
|
-
MY_ORDERS: ROUTES.MY_ORDERS,
|
|
309
|
-
MY_E_VOUCHERS: ROUTES.MY_E_VOUCHERS,
|
|
310
|
-
REDEMPTION_HISTORY: ROUTES.REDEMPTION_HISTORY,
|
|
311
|
-
});
|
|
312
275
|
}
|
|
313
276
|
} catch (error) {
|
|
314
|
-
|
|
277
|
+
// Error handling
|
|
315
278
|
}
|
|
316
279
|
};
|
|
317
280
|
|
|
318
281
|
const navigateToCart = () => {
|
|
319
|
-
console.log("🧭 Dashboard navigateToCart called");
|
|
320
282
|
// Use the same logic as navigateToDashboardScreen for consistency
|
|
321
283
|
navigateToDashboardScreen("MyCart", { from: "Dashboard" });
|
|
322
284
|
};
|
|
@@ -202,7 +202,7 @@ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
|
|
|
202
202
|
</Text>
|
|
203
203
|
<CustomImage source={Images.greyDownArrow} imgStyle={styles.icon} />
|
|
204
204
|
</TouchableOpacity>
|
|
205
|
-
<Text style={styles.productPoints}
|
|
205
|
+
<Text style={styles.productPoints}>₹{item?.amount_cents / 100}</Text>
|
|
206
206
|
</View>
|
|
207
207
|
</View>
|
|
208
208
|
);
|
|
@@ -42,8 +42,6 @@ const PaymentMethod: React.FC<{
|
|
|
42
42
|
const [showPointsApply, setShowPointsApply] = useState(false);
|
|
43
43
|
const [amountModalVisible, setAmountModalVisible] = useState(false);
|
|
44
44
|
const [checkoutPoints, setCheckoutPoints] = useState<number>(0);
|
|
45
|
-
const [showOtpModal, setShowOtpModal] = useState(false);
|
|
46
|
-
const [pendingCheckoutPayload, setPendingCheckoutPayload] = useState<any>(null);
|
|
47
45
|
const dispatch = useAppDispatch();
|
|
48
46
|
const [showLoader, setShowLoader] = useState(false);
|
|
49
47
|
|
|
@@ -53,11 +51,6 @@ const PaymentMethod: React.FC<{
|
|
|
53
51
|
cartId,
|
|
54
52
|
checkoutSuccessMessage,
|
|
55
53
|
checkoutError,
|
|
56
|
-
myOrdersGenerateOtpLoading,
|
|
57
|
-
myOrdersGenerateOtpError,
|
|
58
|
-
myOrdersValidateOtpLoading,
|
|
59
|
-
myOrdersValidateOtpError,
|
|
60
|
-
myOrdersValidateOtpData,
|
|
61
54
|
} = useAppSelector((state: RootState) => state.auth);
|
|
62
55
|
|
|
63
56
|
const route = useRoute<
|
|
@@ -91,22 +84,6 @@ const PaymentMethod: React.FC<{
|
|
|
91
84
|
}
|
|
92
85
|
}, [cartId, dispatch]);
|
|
93
86
|
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
// if (!skipAddress && myOrdersValidateOtpData && pendingCheckoutPayload)
|
|
96
|
-
if (myOrdersValidateOtpData && pendingCheckoutPayload && cartId){
|
|
97
|
-
setShowOtpModal(false);
|
|
98
|
-
setShowLoader(true);
|
|
99
|
-
// Use current cartId from Redux state to ensure we have the latest cart ID
|
|
100
|
-
const checkoutPayload = {
|
|
101
|
-
...pendingCheckoutPayload,
|
|
102
|
-
orderId: cartId,
|
|
103
|
-
order_id: cartId,
|
|
104
|
-
};
|
|
105
|
-
dispatch(checkoutRequest(checkoutPayload));
|
|
106
|
-
setPendingCheckoutPayload(null);
|
|
107
|
-
}
|
|
108
|
-
}, [myOrdersValidateOtpData, pendingCheckoutPayload, cartId, dispatch]);
|
|
109
|
-
|
|
110
87
|
|
|
111
88
|
return (
|
|
112
89
|
<View style={styles.container}>
|
|
@@ -162,7 +139,7 @@ const PaymentMethod: React.FC<{
|
|
|
162
139
|
onPress={() => setShowPointsBreakdown(!showPointsBreakdown)}
|
|
163
140
|
>
|
|
164
141
|
<Text style={styles.pointsText}>
|
|
165
|
-
{viewMyCartData?.amount_cents / 100}
|
|
142
|
+
₹{viewMyCartData?.amount_cents / 100}
|
|
166
143
|
</Text>
|
|
167
144
|
<CustomImage
|
|
168
145
|
source={
|
|
@@ -253,7 +230,7 @@ const PaymentMethod: React.FC<{
|
|
|
253
230
|
<View style={styles.bottomCTA}>
|
|
254
231
|
<View style={styles.priceSection}>
|
|
255
232
|
<Text style={styles.priceText}>
|
|
256
|
-
{viewMyCartData?.total_amount_cents / 100}
|
|
233
|
+
₹{viewMyCartData?.total_amount_cents / 100}
|
|
257
234
|
</Text>
|
|
258
235
|
<TouchableOpacity
|
|
259
236
|
activeOpacity={0.7}
|
|
@@ -308,19 +285,13 @@ const PaymentMethod: React.FC<{
|
|
|
308
285
|
],
|
|
309
286
|
skipAddress,
|
|
310
287
|
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
setPendingCheckoutPayload(payload);
|
|
316
|
-
|
|
317
|
-
dispatch(
|
|
318
|
-
myOrdersGenerateOtpRequest({
|
|
288
|
+
setShowLoader(true);
|
|
289
|
+
const checkoutPayload = {
|
|
290
|
+
...payload,
|
|
291
|
+
orderId: cartId,
|
|
319
292
|
order_id: cartId,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
);
|
|
323
|
-
setShowOtpModal(true);
|
|
293
|
+
};
|
|
294
|
+
dispatch(checkoutRequest(checkoutPayload));
|
|
324
295
|
|
|
325
296
|
}}
|
|
326
297
|
>
|
|
@@ -352,35 +323,7 @@ const PaymentMethod: React.FC<{
|
|
|
352
323
|
}}
|
|
353
324
|
/>
|
|
354
325
|
)}
|
|
355
|
-
<
|
|
356
|
-
visible={showOtpModal}
|
|
357
|
-
onClose={() => {
|
|
358
|
-
setShowOtpModal(false);
|
|
359
|
-
setPendingCheckoutPayload(null);
|
|
360
|
-
}}
|
|
361
|
-
onResend={() => dispatch(
|
|
362
|
-
myOrdersGenerateOtpRequest({
|
|
363
|
-
order_id: cartId,
|
|
364
|
-
otp_type: 'orders_confirm_otp',
|
|
365
|
-
}))}
|
|
366
|
-
onVerify={(otp: string) => {
|
|
367
|
-
if (otp && otp.trim()) {
|
|
368
|
-
dispatch(
|
|
369
|
-
myOrdersValidateOtpRequest({
|
|
370
|
-
order_id: cartId,
|
|
371
|
-
otp,
|
|
372
|
-
otp_type: 'orders_confirm_otp',
|
|
373
|
-
next: pendingCheckoutPayload,
|
|
374
|
-
})
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
}}
|
|
378
|
-
loading={!!myOrdersGenerateOtpLoading || !!myOrdersValidateOtpLoading}
|
|
379
|
-
errorMessage={myOrdersValidateOtpError || myOrdersGenerateOtpError}
|
|
380
|
-
title={OTP_TITLE}
|
|
381
|
-
subtitle={OTP_SUBTITLE}
|
|
382
|
-
/>
|
|
383
|
-
{showLoader && <CustomLoader message={PROCESSING_ORDER} />}
|
|
326
|
+
{showLoader && <CustomLoader text={PROCESSING_ORDER} />}
|
|
384
327
|
|
|
385
328
|
</View>
|
|
386
329
|
);
|
|
@@ -1,402 +1,3 @@
|
|
|
1
|
-
// import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
-
// import {
|
|
3
|
-
// View,
|
|
4
|
-
// Text,
|
|
5
|
-
// StyleSheet,
|
|
6
|
-
// Modal,
|
|
7
|
-
// TouchableOpacity,
|
|
8
|
-
// Animated,
|
|
9
|
-
// TouchableWithoutFeedback,
|
|
10
|
-
// Dimensions,
|
|
11
|
-
// KeyboardAvoidingView,
|
|
12
|
-
// Platform,
|
|
13
|
-
// ScrollView,
|
|
14
|
-
// } from 'react-native';
|
|
15
|
-
// import { OtpInput } from 'react-native-otp-entry';
|
|
16
|
-
// import { useAppSelector } from '../hooks/useAppSelector';
|
|
17
|
-
// import { RootState } from '../redux/store';
|
|
18
|
-
// import CustomButton from './CustomButton';
|
|
19
|
-
// import FontFamily from '../constants/Fonts';
|
|
20
|
-
// import CustomError from './CustomError';
|
|
21
|
-
// import {
|
|
22
|
-
// DIDNT_RECEIVE_OTP,
|
|
23
|
-
// ENTER_4_DIGIT_CODE,
|
|
24
|
-
// OTP,
|
|
25
|
-
// OTP_DIGIT,
|
|
26
|
-
// OTP_LENGTH,
|
|
27
|
-
// OTP_SENT,
|
|
28
|
-
// RESEND_OTP,
|
|
29
|
-
// TEXT,
|
|
30
|
-
// } from '../constants/Messages';
|
|
31
|
-
// import { colors } from '../styles/colors';
|
|
32
|
-
|
|
33
|
-
// const { height: screenHeight } = Dimensions.get('window');
|
|
34
|
-
|
|
35
|
-
// interface OTPModalProps {
|
|
36
|
-
// visible: boolean;
|
|
37
|
-
// onClose: () => void;
|
|
38
|
-
// onVerify: (otp: string) => void;
|
|
39
|
-
// onNavigateToOrders: () => void;
|
|
40
|
-
// phoneNumber?: string;
|
|
41
|
-
// onResend?: () => void;
|
|
42
|
-
// resetOtpTrigger?: number;
|
|
43
|
-
// otpLength?: number;
|
|
44
|
-
// screen?: string;
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
|
-
// function maskPhoneNumber(phone: string): string {
|
|
48
|
-
// if (!phone) return '';
|
|
49
|
-
// const clean = phone.replace(/\D/g, '');
|
|
50
|
-
// if (clean.length <= 4) return clean;
|
|
51
|
-
// if (clean.length <= 6) {
|
|
52
|
-
// return clean;
|
|
53
|
-
// }
|
|
54
|
-
// const first2 = clean.slice(0, 2);
|
|
55
|
-
// const last2 = clean.slice(-2);
|
|
56
|
-
// const maskedLength = clean.length - 4;
|
|
57
|
-
// return `${first2}${'*'.repeat(maskedLength)}${last2}`;
|
|
58
|
-
// }
|
|
59
|
-
|
|
60
|
-
// const OTPModal: React.FC<OTPModalProps> = ({
|
|
61
|
-
// visible,
|
|
62
|
-
// onClose,
|
|
63
|
-
// onVerify,
|
|
64
|
-
// onNavigateToOrders,
|
|
65
|
-
// phoneNumber,
|
|
66
|
-
// onResend,
|
|
67
|
-
// resetOtpTrigger,
|
|
68
|
-
// otpLength = 6,
|
|
69
|
-
// screen,
|
|
70
|
-
// }) => {
|
|
71
|
-
// const [countdown, setCountdown] = useState(60);
|
|
72
|
-
// const slideAnim = useRef(new Animated.Value(screenHeight)).current;
|
|
73
|
-
// const {
|
|
74
|
-
// mobileNumber: reduxMobileNumber,
|
|
75
|
-
// myOrdersValidateOtpError,
|
|
76
|
-
// validateEVouchersError,
|
|
77
|
-
// } = useAppSelector((state: RootState) => state.auth);
|
|
78
|
-
// const displayNumber = phoneNumber || reduxMobileNumber || '';
|
|
79
|
-
// const [newOtp, setNewOtp] = useState('');
|
|
80
|
-
|
|
81
|
-
// useEffect(() => {
|
|
82
|
-
// if (visible) {
|
|
83
|
-
// setCountdown(60);
|
|
84
|
-
// setNewOtp('');
|
|
85
|
-
// Animated.timing(slideAnim, {
|
|
86
|
-
// toValue: 0,
|
|
87
|
-
// duration: 300,
|
|
88
|
-
// useNativeDriver: true,
|
|
89
|
-
// }).start();
|
|
90
|
-
// } else {
|
|
91
|
-
// Animated.timing(slideAnim, {
|
|
92
|
-
// toValue: screenHeight,
|
|
93
|
-
// duration: 300,
|
|
94
|
-
// useNativeDriver: true,
|
|
95
|
-
// }).start();
|
|
96
|
-
// }
|
|
97
|
-
// }, [visible]);
|
|
98
|
-
|
|
99
|
-
// useEffect(() => {
|
|
100
|
-
// let timer: NodeJS.Timeout;
|
|
101
|
-
// if (visible && countdown > 0) {
|
|
102
|
-
// timer = setTimeout(() => setCountdown(countdown - 1), 1000);
|
|
103
|
-
// }
|
|
104
|
-
// return () => clearTimeout(timer);
|
|
105
|
-
// }, [visible, countdown]);
|
|
106
|
-
|
|
107
|
-
// const handleVerify = () => {
|
|
108
|
-
// onVerify(newOtp);
|
|
109
|
-
// };
|
|
110
|
-
|
|
111
|
-
// const handleResendOTP = () => {
|
|
112
|
-
// setCountdown(60);
|
|
113
|
-
// setNewOtp('');
|
|
114
|
-
// onResend?.();
|
|
115
|
-
// };
|
|
116
|
-
|
|
117
|
-
// const formatTime = (seconds: number) => {
|
|
118
|
-
// const mins = Math.floor(seconds / 60);
|
|
119
|
-
// const secs = seconds % 60;
|
|
120
|
-
// return `${mins.toString().padStart(2, '0')} : ${secs
|
|
121
|
-
// .toString()
|
|
122
|
-
// .padStart(2, '0')}`;
|
|
123
|
-
// };
|
|
124
|
-
|
|
125
|
-
// if (!visible) return null;
|
|
126
|
-
|
|
127
|
-
// return (
|
|
128
|
-
// <Modal
|
|
129
|
-
// transparent
|
|
130
|
-
// visible={visible}
|
|
131
|
-
// animationType="none"
|
|
132
|
-
// onRequestClose={onClose}
|
|
133
|
-
// statusBarTranslucent
|
|
134
|
-
// >
|
|
135
|
-
// <TouchableWithoutFeedback onPress={onClose}>
|
|
136
|
-
// <View style={styles.overlay}>
|
|
137
|
-
// <TouchableWithoutFeedback>
|
|
138
|
-
// {/* ⬇️ KeyboardAvoidingView makes the sheet rise with the keyboard */}
|
|
139
|
-
// <KeyboardAvoidingView
|
|
140
|
-
// behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
141
|
-
// keyboardVerticalOffset={Platform.OS === 'ios' ? 12 : 0}
|
|
142
|
-
// style={{ width: '100%' }}
|
|
143
|
-
// >
|
|
144
|
-
// <Animated.View
|
|
145
|
-
// style={[
|
|
146
|
-
// styles.modalContainer,
|
|
147
|
-
// {
|
|
148
|
-
// transform: [{ translateY: slideAnim }],
|
|
149
|
-
// height: myOrdersValidateOtpError ? 370 : 334,
|
|
150
|
-
// },
|
|
151
|
-
// ]}
|
|
152
|
-
// >
|
|
153
|
-
// <ScrollView
|
|
154
|
-
// keyboardShouldPersistTaps="handled"
|
|
155
|
-
// contentContainerStyle={styles.sheetContent}
|
|
156
|
-
// showsVerticalScrollIndicator={false}
|
|
157
|
-
// >
|
|
158
|
-
// <View style={styles.handleBar} />
|
|
159
|
-
|
|
160
|
-
// {(myOrdersValidateOtpError || validateEVouchersError) && (
|
|
161
|
-
// <CustomError
|
|
162
|
-
// message={
|
|
163
|
-
// myOrdersValidateOtpError || validateEVouchersError || ''
|
|
164
|
-
// }
|
|
165
|
-
// />
|
|
166
|
-
// )}
|
|
167
|
-
|
|
168
|
-
// <Text style={styles.title}>{ENTER_4_DIGIT_CODE}</Text>
|
|
169
|
-
|
|
170
|
-
// <Text style={styles.subtitle}>
|
|
171
|
-
// {OTP_SENT} {maskPhoneNumber(displayNumber)}
|
|
172
|
-
// </Text>
|
|
173
|
-
|
|
174
|
-
// <OtpInput
|
|
175
|
-
// numberOfDigits={OTP_LENGTH}
|
|
176
|
-
// focusColor="green"
|
|
177
|
-
// autoFocus={false}
|
|
178
|
-
// hideStick={false}
|
|
179
|
-
// placeholder=""
|
|
180
|
-
// blurOnFilled={true}
|
|
181
|
-
// disabled={false}
|
|
182
|
-
// type="numeric"
|
|
183
|
-
// secureTextEntry={false}
|
|
184
|
-
// focusStickBlinkingDuration={500}
|
|
185
|
-
// onFocus={() => {}}
|
|
186
|
-
// onBlur={() => {}}
|
|
187
|
-
// onTextChange={setNewOtp}
|
|
188
|
-
// onFilled={() => {}}
|
|
189
|
-
// textInputProps={{
|
|
190
|
-
// accessibilityLabel: OTP,
|
|
191
|
-
// }}
|
|
192
|
-
// textProps={{
|
|
193
|
-
// accessibilityRole: TEXT,
|
|
194
|
-
// accessibilityLabel: OTP_DIGIT,
|
|
195
|
-
// allowFontScaling: false,
|
|
196
|
-
// }}
|
|
197
|
-
// theme={{
|
|
198
|
-
// containerStyle: styles.container,
|
|
199
|
-
// pinCodeContainerStyle: styles.pinCodeBox,
|
|
200
|
-
// pinCodeTextStyle: styles.pinCodeText,
|
|
201
|
-
// focusStickStyle: styles.focusStick,
|
|
202
|
-
// focusedPinCodeContainerStyle: styles.activePinBox,
|
|
203
|
-
// placeholderTextStyle: styles.placeholderTextStyle,
|
|
204
|
-
// disabledPinCodeContainerStyle:
|
|
205
|
-
// styles.disabledPinCodeContainer,
|
|
206
|
-
// }}
|
|
207
|
-
// />
|
|
208
|
-
|
|
209
|
-
// <View style={styles.resendContainer}>
|
|
210
|
-
// <View style={styles.resendTextContainer}>
|
|
211
|
-
// <Text style={styles.resendText}>{DIDNT_RECEIVE_OTP}</Text>
|
|
212
|
-
// {countdown > 0 ? (
|
|
213
|
-
// <Text style={styles.resendLinkDisabled}>{RESEND_OTP}</Text>
|
|
214
|
-
// ) : (
|
|
215
|
-
// <TouchableOpacity onPress={handleResendOTP}>
|
|
216
|
-
// <Text style={styles.resendLinkActive}>
|
|
217
|
-
// {RESEND_OTP}
|
|
218
|
-
// </Text>
|
|
219
|
-
// </TouchableOpacity>
|
|
220
|
-
// )}
|
|
221
|
-
// </View>
|
|
222
|
-
// <Text style={styles.countdown}>
|
|
223
|
-
// {formatTime(countdown)}
|
|
224
|
-
// </Text>
|
|
225
|
-
// </View>
|
|
226
|
-
|
|
227
|
-
// <CustomButton
|
|
228
|
-
// title="Verify"
|
|
229
|
-
// onPress={handleVerify}
|
|
230
|
-
// disabled={newOtp.length !== OTP_LENGTH}
|
|
231
|
-
// />
|
|
232
|
-
// </ScrollView>
|
|
233
|
-
// </Animated.View>
|
|
234
|
-
// </KeyboardAvoidingView>
|
|
235
|
-
// </TouchableWithoutFeedback>
|
|
236
|
-
// </View>
|
|
237
|
-
// </TouchableWithoutFeedback>
|
|
238
|
-
// </Modal>
|
|
239
|
-
// );
|
|
240
|
-
// };
|
|
241
|
-
|
|
242
|
-
// const styles = StyleSheet.create({
|
|
243
|
-
// overlay: {
|
|
244
|
-
// flex: 1,
|
|
245
|
-
// backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
246
|
-
// justifyContent: 'flex-end',
|
|
247
|
-
// alignItems: 'center',
|
|
248
|
-
// },
|
|
249
|
-
// modalContainer: {
|
|
250
|
-
// width: 393,
|
|
251
|
-
// maxWidth: '100%',
|
|
252
|
-
// height: 334,
|
|
253
|
-
// backgroundColor: colors.background,
|
|
254
|
-
// borderTopLeftRadius: 30,
|
|
255
|
-
// borderTopRightRadius: 30,
|
|
256
|
-
// paddingHorizontal: 20,
|
|
257
|
-
// paddingTop: 18,
|
|
258
|
-
// paddingBottom: 36,
|
|
259
|
-
// maxHeight: screenHeight * 0.9,
|
|
260
|
-
// alignSelf: 'stretch',
|
|
261
|
-
// },
|
|
262
|
-
// sheetContent: {
|
|
263
|
-
// paddingBottom: 8,
|
|
264
|
-
// },
|
|
265
|
-
// handleBar: {
|
|
266
|
-
// width: 48,
|
|
267
|
-
// height: 4,
|
|
268
|
-
// backgroundColor: colors.outline,
|
|
269
|
-
// borderRadius: 6,
|
|
270
|
-
// alignSelf: 'center',
|
|
271
|
-
// marginBottom: 15,
|
|
272
|
-
// },
|
|
273
|
-
// title: {
|
|
274
|
-
// fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
275
|
-
// fontSize: 16,
|
|
276
|
-
// fontWeight: '500',
|
|
277
|
-
// color: colors.black,
|
|
278
|
-
// textTransform: 'capitalize',
|
|
279
|
-
// marginBottom: 8,
|
|
280
|
-
// },
|
|
281
|
-
// subtitle: {
|
|
282
|
-
// fontFamily: FontFamily.LEXEND_REGULAR,
|
|
283
|
-
// fontSize: 12,
|
|
284
|
-
// fontWeight: '400',
|
|
285
|
-
// color: colors.onSurfaceVariant,
|
|
286
|
-
// lineHeight: 18,
|
|
287
|
-
// marginBottom: 24,
|
|
288
|
-
// },
|
|
289
|
-
|
|
290
|
-
// resendContainer: {
|
|
291
|
-
// flexDirection: 'row',
|
|
292
|
-
// justifyContent: 'space-between',
|
|
293
|
-
// alignItems: 'center',
|
|
294
|
-
// marginBottom: 32,
|
|
295
|
-
// },
|
|
296
|
-
// resendTextContainer: {
|
|
297
|
-
// flexDirection: 'row',
|
|
298
|
-
// alignItems: 'center',
|
|
299
|
-
// },
|
|
300
|
-
// resendText: {
|
|
301
|
-
// fontFamily: FontFamily.LEXEND_REGULAR,
|
|
302
|
-
// fontSize: 12,
|
|
303
|
-
// fontWeight: '400',
|
|
304
|
-
// color: colors.black,
|
|
305
|
-
// lineHeight: 18,
|
|
306
|
-
// },
|
|
307
|
-
// resendLink: {
|
|
308
|
-
// fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
309
|
-
// fontSize: 12,
|
|
310
|
-
// fontWeight: '500',
|
|
311
|
-
// color: colors.red,
|
|
312
|
-
// lineHeight: 18,
|
|
313
|
-
// textDecorationLine: 'underline',
|
|
314
|
-
// marginLeft: 6,
|
|
315
|
-
// },
|
|
316
|
-
// resendLinkActive: {
|
|
317
|
-
// fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
318
|
-
// fontSize: 12,
|
|
319
|
-
// fontWeight: '500',
|
|
320
|
-
// color: colors.red,
|
|
321
|
-
// lineHeight: 18,
|
|
322
|
-
// textDecorationLine: 'underline',
|
|
323
|
-
// marginLeft: 6,
|
|
324
|
-
// },
|
|
325
|
-
// countdown: {
|
|
326
|
-
// fontFamily: FontFamily.LEXEND_REGULAR,
|
|
327
|
-
// fontSize: 12,
|
|
328
|
-
// fontWeight: '400',
|
|
329
|
-
// color: colors.black,
|
|
330
|
-
// lineHeight: 18,
|
|
331
|
-
// },
|
|
332
|
-
|
|
333
|
-
// // OTP Input Styles
|
|
334
|
-
// container: {
|
|
335
|
-
// flexDirection: 'row',
|
|
336
|
-
// justifyContent: 'space-between',
|
|
337
|
-
// paddingHorizontal: 0,
|
|
338
|
-
// marginBottom: 16,
|
|
339
|
-
// },
|
|
340
|
-
// pinCodeBox: {
|
|
341
|
-
// width: 49,
|
|
342
|
-
// height: 62,
|
|
343
|
-
// borderWidth: 1,
|
|
344
|
-
// borderRadius: 12,
|
|
345
|
-
// borderColor: colors.outline,
|
|
346
|
-
// justifyContent: 'center',
|
|
347
|
-
// alignItems: 'center',
|
|
348
|
-
// backgroundColor: colors.background,
|
|
349
|
-
// },
|
|
350
|
-
// pinCodeText: {
|
|
351
|
-
// fontFamily: FontFamily.LEXEND_REGULAR,
|
|
352
|
-
// fontSize: 18,
|
|
353
|
-
// fontWeight: '400',
|
|
354
|
-
// color: colors.black,
|
|
355
|
-
// textAlign: 'center',
|
|
356
|
-
// },
|
|
357
|
-
// focusStick: {
|
|
358
|
-
// width: 2,
|
|
359
|
-
// height: 30,
|
|
360
|
-
// backgroundColor: colors.darkGrey,
|
|
361
|
-
// borderRadius: 1,
|
|
362
|
-
// },
|
|
363
|
-
// activePinBox: {
|
|
364
|
-
// borderColor: colors.darkGrey,
|
|
365
|
-
// borderWidth: 2,
|
|
366
|
-
// backgroundColor: colors.background,
|
|
367
|
-
// },
|
|
368
|
-
|
|
369
|
-
// disabledPinCodeContainer: {
|
|
370
|
-
// borderColor: colors.outlineVariant,
|
|
371
|
-
// borderWidth: 1,
|
|
372
|
-
// backgroundColor: colors.surface,
|
|
373
|
-
// opacity: 0.6,
|
|
374
|
-
// },
|
|
375
|
-
// placeholderTextStyle: {
|
|
376
|
-
// fontFamily: FontFamily.LEXEND_REGULAR,
|
|
377
|
-
// fontSize: 18,
|
|
378
|
-
// fontWeight: '400',
|
|
379
|
-
// color: colors.placeholderColor,
|
|
380
|
-
// textAlign: 'center',
|
|
381
|
-
// },
|
|
382
|
-
// resendLinkDisabled: {
|
|
383
|
-
// fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
384
|
-
// fontSize: 12,
|
|
385
|
-
// fontWeight: '500',
|
|
386
|
-
// color: colors.onSurfaceVariant,
|
|
387
|
-
// lineHeight: 18,
|
|
388
|
-
// textDecorationLine: 'none',
|
|
389
|
-
// marginLeft: 6,
|
|
390
|
-
// },
|
|
391
|
-
|
|
392
|
-
// });
|
|
393
|
-
|
|
394
|
-
// export default OTPModal;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
1
|
import React, { useState, useEffect } from 'react';
|
|
401
2
|
import {
|
|
402
3
|
View,
|
|
@@ -473,8 +74,6 @@ const OTPModal: React.FC<OTPModalProps> = ({
|
|
|
473
74
|
const displayNumber = phoneNumber || reduxMobileNumber || '';
|
|
474
75
|
const [newOtp, setNewOtp] = useState('');
|
|
475
76
|
|
|
476
|
-
console.log("newOtp...",newOtp?.length);
|
|
477
|
-
|
|
478
77
|
|
|
479
78
|
useEffect(() => {
|
|
480
79
|
if (visible) {
|
|
@@ -492,7 +91,6 @@ const OTPModal: React.FC<OTPModalProps> = ({
|
|
|
492
91
|
}, [visible, countdown]);
|
|
493
92
|
|
|
494
93
|
const handleVerify = () => {
|
|
495
|
-
console.log('🔍 OTPModal handleVerify called with OTP:', newOtp);
|
|
496
94
|
onVerify(newOtp);
|
|
497
95
|
};
|
|
498
96
|
|
|
@@ -512,7 +110,6 @@ const OTPModal: React.FC<OTPModalProps> = ({
|
|
|
512
110
|
|
|
513
111
|
|
|
514
112
|
if (!visible) {
|
|
515
|
-
console.log('🔍 OTPModal not visible, returning null');
|
|
516
113
|
return null;
|
|
517
114
|
}
|
|
518
115
|
|
|
@@ -43,7 +43,7 @@ export const DELIVERY_CHARGES = "Delivery Charges";
|
|
|
43
43
|
export const ERROR_TITLE = "Error";
|
|
44
44
|
export const ITEM_ADDED_TO_CART_SUCCESSFULLY = "Item added to cart successfully!";
|
|
45
45
|
export const SUCCESS = 'success';
|
|
46
|
-
export const INSUFFICIENT_BALANCE= "Insufficient
|
|
46
|
+
export const INSUFFICIENT_BALANCE= "Insufficient Balance";
|
|
47
47
|
export const EMPTY_CART_TITLE= "Your cart is empty";
|
|
48
48
|
export const EMPTY_CART_SUBTITLE= "Looks like you haven't added anything to your cart yet.";
|
|
49
49
|
export const ITEM_DELETE_TITLE="Are you sure you want to delete the item ?";
|
|
@@ -350,7 +350,6 @@ const authSlice = createSlice({
|
|
|
350
350
|
state.myOrdersGenerateOtpError = action.payload;
|
|
351
351
|
},
|
|
352
352
|
myOrdersValidateOtpRequest(state, _action: PayloadAction<any>) {
|
|
353
|
-
console.log("🔄 Reducer: myOrdersValidateOtpRequest called");
|
|
354
353
|
state.myOrdersValidateOtpLoading = true;
|
|
355
354
|
state.myOrdersValidateOtpError = null;
|
|
356
355
|
state.myOrdersValidateOtpData = null;
|
|
@@ -269,7 +269,7 @@ export const myOrdersGenerateOtpApi = async (params?: {
|
|
|
269
269
|
config.params = params;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
const response = await
|
|
272
|
+
const response = await api.get(ENDPOINTS.MY_ORDERS_GENERATE_OTP, config);
|
|
273
273
|
return response;
|
|
274
274
|
} catch (error: any) {
|
|
275
275
|
throw error;
|
|
@@ -280,29 +280,35 @@ export const myOrdersValidateOtpApi = async (
|
|
|
280
280
|
arg: { otp: string; order_id?: string; otp_type?: 'orders_confirm_otp' } | string
|
|
281
281
|
) => {
|
|
282
282
|
try {
|
|
283
|
-
console.log("🌐 API: myOrdersValidateOtpApi called with arg:", arg);
|
|
284
283
|
const headers = await getAuthHeader();
|
|
285
284
|
const params = typeof arg === 'string' ? { otp: arg } : arg;
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
|
|
286
|
+
// Step 1: Validate OTP first
|
|
287
|
+
const validateRes = await api.get(ENDPOINTS.MY_ORDERS_VALIDATE_OTP, {
|
|
288
|
+
headers,
|
|
289
|
+
params: { otp: params.otp },
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Step 2: If validation successful, fetch orders
|
|
293
|
+
const listRes = await api.get(ENDPOINTS.MY_ORDERS, {
|
|
294
|
+
headers,
|
|
288
295
|
params: { otp: params.otp },
|
|
289
296
|
});
|
|
297
|
+
|
|
290
298
|
const raw = listRes?.data;
|
|
291
|
-
const orders =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const result = {
|
|
295
|
-
|
|
299
|
+
const orders = raw?.orders ?? raw?.data ?? (Array.isArray(raw) ? raw : raw?.items ?? raw);
|
|
300
|
+
const pagination = raw?.pagination;
|
|
301
|
+
|
|
302
|
+
const result = {
|
|
303
|
+
...listRes,
|
|
304
|
+
data: {
|
|
305
|
+
orders,
|
|
306
|
+
pagination
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
296
310
|
return result;
|
|
297
311
|
} catch (error: any) {
|
|
298
|
-
console.log("🌐 API: myOrdersValidateOtpApi ERROR DETAILS:");
|
|
299
|
-
console.log(" - Error message:", error?.message);
|
|
300
|
-
console.log(" - Status code:", error?.response?.status);
|
|
301
|
-
console.log(" - Status text:", error?.response?.statusText);
|
|
302
|
-
console.log(" - Response data:", JSON.stringify(error?.response?.data, null, 2));
|
|
303
|
-
console.log(" - Response headers:", JSON.stringify(error?.response?.headers, null, 2));
|
|
304
|
-
console.log(" - Full error object:", error);
|
|
305
|
-
|
|
306
312
|
const errMsg = error?.response?.data?.message || error.message || 'Unknown error';
|
|
307
313
|
|
|
308
314
|
throw error;
|