@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,47 @@
|
|
|
1
|
+
import {StyleSheet } from 'react-native';
|
|
2
|
+
import FontFamily from '../../../src-app/constants/Fonts';
|
|
3
|
+
import { VSCALE, SCALE, MSCALE } from '../../../src-app/constants/Scaling';
|
|
4
|
+
import { Dimensions } from 'react-native';
|
|
5
|
+
|
|
6
|
+
const { height: screenHeight } = Dimensions.get('window');
|
|
7
|
+
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
main: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
backgroundColor: 'white',
|
|
12
|
+
},
|
|
13
|
+
content: {
|
|
14
|
+
padding: SCALE(20),
|
|
15
|
+
flex: 1,
|
|
16
|
+
},
|
|
17
|
+
text: {
|
|
18
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
19
|
+
fontSize: MSCALE(12),
|
|
20
|
+
fontWeight: '400',
|
|
21
|
+
color: '#6B7280',
|
|
22
|
+
width: '90%',
|
|
23
|
+
},
|
|
24
|
+
i_icon: {
|
|
25
|
+
height: VSCALE(16.5),
|
|
26
|
+
width: SCALE(16.5),
|
|
27
|
+
bottom: VSCALE(5),
|
|
28
|
+
},
|
|
29
|
+
row: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
gap: SCALE(10),
|
|
33
|
+
},
|
|
34
|
+
customButtonContainerStyle: {
|
|
35
|
+
paddingHorizontal: SCALE(20),
|
|
36
|
+
marginTop: VSCALE(80),
|
|
37
|
+
},
|
|
38
|
+
footer: {
|
|
39
|
+
},
|
|
40
|
+
contentContainer: {
|
|
41
|
+
paddingBottom: screenHeight > 700 ? VSCALE(40) : VSCALE(50),
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export default styles;
|
|
47
|
+
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { View, Text, TextInput } from 'react-native';
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
3
|
+
import styles, { EXTRA_SCROLL_HEIGHT } 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 { RouteProp, useIsFocused, useRoute } from '@react-navigation/native';
|
|
8
|
+
import { CustomButton } from '../../../src-app/components';
|
|
9
|
+
import {
|
|
10
|
+
createAddressRequest,
|
|
11
|
+
updateAddressRequest,
|
|
12
|
+
} from '../../../src-app/redux/authSlice';
|
|
13
|
+
import { useAppDispatch } from '../../../src-app/hooks/useAppDispatch';
|
|
14
|
+
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
15
|
+
import { ADD_NEW_DELIVERY_ADDRESS, ADDRESS, CITY, EDIT_DELIVERY_ADDRESS, EMAIL_ID, FULL_NAME, LANDMARK, MOBILE_NUMBER, PINCODE, SAVE_AND_PROCEED, STATE, UPDATE_AND_PROCEED, FULL_NAME_LABEL, MOBILE_NUMBER_LABEL, EMAIL_ID_LABEL, ADDRESS_LABEL, LANDMARK_LABEL, CITY_LABEL, STATE_LABEL, PINCODE_LABEL, COUNTRY_INDIA, ADDRESS_LINE_PREFIX, ADDRESS_LANDMARK_PREFIX, BILLING_ADDRESS } from '../../../src-app/constants/Messages';
|
|
16
|
+
import { extractLineAndLandmark, formSchema } from '../../../src-app/utils/Validation';
|
|
17
|
+
import { Formik } from 'formik';
|
|
18
|
+
import { useAppSelector } from '../../../src-app/hooks/useAppSelector';
|
|
19
|
+
import { RootState } from '../../../src-app/redux/store';
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
navigation: StackNavigationProp<AppStackParamList, 'NewDeliveryAddress'>;
|
|
23
|
+
route: RouteProp<AppStackParamList, 'NewDeliveryAddress'>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface CustomFieldProps {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
onChangeText: (text: string) => void;
|
|
30
|
+
error?: string;
|
|
31
|
+
onBlur?: () => void;
|
|
32
|
+
onFocus?: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const CustomField: React.FC<CustomFieldProps> = ({
|
|
36
|
+
label,
|
|
37
|
+
value,
|
|
38
|
+
onChangeText,
|
|
39
|
+
error,
|
|
40
|
+
onBlur,
|
|
41
|
+
onFocus,
|
|
42
|
+
}) => {
|
|
43
|
+
return (
|
|
44
|
+
<View>
|
|
45
|
+
<View style={styles.inputContainer}>
|
|
46
|
+
<Text style={styles.label}>{label}</Text>
|
|
47
|
+
<TextInput
|
|
48
|
+
editable
|
|
49
|
+
multiline
|
|
50
|
+
numberOfLines={4}
|
|
51
|
+
onChangeText={onChangeText}
|
|
52
|
+
onBlur={onBlur}
|
|
53
|
+
onFocus={onFocus}
|
|
54
|
+
value={value}
|
|
55
|
+
style={styles.input}
|
|
56
|
+
keyboardType={
|
|
57
|
+
label === MOBILE_NUMBER_LABEL || label === PINCODE_LABEL ? 'number-pad' : 'default'
|
|
58
|
+
}
|
|
59
|
+
maxLength={
|
|
60
|
+
label === MOBILE_NUMBER_LABEL ? 10 : label === PINCODE_LABEL ? 6 : undefined
|
|
61
|
+
}
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
{error ? <Text style={styles.error}>{error}</Text> : null}
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const NewDeliveryAddress: React.FC<Props> = ({ navigation }) => {
|
|
71
|
+
const dispatch = useAppDispatch();
|
|
72
|
+
const route = useRoute<RouteProp<AppStackParamList, 'NewDeliveryAddress'>>();
|
|
73
|
+
const item = route.params?.item;
|
|
74
|
+
const createAddressError = useAppSelector(
|
|
75
|
+
(state: RootState) => state.auth.createAddressError
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const isEditing = !!item;
|
|
79
|
+
const isFocused = useIsFocused();
|
|
80
|
+
const [currentFocusedField, setCurrentFocusedField] = React.useState<string | null>(null);
|
|
81
|
+
const [fieldsToValidate, setFieldsToValidate] = React.useState<Set<string>>(new Set());
|
|
82
|
+
const [formKey, setFormKey] = React.useState(0);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (isFocused) {
|
|
86
|
+
setFieldsToValidate(new Set());
|
|
87
|
+
setCurrentFocusedField(null);
|
|
88
|
+
setFormKey(prev => prev + 1);
|
|
89
|
+
}
|
|
90
|
+
}, [isFocused, item]);
|
|
91
|
+
|
|
92
|
+
const initialValues = useMemo(() => {
|
|
93
|
+
const { line, landmark } = extractLineAndLandmark(item?.line);
|
|
94
|
+
return {
|
|
95
|
+
fullName: item?.name || '',
|
|
96
|
+
mobileNumber: item?.phone_numbers?.[0] || '',
|
|
97
|
+
email: item?.email || '',
|
|
98
|
+
address: line || item?.line || '',
|
|
99
|
+
landmark: landmark || '',
|
|
100
|
+
city: item?.city || '',
|
|
101
|
+
state: item?.state || '',
|
|
102
|
+
pincode: item?.zip_code || '',
|
|
103
|
+
};
|
|
104
|
+
}, [item]);
|
|
105
|
+
|
|
106
|
+
const handleSave = async (values: typeof initialValues, setErrors: any) => {
|
|
107
|
+
try {
|
|
108
|
+
if (isEditing) {
|
|
109
|
+
dispatch(
|
|
110
|
+
updateAddressRequest({
|
|
111
|
+
id: item?.id,
|
|
112
|
+
address: {
|
|
113
|
+
city: values?.city,
|
|
114
|
+
country: { id: '', name: COUNTRY_INDIA },
|
|
115
|
+
email: values?.email.trim(),
|
|
116
|
+
landmark: values?.landmark,
|
|
117
|
+
line: `${ADDRESS_LINE_PREFIX}${values?.address}\n${ADDRESS_LANDMARK_PREFIX}${values?.landmark}`,
|
|
118
|
+
name: values?.fullName,
|
|
119
|
+
phone_numbers: [values?.mobileNumber],
|
|
120
|
+
state: values?.state,
|
|
121
|
+
zip_code: values?.pincode,
|
|
122
|
+
},
|
|
123
|
+
address_type: BILLING_ADDRESS,
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
dispatch(
|
|
128
|
+
createAddressRequest({
|
|
129
|
+
address: {
|
|
130
|
+
city: values?.city,
|
|
131
|
+
country: { id: '', name: COUNTRY_INDIA },
|
|
132
|
+
email: values?.email.trim(),
|
|
133
|
+
landmark: values?.landmark,
|
|
134
|
+
line: `${ADDRESS_LINE_PREFIX}${values?.address}\n${ADDRESS_LANDMARK_PREFIX}${values?.landmark}`,
|
|
135
|
+
name: values?.fullName,
|
|
136
|
+
phone_numbers: [values?.mobileNumber],
|
|
137
|
+
state: values?.state,
|
|
138
|
+
zip_code: values?.pincode,
|
|
139
|
+
},
|
|
140
|
+
address_type: BILLING_ADDRESS,
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
navigation.goBack();
|
|
145
|
+
} catch (err: any) {
|
|
146
|
+
if (err.response?.data?.errors) {
|
|
147
|
+
setErrors(err.response.data.errors);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<View style={styles.container}>
|
|
154
|
+
<MobileHeader
|
|
155
|
+
title={isEditing ? EDIT_DELIVERY_ADDRESS : ADD_NEW_DELIVERY_ADDRESS}
|
|
156
|
+
showBack
|
|
157
|
+
onBack={() => {
|
|
158
|
+
if (navigation.canGoBack()) {
|
|
159
|
+
navigation.goBack();
|
|
160
|
+
} else {
|
|
161
|
+
navigation.navigate('DeliveryAddress' as never);
|
|
162
|
+
}
|
|
163
|
+
}}
|
|
164
|
+
disableSafeAreaPadding
|
|
165
|
+
/>
|
|
166
|
+
<KeyboardAwareScrollView
|
|
167
|
+
style={styles.keyboardAwareScrollView}
|
|
168
|
+
contentContainerStyle={styles.keyboardAwareScrollViewContent}
|
|
169
|
+
enableOnAndroid
|
|
170
|
+
enableAutomaticScroll
|
|
171
|
+
extraScrollHeight={EXTRA_SCROLL_HEIGHT}
|
|
172
|
+
keyboardShouldPersistTaps="handled"
|
|
173
|
+
enableResetScrollToCoords={false}
|
|
174
|
+
showsVerticalScrollIndicator={false}
|
|
175
|
+
>
|
|
176
|
+
<View style={styles.content}>
|
|
177
|
+
<Formik
|
|
178
|
+
key={formKey}
|
|
179
|
+
initialValues={initialValues}
|
|
180
|
+
enableReinitialize
|
|
181
|
+
validationSchema={formSchema}
|
|
182
|
+
validateOnChange
|
|
183
|
+
validateOnBlur
|
|
184
|
+
validateOnMount={true}
|
|
185
|
+
onSubmit={(values, { setErrors }) => handleSave(values, setErrors)}
|
|
186
|
+
>
|
|
187
|
+
|
|
188
|
+
{({
|
|
189
|
+
handleChange,
|
|
190
|
+
handleSubmit,
|
|
191
|
+
values,
|
|
192
|
+
errors,
|
|
193
|
+
touched,
|
|
194
|
+
setFieldTouched,
|
|
195
|
+
setFieldError,
|
|
196
|
+
validateField,
|
|
197
|
+
isSubmitting,
|
|
198
|
+
isValid,
|
|
199
|
+
}) => {
|
|
200
|
+
const handleFieldFocus = async (fieldName: string) => {
|
|
201
|
+
|
|
202
|
+
if (currentFocusedField && currentFocusedField !== fieldName) {
|
|
203
|
+
await validateField(currentFocusedField);
|
|
204
|
+
setFieldTouched(currentFocusedField, true, false);
|
|
205
|
+
setFieldsToValidate(prev => new Set([...prev, currentFocusedField]));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await formSchema.validateAt(fieldName, values);
|
|
211
|
+
setFieldError(fieldName, '');
|
|
212
|
+
} catch (e) {
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setCurrentFocusedField(fieldName);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const handleFieldChange = (fieldName: string) => (text: string) => {
|
|
220
|
+
handleChange(fieldName)(text);
|
|
221
|
+
|
|
222
|
+
if (fieldsToValidate.has(fieldName)) {
|
|
223
|
+
try {
|
|
224
|
+
formSchema.validateSyncAt(fieldName, { ...values, [fieldName]: text });
|
|
225
|
+
setFieldError(fieldName, '');
|
|
226
|
+
} catch (e) {
|
|
227
|
+
console.log(e);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
const handleFieldBlur = (fieldName: string) => {
|
|
234
|
+
validateField(fieldName);
|
|
235
|
+
setFieldTouched(fieldName, true, false);
|
|
236
|
+
setFieldsToValidate(prev => new Set([...prev, fieldName]));
|
|
237
|
+
setCurrentFocusedField(null);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
const shouldShowError = (fieldName: string) => {
|
|
242
|
+
return fieldsToValidate.has(fieldName) && typeof errors[fieldName as keyof typeof errors] === 'string';
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<>
|
|
247
|
+
<CustomField
|
|
248
|
+
label={FULL_NAME_LABEL}
|
|
249
|
+
value={values.fullName}
|
|
250
|
+
onChangeText={handleFieldChange(FULL_NAME)}
|
|
251
|
+
onFocus={() => handleFieldFocus(FULL_NAME)}
|
|
252
|
+
onBlur={() => handleFieldBlur(FULL_NAME)}
|
|
253
|
+
error={
|
|
254
|
+
shouldShowError(FULL_NAME) && errors.fullName
|
|
255
|
+
? (errors.fullName as string)
|
|
256
|
+
: ''
|
|
257
|
+
}
|
|
258
|
+
/>
|
|
259
|
+
<CustomField
|
|
260
|
+
label={MOBILE_NUMBER_LABEL}
|
|
261
|
+
value={values.mobileNumber}
|
|
262
|
+
onChangeText={handleFieldChange(MOBILE_NUMBER)}
|
|
263
|
+
onFocus={() => handleFieldFocus(MOBILE_NUMBER)}
|
|
264
|
+
onBlur={() => handleFieldBlur(MOBILE_NUMBER)}
|
|
265
|
+
error={
|
|
266
|
+
shouldShowError(MOBILE_NUMBER) && errors.mobileNumber
|
|
267
|
+
? (errors.mobileNumber as string)
|
|
268
|
+
: ''
|
|
269
|
+
}
|
|
270
|
+
/>
|
|
271
|
+
<CustomField
|
|
272
|
+
label={EMAIL_ID_LABEL}
|
|
273
|
+
value={values.email}
|
|
274
|
+
onChangeText={handleFieldChange(EMAIL_ID)}
|
|
275
|
+
onFocus={() => handleFieldFocus(EMAIL_ID)}
|
|
276
|
+
onBlur={() => handleFieldBlur(EMAIL_ID)}
|
|
277
|
+
error={
|
|
278
|
+
shouldShowError(EMAIL_ID) && errors.email
|
|
279
|
+
? (errors.email as string)
|
|
280
|
+
: ''
|
|
281
|
+
}
|
|
282
|
+
/>
|
|
283
|
+
<CustomField
|
|
284
|
+
label={ADDRESS_LABEL}
|
|
285
|
+
value={values.address}
|
|
286
|
+
onChangeText={handleFieldChange(ADDRESS)}
|
|
287
|
+
onFocus={() => handleFieldFocus(ADDRESS)}
|
|
288
|
+
onBlur={() => handleFieldBlur(ADDRESS)}
|
|
289
|
+
error={
|
|
290
|
+
shouldShowError(ADDRESS) && errors.address
|
|
291
|
+
? (errors.address as string)
|
|
292
|
+
: ''
|
|
293
|
+
}
|
|
294
|
+
/>
|
|
295
|
+
<CustomField
|
|
296
|
+
label={LANDMARK_LABEL}
|
|
297
|
+
value={values.landmark}
|
|
298
|
+
onChangeText={handleFieldChange(LANDMARK)}
|
|
299
|
+
onFocus={() => handleFieldFocus(LANDMARK)}
|
|
300
|
+
onBlur={() => handleFieldBlur(LANDMARK)}
|
|
301
|
+
error={
|
|
302
|
+
shouldShowError(LANDMARK) && errors.landmark
|
|
303
|
+
? (errors.landmark as string)
|
|
304
|
+
: ''
|
|
305
|
+
}
|
|
306
|
+
/>
|
|
307
|
+
<CustomField
|
|
308
|
+
label={CITY_LABEL}
|
|
309
|
+
value={values.city}
|
|
310
|
+
onChangeText={handleFieldChange(CITY)}
|
|
311
|
+
onFocus={() => handleFieldFocus(CITY)}
|
|
312
|
+
onBlur={() => handleFieldBlur(CITY)}
|
|
313
|
+
error={
|
|
314
|
+
shouldShowError(CITY) && errors.city
|
|
315
|
+
? (errors.city as string)
|
|
316
|
+
: ''
|
|
317
|
+
}
|
|
318
|
+
/>
|
|
319
|
+
<CustomField
|
|
320
|
+
label={STATE_LABEL}
|
|
321
|
+
value={values.state}
|
|
322
|
+
onChangeText={handleFieldChange(STATE)}
|
|
323
|
+
onFocus={() => handleFieldFocus(STATE)}
|
|
324
|
+
onBlur={() => handleFieldBlur(STATE)}
|
|
325
|
+
error={
|
|
326
|
+
shouldShowError(STATE) && errors.state
|
|
327
|
+
? (errors.state as string)
|
|
328
|
+
: ''
|
|
329
|
+
}
|
|
330
|
+
/>
|
|
331
|
+
<CustomField
|
|
332
|
+
label={PINCODE_LABEL}
|
|
333
|
+
value={values.pincode}
|
|
334
|
+
onChangeText={handleFieldChange(PINCODE)}
|
|
335
|
+
onFocus={() => handleFieldFocus(PINCODE)}
|
|
336
|
+
onBlur={() => handleFieldBlur(PINCODE)}
|
|
337
|
+
error={
|
|
338
|
+
shouldShowError(PINCODE) && errors.pincode
|
|
339
|
+
? (errors.pincode as string)
|
|
340
|
+
: ''
|
|
341
|
+
}
|
|
342
|
+
/>
|
|
343
|
+
|
|
344
|
+
<CustomButton
|
|
345
|
+
title={isEditing ? UPDATE_AND_PROCEED : SAVE_AND_PROCEED}
|
|
346
|
+
onPress={() => handleSubmit()}
|
|
347
|
+
disabled={!isValid || isSubmitting}
|
|
348
|
+
/>
|
|
349
|
+
</>
|
|
350
|
+
);
|
|
351
|
+
}}
|
|
352
|
+
</Formik>
|
|
353
|
+
</View>
|
|
354
|
+
</KeyboardAwareScrollView>
|
|
355
|
+
</View>
|
|
356
|
+
);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export default NewDeliveryAddress;
|
|
360
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Platform, StyleSheet } from "react-native";
|
|
2
|
+
import FontFamily from "../../../src-app/constants/Fonts";
|
|
3
|
+
import { SCALE, VSCALE } from "../../../src-app/constants/Scaling";
|
|
4
|
+
import { colors } from "../../../src-app/styles/colors";
|
|
5
|
+
|
|
6
|
+
export const EXTRA_SCROLL_HEIGHT =
|
|
7
|
+
Platform.OS === "ios" ? VSCALE(200) : VSCALE(150);
|
|
8
|
+
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
flex: 1,
|
|
12
|
+
backgroundColor: colors.background,
|
|
13
|
+
},
|
|
14
|
+
icon: {
|
|
15
|
+
height: VSCALE(24),
|
|
16
|
+
width: VSCALE(24),
|
|
17
|
+
resizeMode: "contain",
|
|
18
|
+
},
|
|
19
|
+
content: {
|
|
20
|
+
padding: 20,
|
|
21
|
+
},
|
|
22
|
+
scrollContent: {
|
|
23
|
+
paddingBottom: 80,
|
|
24
|
+
},
|
|
25
|
+
inputContainer: {
|
|
26
|
+
borderWidth: 1,
|
|
27
|
+
borderColor: colors.outline,
|
|
28
|
+
borderRadius: 12,
|
|
29
|
+
backgroundColor: colors.white,
|
|
30
|
+
paddingHorizontal: 20,
|
|
31
|
+
marginBottom: "7%",
|
|
32
|
+
},
|
|
33
|
+
label: {
|
|
34
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
35
|
+
fontSize: 12,
|
|
36
|
+
fontWeight: 400,
|
|
37
|
+
color: colors.onSurfaceVariant,
|
|
38
|
+
paddingVertical: 7,
|
|
39
|
+
paddingBottom: 0,
|
|
40
|
+
},
|
|
41
|
+
input: {
|
|
42
|
+
fontSize: 14,
|
|
43
|
+
color: colors.onSurface,
|
|
44
|
+
borderRadius: 8,
|
|
45
|
+
backgroundColor: colors.white,
|
|
46
|
+
textAlignVertical: "top",
|
|
47
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
48
|
+
fontWeight: 400,
|
|
49
|
+
paddingVertical: 7,
|
|
50
|
+
right: Platform.OS === "ios" ? 0 : VSCALE(3),
|
|
51
|
+
},
|
|
52
|
+
keyboardAwareScrollView: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
},
|
|
55
|
+
keyboardAwareScrollViewContent: {
|
|
56
|
+
flexGrow: 1,
|
|
57
|
+
paddingBottom: VSCALE(40),
|
|
58
|
+
},
|
|
59
|
+
error: {
|
|
60
|
+
color: colors.red,
|
|
61
|
+
fontSize: SCALE(12),
|
|
62
|
+
fontFamily: FontFamily.LEXEND_REGULAR,
|
|
63
|
+
marginBottom: VSCALE(4),
|
|
64
|
+
bottom: VSCALE(15),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export default styles;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import { StackNavigationProp } from '@react-navigation/stack';
|
|
4
|
+
import { RootStackParamList } from '../../../src-app/types/navigation';
|
|
5
|
+
import Button from '../../../src-app/components/Button';
|
|
6
|
+
import styles from './styles';
|
|
7
|
+
import ENV from '../../../src-app/config/env';
|
|
8
|
+
console.log("Config API_URL:", ENV.apiUrl);
|
|
9
|
+
|
|
10
|
+
type OnboardingNavigationProp = StackNavigationProp<
|
|
11
|
+
RootStackParamList,
|
|
12
|
+
'Onboarding'
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
navigation: OnboardingNavigationProp;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Onboarding: React.FC<Props> = ({ navigation }) => {
|
|
20
|
+
return (
|
|
21
|
+
<View style={styles.container}>
|
|
22
|
+
<View style={styles.content}>
|
|
23
|
+
<View style={styles.header}>
|
|
24
|
+
<Text style={styles.title}>APNA Club Mobile App</Text>
|
|
25
|
+
<Text style={styles.subtitle}>
|
|
26
|
+
Experience the mobile loyalty app interface
|
|
27
|
+
</Text>
|
|
28
|
+
</View>
|
|
29
|
+
|
|
30
|
+
<View style={styles.buttonContainer}>
|
|
31
|
+
<Button
|
|
32
|
+
title="Start Login Flow"
|
|
33
|
+
onPress={() => navigation.navigate('Login')}
|
|
34
|
+
fullWidth
|
|
35
|
+
style={styles.primaryButton}
|
|
36
|
+
/>
|
|
37
|
+
<Button
|
|
38
|
+
title="View Dashboard"
|
|
39
|
+
variant="outline"
|
|
40
|
+
onPress={() => navigation.navigate('MainTabs')}
|
|
41
|
+
fullWidth
|
|
42
|
+
style={styles.outlineButton}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
45
|
+
|
|
46
|
+
<View style={styles.footer}>
|
|
47
|
+
<Text style={styles.footerText}>Mobile-first responsive design</Text>
|
|
48
|
+
<Text style={styles.footerText}>
|
|
49
|
+
Best viewed on mobile or narrow screen
|
|
50
|
+
</Text>
|
|
51
|
+
</View>
|
|
52
|
+
</View>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default Onboarding;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { borderRadius, spacing, typography } from '../../../src-app/styles/shared';
|
|
3
|
+
import { colors } from '../../../src-app/styles/colors';
|
|
4
|
+
|
|
5
|
+
const styles = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: colors.surface,
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
padding: spacing.lg,
|
|
12
|
+
},
|
|
13
|
+
content: {
|
|
14
|
+
width: '100%',
|
|
15
|
+
maxWidth: 400,
|
|
16
|
+
backgroundColor: colors.background,
|
|
17
|
+
borderRadius: borderRadius.xl,
|
|
18
|
+
padding: spacing.xl,
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
},
|
|
21
|
+
header: {
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
marginBottom: spacing.xl,
|
|
24
|
+
},
|
|
25
|
+
title: {
|
|
26
|
+
...typography.h1,
|
|
27
|
+
color: colors.onSurface,
|
|
28
|
+
textAlign: 'center',
|
|
29
|
+
marginBottom: spacing.sm,
|
|
30
|
+
},
|
|
31
|
+
subtitle: {
|
|
32
|
+
...typography.bodySmall,
|
|
33
|
+
color: colors.onSurfaceVariant,
|
|
34
|
+
textAlign: 'center',
|
|
35
|
+
},
|
|
36
|
+
buttonContainer: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
gap: spacing.md,
|
|
39
|
+
marginBottom: spacing.xl,
|
|
40
|
+
},
|
|
41
|
+
primaryButton: {
|
|
42
|
+
backgroundColor: colors.primary,
|
|
43
|
+
},
|
|
44
|
+
outlineButton: {
|
|
45
|
+
borderColor: colors.outline,
|
|
46
|
+
},
|
|
47
|
+
footer: {
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
paddingTop: spacing.lg,
|
|
50
|
+
borderTopWidth: 1,
|
|
51
|
+
borderTopColor: colors.outlineVariant,
|
|
52
|
+
},
|
|
53
|
+
footerText: {
|
|
54
|
+
...typography.caption,
|
|
55
|
+
color: colors.onSurfaceVariant,
|
|
56
|
+
textAlign: 'center',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default styles;
|