@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,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActivityIndicator,
|
|
3
|
+
View,
|
|
4
|
+
FlatList,
|
|
5
|
+
Text,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
KeyboardAvoidingView,
|
|
8
|
+
Platform,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import styles from './styles';
|
|
12
|
+
import MobileHeader from '../../../src-app/components/MobileHeader';
|
|
13
|
+
import { AppStackParamList } from '../../../src-app/types/navigation';
|
|
14
|
+
import { RouteProp, useIsFocused, useRoute } from '@react-navigation/native';
|
|
15
|
+
import { useAppDispatch } from '../../../src-app/hooks/useAppDispatch';
|
|
16
|
+
import { RootState } from '../../../src-app/redux/store';
|
|
17
|
+
import { useAppSelector } from '../../../src-app/hooks/useAppSelector';
|
|
18
|
+
import { useEffect } from 'react';
|
|
19
|
+
import {
|
|
20
|
+
createAddressRequest,
|
|
21
|
+
dashboardInfoRequest,
|
|
22
|
+
deleteAddressRequest,
|
|
23
|
+
deliverHereRequest,
|
|
24
|
+
getAddressListRequest,
|
|
25
|
+
resetAuthState,
|
|
26
|
+
updateAddressRequest,
|
|
27
|
+
} from '../../../src-app/redux/authSlice';
|
|
28
|
+
import {
|
|
29
|
+
CustomButton,
|
|
30
|
+
CustomImage,
|
|
31
|
+
CustomLoader,
|
|
32
|
+
NoDataFound,
|
|
33
|
+
} from '../../../src-app/components';
|
|
34
|
+
import Images from '../../../src-app/constants/Images';
|
|
35
|
+
import { VSCALE } from '../../../src-app/constants/Scaling';
|
|
36
|
+
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
37
|
+
|
|
38
|
+
interface DeliveryAddressProps {
|
|
39
|
+
navigation?: any;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type DeliveryAddressRouteProp = RouteProp<AppStackParamList, 'DeliveryAddress'>;
|
|
43
|
+
|
|
44
|
+
const DeliveryAddress: React.FC<DeliveryAddressProps> = ({ navigation }) => {
|
|
45
|
+
const route = useRoute<DeliveryAddressRouteProp>();
|
|
46
|
+
// const from = route.params?.from;
|
|
47
|
+
const dispatch = useAppDispatch();
|
|
48
|
+
const focus = useIsFocused();
|
|
49
|
+
const { getAddressListData, getAddressListLoading } = useAppSelector(
|
|
50
|
+
(state: RootState) => state.auth,
|
|
51
|
+
);
|
|
52
|
+
const cartId = useAppSelector((state: RootState) => state.auth.cartId);
|
|
53
|
+
const { deliverHereStatus } = useAppSelector(
|
|
54
|
+
(state: RootState) => state.auth,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
dispatch(getAddressListRequest());
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
dispatch(dashboardInfoRequest({}));
|
|
63
|
+
}, [dispatch]);
|
|
64
|
+
|
|
65
|
+
const handleEdit = (item: any) => {
|
|
66
|
+
navigation.navigate('NewDeliveryAddress', { item });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const extractLineAndLandmark = (address: string) => {
|
|
70
|
+
const raw = (address || '').replace(/\\n/g, '\n');
|
|
71
|
+
|
|
72
|
+
const lineMatch = raw.match(/Line:\s*(.*?)(\n|$)/);
|
|
73
|
+
const landmarkMatch = raw.match(/Landmark:\s*(.*)/);
|
|
74
|
+
|
|
75
|
+
const Line = lineMatch ? lineMatch[1].trim() : '';
|
|
76
|
+
const Landmark = landmarkMatch ? landmarkMatch[1].trim() : '';
|
|
77
|
+
|
|
78
|
+
return { Line, Landmark };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const renderItem = (item: any) => {
|
|
82
|
+
const { Line, Landmark } = extractLineAndLandmark(item.line);
|
|
83
|
+
return (
|
|
84
|
+
<View style={styles.cardItem}>
|
|
85
|
+
<View style={styles.mainContent}>
|
|
86
|
+
<View style={styles.topRow}>
|
|
87
|
+
<Text style={styles.name}>{item.name}</Text>
|
|
88
|
+
<View style={styles.row}>
|
|
89
|
+
<TouchableOpacity
|
|
90
|
+
style={styles.editContainer}
|
|
91
|
+
activeOpacity={0.7}
|
|
92
|
+
onPress={() => {
|
|
93
|
+
handleEdit(item);
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<CustomImage
|
|
97
|
+
source={Images.editIcon}
|
|
98
|
+
imgStyle={styles.editIcon}
|
|
99
|
+
/>
|
|
100
|
+
</TouchableOpacity>
|
|
101
|
+
<TouchableOpacity
|
|
102
|
+
style={styles.deleteContainer}
|
|
103
|
+
activeOpacity={0.7}
|
|
104
|
+
onPress={() => {
|
|
105
|
+
dispatch(deleteAddressRequest({ id: item?.id }));
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<CustomImage
|
|
109
|
+
source={Images.delete}
|
|
110
|
+
imgStyle={styles.deleteIcon}
|
|
111
|
+
/>
|
|
112
|
+
</TouchableOpacity>
|
|
113
|
+
</View>
|
|
114
|
+
</View>
|
|
115
|
+
|
|
116
|
+
<Text style={styles.phone}>+91 {item.phone_numbers.join('\n')}</Text>
|
|
117
|
+
<Text style={styles.address}>
|
|
118
|
+
Address : <Text style={styles.addressText}>{Line}</Text>
|
|
119
|
+
</Text>
|
|
120
|
+
<Text style={styles.address}>
|
|
121
|
+
Landmark : <Text style={styles.addressText}>{Landmark}</Text>
|
|
122
|
+
</Text>
|
|
123
|
+
</View>
|
|
124
|
+
|
|
125
|
+
<CustomButton
|
|
126
|
+
customButtonContainerStyle={styles.buttonContainer}
|
|
127
|
+
buttonStyle={styles.button}
|
|
128
|
+
title="Deliver Here"
|
|
129
|
+
onPress={() => {
|
|
130
|
+
dispatch(deliverHereRequest({
|
|
131
|
+
order_id: cartId,
|
|
132
|
+
skip_payable_validation: true,
|
|
133
|
+
order: {
|
|
134
|
+
shipping: {
|
|
135
|
+
shipping_method: "billing_address"
|
|
136
|
+
},
|
|
137
|
+
shipping_address: {
|
|
138
|
+
zip_code: item?.zip_code,
|
|
139
|
+
city: item?.city,
|
|
140
|
+
name: item?.name,
|
|
141
|
+
latitude: null,
|
|
142
|
+
longitude: null,
|
|
143
|
+
state: item?.state,
|
|
144
|
+
line: item?.line,
|
|
145
|
+
country: {
|
|
146
|
+
id: "",
|
|
147
|
+
name: "India"
|
|
148
|
+
},
|
|
149
|
+
phone_numbers: item?.phone_numbers,
|
|
150
|
+
id: item?.id,
|
|
151
|
+
email: item?.email ? item?.email : ""
|
|
152
|
+
},
|
|
153
|
+
billing_address: {
|
|
154
|
+
zip_code: item?.zip_code,
|
|
155
|
+
city: item?.city,
|
|
156
|
+
name: item?.name,
|
|
157
|
+
latitude: null,
|
|
158
|
+
longitude: null,
|
|
159
|
+
state: item?.state,
|
|
160
|
+
line: item?.line,
|
|
161
|
+
country: {
|
|
162
|
+
id: "",
|
|
163
|
+
name: "India"
|
|
164
|
+
},
|
|
165
|
+
phone_numbers: item?.phone_numbers,
|
|
166
|
+
id: item?.id,
|
|
167
|
+
email: item?.email ? item?.email : ""
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
navigation.navigate('PaymentMethod', { item: item });
|
|
172
|
+
dispatch(resetAuthState("deliverHereStatus"));
|
|
173
|
+
}}
|
|
174
|
+
textStyle={styles.buttonText}
|
|
175
|
+
/>
|
|
176
|
+
</View>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
return (
|
|
180
|
+
<View style={styles.container}>
|
|
181
|
+
<MobileHeader
|
|
182
|
+
title="Select Delivery Address"
|
|
183
|
+
showBack
|
|
184
|
+
onBack={() => {
|
|
185
|
+
if (navigation.canGoBack()) {
|
|
186
|
+
navigation.goBack();
|
|
187
|
+
} else {
|
|
188
|
+
navigation.navigate('MyCart' as never);
|
|
189
|
+
}
|
|
190
|
+
}}
|
|
191
|
+
disableSafeAreaPadding={true}
|
|
192
|
+
/>
|
|
193
|
+
<View style={styles.content}>
|
|
194
|
+
{getAddressListLoading ? (
|
|
195
|
+
<CustomLoader loading={getAddressListLoading} />
|
|
196
|
+
) : getAddressListData?.length > 0 ? (
|
|
197
|
+
<FlatList
|
|
198
|
+
data={getAddressListData}
|
|
199
|
+
renderItem={({ item }) => renderItem(item)}
|
|
200
|
+
keyExtractor={item => item.id}
|
|
201
|
+
contentContainerStyle={{ paddingBottom: VSCALE(100) }}
|
|
202
|
+
showsVerticalScrollIndicator={false}
|
|
203
|
+
/>
|
|
204
|
+
) : (
|
|
205
|
+
<NoDataFound />
|
|
206
|
+
)}
|
|
207
|
+
</View>
|
|
208
|
+
<CustomButton
|
|
209
|
+
title="Add New Address"
|
|
210
|
+
onPress={() => {
|
|
211
|
+
navigation.navigate('NewDeliveryAddress');
|
|
212
|
+
}}
|
|
213
|
+
icon={true}
|
|
214
|
+
iconSrc={Images.addWhiteIcon}
|
|
215
|
+
customButtonContainerStyle={styles.buttonView}
|
|
216
|
+
/>
|
|
217
|
+
</View>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export default DeliveryAddress;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import FontFamily from '../../../src-app/constants/Fonts';
|
|
3
|
+
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
backgroundColor: 'white',
|
|
8
|
+
},
|
|
9
|
+
cardItem: {
|
|
10
|
+
shadowColor: '#000',
|
|
11
|
+
shadowOffset: {
|
|
12
|
+
width: 0,
|
|
13
|
+
height: 2,
|
|
14
|
+
},
|
|
15
|
+
shadowOpacity: 0.25,
|
|
16
|
+
shadowRadius: 3.84,
|
|
17
|
+
elevation: 5,
|
|
18
|
+
backgroundColor: '#fff',
|
|
19
|
+
borderRadius: 16,
|
|
20
|
+
marginBottom: 20,
|
|
21
|
+
borderWidth: 0.25,
|
|
22
|
+
borderColor: '#ccc',
|
|
23
|
+
},
|
|
24
|
+
content: {
|
|
25
|
+
flex: 1,
|
|
26
|
+
padding: 20,
|
|
27
|
+
},
|
|
28
|
+
button: {
|
|
29
|
+
borderWidth: 1,
|
|
30
|
+
borderColor: '#DC291E',
|
|
31
|
+
borderRadius: 12,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
backgroundColor: 'white',
|
|
34
|
+
},
|
|
35
|
+
buttonText: {
|
|
36
|
+
color: '#DC291E',
|
|
37
|
+
fontSize: 12,
|
|
38
|
+
fontWeight: '600',
|
|
39
|
+
fontFamily: FontFamily.LEXEND_SEMIBOLD,
|
|
40
|
+
},
|
|
41
|
+
mainContent: {
|
|
42
|
+
padding: 20,
|
|
43
|
+
},
|
|
44
|
+
buttonContainer: {
|
|
45
|
+
marginBottom: 20,
|
|
46
|
+
paddingHorizontal:20
|
|
47
|
+
},
|
|
48
|
+
name: {
|
|
49
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
50
|
+
fontSize: 14,
|
|
51
|
+
fontWeight: '500',
|
|
52
|
+
color: 'black',
|
|
53
|
+
marginBottom: 2,
|
|
54
|
+
},
|
|
55
|
+
phone: {
|
|
56
|
+
color: '#6B7280',
|
|
57
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
58
|
+
fontSize: 10,
|
|
59
|
+
fontWeight: '500',
|
|
60
|
+
marginBottom: 2,
|
|
61
|
+
},
|
|
62
|
+
address: {
|
|
63
|
+
color: '#1F2937',
|
|
64
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
65
|
+
fontSize: 10,
|
|
66
|
+
fontWeight: '400',
|
|
67
|
+
marginVertical: 2,
|
|
68
|
+
},
|
|
69
|
+
addressText: {
|
|
70
|
+
color: '#6B7280',
|
|
71
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
72
|
+
fontSize: 10,
|
|
73
|
+
fontWeight: '500',
|
|
74
|
+
marginVertical: 2,
|
|
75
|
+
},
|
|
76
|
+
editIcon: {
|
|
77
|
+
width: 12,
|
|
78
|
+
height: 12,
|
|
79
|
+
resizeMode: 'contain',
|
|
80
|
+
},
|
|
81
|
+
deleteIcon: {
|
|
82
|
+
width: 22,
|
|
83
|
+
height: 22,
|
|
84
|
+
resizeMode: 'contain',
|
|
85
|
+
},
|
|
86
|
+
editContainer: {
|
|
87
|
+
width: 28,
|
|
88
|
+
height: 28,
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
justifyContent: 'center',
|
|
91
|
+
borderWidth: 1,
|
|
92
|
+
borderColor: '#F3F4F7',
|
|
93
|
+
borderRadius: 5,
|
|
94
|
+
backgroundColor: '#F3F4F7',
|
|
95
|
+
},
|
|
96
|
+
deleteContainer: {
|
|
97
|
+
width: 28,
|
|
98
|
+
height: 28,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
borderWidth: 1,
|
|
102
|
+
borderColor: '#FEF2F2',
|
|
103
|
+
borderRadius: 5,
|
|
104
|
+
backgroundColor: '#FEF2F2',
|
|
105
|
+
},
|
|
106
|
+
row: {
|
|
107
|
+
flexDirection: 'row',
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
justifyContent: 'space-between',
|
|
110
|
+
width: 70,
|
|
111
|
+
},
|
|
112
|
+
topRow: {
|
|
113
|
+
flexDirection: 'row',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
justifyContent: 'space-between',
|
|
116
|
+
},
|
|
117
|
+
buttonView:{
|
|
118
|
+
paddingHorizontal:20
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export default styles;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { View, Text, ScrollView, TouchableOpacity } from 'react-native';
|
|
2
|
+
import React, { useState, useMemo } from 'react';
|
|
3
|
+
import styles from './styles';
|
|
4
|
+
import MobileHeader from '../../../src-app/components/MobileHeader';
|
|
5
|
+
import { StackNavigationProp } from '@react-navigation/stack';
|
|
6
|
+
import { AppStackParamList } from '../../../src-app/types/navigation';
|
|
7
|
+
import { useAppSelector } from '../../../src-app/hooks/useAppSelector';
|
|
8
|
+
import { RootState } from '../../../src-app/redux/store';
|
|
9
|
+
import { CustomImage, NoDataFound } from '../../../src-app/components';
|
|
10
|
+
import Images from '../../../src-app/constants/Images';
|
|
11
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
|
12
|
+
import Toast from 'react-native-toast-message';
|
|
13
|
+
import { FILTER, MAP } from '../../../src-app/utils/filterPins';
|
|
14
|
+
|
|
15
|
+
type MyEVouchersNavigationProp = StackNavigationProp<
|
|
16
|
+
AppStackParamList,
|
|
17
|
+
'MyEVouchers'
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
navigation: MyEVouchersNavigationProp;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const formatDate = (isoDate: string): string => {
|
|
25
|
+
const date = new Date(isoDate);
|
|
26
|
+
const day = date.toLocaleString('en-GB', { day: '2-digit' });
|
|
27
|
+
const month = date.toLocaleString('en-GB', { month: 'short' });
|
|
28
|
+
const year = date.getFullYear();
|
|
29
|
+
return `Expires on ${day} ${month}, ${year}`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const renderItem = (
|
|
33
|
+
item: any,
|
|
34
|
+
index: number,
|
|
35
|
+
visiblePins: { [key: number]: boolean },
|
|
36
|
+
setVisiblePins: React.Dispatch<
|
|
37
|
+
React.SetStateAction<{ [key: number]: boolean }>
|
|
38
|
+
>,
|
|
39
|
+
) => {
|
|
40
|
+
const isVisible = visiblePins[index];
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View key={index} style={styles.cardItem}>
|
|
44
|
+
<Text style={styles.name}>{item?.product?.name}</Text>
|
|
45
|
+
<View style={styles.row}>
|
|
46
|
+
<Text style={styles.denomination}>Denomination {item?.value}</Text>
|
|
47
|
+
<Text style={styles.denomination}>
|
|
48
|
+
Order ID : {item?.order?.order_no}
|
|
49
|
+
</Text>
|
|
50
|
+
</View>
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
style={styles.touchable}
|
|
53
|
+
activeOpacity={0.7}
|
|
54
|
+
onPress={() => {
|
|
55
|
+
if (item?.code) {
|
|
56
|
+
Clipboard.setString(item?.code);
|
|
57
|
+
Toast.show({
|
|
58
|
+
type: 'success',
|
|
59
|
+
text1: 'Copied to clipboard!',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<Text style={styles.code}>{item?.code}</Text>
|
|
65
|
+
<CustomImage source={Images.copy} imgStyle={styles.copyIcon} />
|
|
66
|
+
</TouchableOpacity>
|
|
67
|
+
<View style={styles.row}>
|
|
68
|
+
<View style={styles.bottomrow}>
|
|
69
|
+
<CustomImage source={Images.stopwatch} imgStyle={styles.icon} />
|
|
70
|
+
<Text style={styles.expiry}>{formatDate(item?.expiry)}</Text>
|
|
71
|
+
</View>
|
|
72
|
+
<View style={styles.bottomrow}>
|
|
73
|
+
<Text style={styles.expiry}>
|
|
74
|
+
PIN : {isVisible ? item?.pin : '*'.repeat(item?.pin?.length || 0)}
|
|
75
|
+
</Text>
|
|
76
|
+
<TouchableOpacity
|
|
77
|
+
onPress={() => {
|
|
78
|
+
setVisiblePins(prev => ({ ...prev, [index]: !prev[index] }));
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<CustomImage source={Images.eye} imgStyle={styles.eyeicon} />
|
|
82
|
+
</TouchableOpacity>
|
|
83
|
+
</View>
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const MyEVouchers: React.FC<Props> = ({ navigation }) => {
|
|
90
|
+
const { validateEVouchersData, validateEVouchersError } = useAppSelector(
|
|
91
|
+
(state: RootState) => state.auth,
|
|
92
|
+
);
|
|
93
|
+
const [visiblePins, setVisiblePins] = useState<{ [key: number]: boolean }>(
|
|
94
|
+
{},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// Use actual data from backend only
|
|
98
|
+
const displayData = useMemo(() => {
|
|
99
|
+
if (Array.isArray(validateEVouchersData) && validateEVouchersData.length > 0) {
|
|
100
|
+
return validateEVouchersData;
|
|
101
|
+
}
|
|
102
|
+
// Return empty array if no data from backend
|
|
103
|
+
console.log('🎟️ MyEVouchers: No data from backend, showing empty state');
|
|
104
|
+
return [];
|
|
105
|
+
}, [validateEVouchersData]);
|
|
106
|
+
|
|
107
|
+
// Debug logging
|
|
108
|
+
console.log('🎟️ MyEVouchers RENDER:', {
|
|
109
|
+
displayDataLength: displayData.length,
|
|
110
|
+
validateEVouchersError: !!validateEVouchersError,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<View style={styles.container}>
|
|
115
|
+
<MobileHeader
|
|
116
|
+
title="My E-Vouchers"
|
|
117
|
+
showBack
|
|
118
|
+
onBack={() => {
|
|
119
|
+
if (navigation.canGoBack()) {
|
|
120
|
+
navigation.goBack();
|
|
121
|
+
} else {
|
|
122
|
+
navigation.navigate('DashboardTab' as never, { screen: 'Dashboard' });
|
|
123
|
+
}
|
|
124
|
+
}}
|
|
125
|
+
icon={Images.help}
|
|
126
|
+
iconPress={() => {
|
|
127
|
+
navigation.navigate('Help', {
|
|
128
|
+
from: "MyEVouchers"
|
|
129
|
+
})
|
|
130
|
+
}}
|
|
131
|
+
disableSafeAreaPadding={true}
|
|
132
|
+
/>
|
|
133
|
+
<ScrollView
|
|
134
|
+
style={{ flex: 1 }}
|
|
135
|
+
contentContainerStyle={styles.content}
|
|
136
|
+
showsVerticalScrollIndicator={false}
|
|
137
|
+
>
|
|
138
|
+
<View>
|
|
139
|
+
{(() => {
|
|
140
|
+
console.log('🎟️ MyEVouchers: Rendering', displayData.length, 'items');
|
|
141
|
+
const filtered = displayData.filter((item: any) => item?.pin);
|
|
142
|
+
console.log('🎟️ MyEVouchers: After filter', filtered.length, 'items');
|
|
143
|
+
if (filtered.length > 0) {
|
|
144
|
+
return filtered.map((item: any, index: number) => {
|
|
145
|
+
console.log('🎟️ MyEVouchers item:', index, item?.product?.name, item?.pin);
|
|
146
|
+
return renderItem(item, index, visiblePins, setVisiblePins);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return <NoDataFound containerstyle={styles.nodataFound}/>;
|
|
150
|
+
})()}
|
|
151
|
+
</View>
|
|
152
|
+
</ScrollView>
|
|
153
|
+
</View>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export default MyEVouchers;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import FontFamily from '../../../src-app/constants/Fonts';
|
|
3
|
+
import { colors } from '../../../src-app/styles/colors';
|
|
4
|
+
|
|
5
|
+
const styles = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: 'white',
|
|
9
|
+
},
|
|
10
|
+
content: {
|
|
11
|
+
padding: 20,
|
|
12
|
+
width: '100%',
|
|
13
|
+
},
|
|
14
|
+
text: {
|
|
15
|
+
fontSize: 16,
|
|
16
|
+
color: '#1F2937',
|
|
17
|
+
fontWeight: '500',
|
|
18
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
19
|
+
},
|
|
20
|
+
cardItem: {
|
|
21
|
+
paddingVertical: 20,
|
|
22
|
+
paddingHorizontal: 20,
|
|
23
|
+
shadowColor: '#000',
|
|
24
|
+
shadowOffset: {
|
|
25
|
+
width: 0,
|
|
26
|
+
height: 2,
|
|
27
|
+
},
|
|
28
|
+
shadowOpacity: 0.25,
|
|
29
|
+
shadowRadius: 3.84,
|
|
30
|
+
elevation: 5,
|
|
31
|
+
backgroundColor: '#fff',
|
|
32
|
+
borderRadius: 16,
|
|
33
|
+
marginBottom: 20,
|
|
34
|
+
borderWidth: 0.25,
|
|
35
|
+
borderColor: '#ccc',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
width: '100%',
|
|
38
|
+
},
|
|
39
|
+
name: {
|
|
40
|
+
fontSize: 14,
|
|
41
|
+
color: '#1F2937',
|
|
42
|
+
fontWeight: '500',
|
|
43
|
+
fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
44
|
+
},
|
|
45
|
+
denomination: {
|
|
46
|
+
fontSize: 12,
|
|
47
|
+
fontWeight: '500',
|
|
48
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
49
|
+
color: colors.onSurfaceVariant,
|
|
50
|
+
},
|
|
51
|
+
row: {
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
gap: 10,
|
|
54
|
+
justifyContent: 'space-between',
|
|
55
|
+
marginTop: 10,
|
|
56
|
+
},
|
|
57
|
+
bottomrow: {
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
gap: 5,
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
marginTop: 10,
|
|
62
|
+
},
|
|
63
|
+
touchable: {
|
|
64
|
+
width: '100%',
|
|
65
|
+
borderWidth: 1,
|
|
66
|
+
borderColor: colors.outline,
|
|
67
|
+
padding: 20,
|
|
68
|
+
borderRadius: 8,
|
|
69
|
+
marginTop: 10,
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'space-between',
|
|
73
|
+
},
|
|
74
|
+
code: {
|
|
75
|
+
fontSize: 16,
|
|
76
|
+
fontWeight: '500',
|
|
77
|
+
fontFamily: FontFamily.LEXEND_MEDIUM,
|
|
78
|
+
color: colors.red,
|
|
79
|
+
},
|
|
80
|
+
expiry: {
|
|
81
|
+
fontSize: 10,
|
|
82
|
+
fontWeight: '400',
|
|
83
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
84
|
+
color: colors.black,
|
|
85
|
+
},
|
|
86
|
+
copyIcon: {
|
|
87
|
+
height: 20,
|
|
88
|
+
width: 17,
|
|
89
|
+
resizeMode: 'contain',
|
|
90
|
+
},
|
|
91
|
+
icon: {
|
|
92
|
+
height: 12,
|
|
93
|
+
width: 7,
|
|
94
|
+
resizeMode: 'contain',
|
|
95
|
+
},
|
|
96
|
+
eyeicon:{
|
|
97
|
+
height: 16,
|
|
98
|
+
width: 16,
|
|
99
|
+
resizeMode: 'contain',
|
|
100
|
+
},
|
|
101
|
+
nodataFound:{
|
|
102
|
+
minHeight:450
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export default styles;
|