@finspringinnovations/fdsdk 0.0.1
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/README.md +184 -0
- package/lib/api/applicationApi.d.ts +1 -0
- package/lib/api/applicationApi.js +11 -0
- package/lib/api/bankApi.d.ts +352 -0
- package/lib/api/bankApi.js +54 -0
- package/lib/api/baseApi.d.ts +8 -0
- package/lib/api/baseApi.js +456 -0
- package/lib/api/customerApi.d.ts +855 -0
- package/lib/api/customerApi.js +213 -0
- package/lib/api/fdApi.d.ts +979 -0
- package/lib/api/fdApi.js +112 -0
- package/lib/api/fdCalculatorApi.d.ts +179 -0
- package/lib/api/fdCalculatorApi.js +36 -0
- package/lib/api/index.d.ts +14 -0
- package/lib/api/index.js +45 -0
- package/lib/api/interestRateApi.d.ts +585 -0
- package/lib/api/interestRateApi.js +101 -0
- package/lib/api/kycApi.d.ts +486 -0
- package/lib/api/kycApi.js +71 -0
- package/lib/api/masterDataApi.d.ts +158 -0
- package/lib/api/masterDataApi.js +32 -0
- package/lib/api/nomineeApi.d.ts +325 -0
- package/lib/api/nomineeApi.js +46 -0
- package/lib/api/onboardingApi.d.ts +192 -0
- package/lib/api/onboardingApi.js +41 -0
- package/lib/api/panApi.d.ts +0 -0
- package/lib/api/panApi.js +23 -0
- package/lib/api/paymentApi.d.ts +325 -0
- package/lib/api/paymentApi.js +46 -0
- package/lib/api/workflowApi.d.ts +654 -0
- package/lib/api/workflowApi.js +90 -0
- package/lib/assets/images/images.d.ts +4 -0
- package/lib/assets/images/images.js +10 -0
- package/lib/components/AadhaarInput.d.ts +13 -0
- package/lib/components/AadhaarInput.js +47 -0
- package/lib/components/ActionButton.d.ts +12 -0
- package/lib/components/ActionButton.js +87 -0
- package/lib/components/ActiveFDCard.d.ts +16 -0
- package/lib/components/ActiveFDCard.js +95 -0
- package/lib/components/AmountInput.d.ts +20 -0
- package/lib/components/AmountInput.js +144 -0
- package/lib/components/CheckboxOption.d.ts +11 -0
- package/lib/components/CheckboxOption.js +41 -0
- package/lib/components/CompanyHeader.d.ts +7 -0
- package/lib/components/CompanyHeader.js +57 -0
- package/lib/components/DropdownSelector.d.ts +9 -0
- package/lib/components/DropdownSelector.js +49 -0
- package/lib/components/EmptyState.d.ts +17 -0
- package/lib/components/EmptyState.js +44 -0
- package/lib/components/ErrorDisplay.d.ts +17 -0
- package/lib/components/ErrorDisplay.js +69 -0
- package/lib/components/FAQItem.d.ts +9 -0
- package/lib/components/FAQItem.js +52 -0
- package/lib/components/FDCard.d.ts +21 -0
- package/lib/components/FDCard.js +96 -0
- package/lib/components/FormDropdown.d.ts +18 -0
- package/lib/components/FormDropdown.js +155 -0
- package/lib/components/FormSection.d.ts +14 -0
- package/lib/components/FormSection.js +38 -0
- package/lib/components/Header.d.ts +14 -0
- package/lib/components/Header.js +52 -0
- package/lib/components/IFSCSearchResultCard.d.ts +13 -0
- package/lib/components/IFSCSearchResultCard.js +70 -0
- package/lib/components/InfoBox.d.ts +8 -0
- package/lib/components/InfoBox.js +39 -0
- package/lib/components/InterestRateCard.d.ts +8 -0
- package/lib/components/InterestRateCard.js +46 -0
- package/lib/components/LoadingIndicator.d.ts +12 -0
- package/lib/components/LoadingIndicator.js +30 -0
- package/lib/components/OTPInput.d.ts +17 -0
- package/lib/components/OTPInput.js +144 -0
- package/lib/components/PaymentDetailsCard.d.ts +20 -0
- package/lib/components/PaymentDetailsCard.js +68 -0
- package/lib/components/PendingFDBottomSheet.d.ts +18 -0
- package/lib/components/PendingFDBottomSheet.js +122 -0
- package/lib/components/SafeAreaWrapper.d.ts +13 -0
- package/lib/components/SafeAreaWrapper.js +41 -0
- package/lib/components/ScreenHeader.d.ts +11 -0
- package/lib/components/ScreenHeader.js +46 -0
- package/lib/components/StatusDisplay.d.ts +15 -0
- package/lib/components/StatusDisplay.js +88 -0
- package/lib/components/TextFieldWithLabel.d.ts +46 -0
- package/lib/components/TextFieldWithLabel.js +326 -0
- package/lib/components/TrustBox.d.ts +8 -0
- package/lib/components/TrustBox.js +45 -0
- package/lib/components/ValidationErrorAlert.d.ts +23 -0
- package/lib/components/ValidationErrorAlert.js +39 -0
- package/lib/components/ValidationMessage.d.ts +9 -0
- package/lib/components/ValidationMessage.js +98 -0
- package/lib/components/index.d.ts +35 -0
- package/lib/components/index.js +64 -0
- package/lib/config/apiConfig.d.ts +34 -0
- package/lib/config/apiConfig.js +158 -0
- package/lib/config/appDataConfig.d.ts +114 -0
- package/lib/config/appDataConfig.js +264 -0
- package/lib/config/encryptionConfig.d.ts +21 -0
- package/lib/config/encryptionConfig.js +61 -0
- package/lib/config/workflowConstants.d.ts +37 -0
- package/lib/config/workflowConstants.js +38 -0
- package/lib/constants/strings/bank.d.ts +72 -0
- package/lib/constants/strings/bank.js +86 -0
- package/lib/constants/strings/base64Images.d.ts +25 -0
- package/lib/constants/strings/base64Images.js +28 -0
- package/lib/constants/strings/common.d.ts +53 -0
- package/lib/constants/strings/common.js +62 -0
- package/lib/constants/strings/employee.d.ts +61 -0
- package/lib/constants/strings/employee.js +77 -0
- package/lib/constants/strings/faq.d.ts +14 -0
- package/lib/constants/strings/faq.js +20 -0
- package/lib/constants/strings/fd.d.ts +122 -0
- package/lib/constants/strings/fd.js +151 -0
- package/lib/constants/strings/home.d.ts +49 -0
- package/lib/constants/strings/home.js +62 -0
- package/lib/constants/strings/index.d.ts +16 -0
- package/lib/constants/strings/index.js +44 -0
- package/lib/constants/strings/kyc.d.ts +80 -0
- package/lib/constants/strings/kyc.js +94 -0
- package/lib/constants/strings/nominee.d.ts +64 -0
- package/lib/constants/strings/nominee.js +81 -0
- package/lib/hooks/useAuth.d.ts +25 -0
- package/lib/hooks/useAuth.js +39 -0
- package/lib/hooks/useFDData.d.ts +11 -0
- package/lib/hooks/useFDData.js +40 -0
- package/lib/index.d.ts +69 -0
- package/lib/index.js +182 -0
- package/lib/navigation/RootNavigator.d.ts +8 -0
- package/lib/navigation/RootNavigator.js +205 -0
- package/lib/navigation/SimpleNavigator.d.ts +11 -0
- package/lib/navigation/SimpleNavigator.js +107 -0
- package/lib/navigation/helpers.d.ts +11 -0
- package/lib/navigation/helpers.js +83 -0
- package/lib/navigation/index.d.ts +15 -0
- package/lib/navigation/index.js +42 -0
- package/lib/navigation/types.d.ts +113 -0
- package/lib/navigation/types.js +2 -0
- package/lib/navigation/workflowNavigator.d.ts +22 -0
- package/lib/navigation/workflowNavigator.js +104 -0
- package/lib/providers/ApiProvider.d.ts +7 -0
- package/lib/providers/ApiProvider.js +34 -0
- package/lib/providers/MasterDataProvider.d.ts +10 -0
- package/lib/providers/MasterDataProvider.js +54 -0
- package/lib/screens/AadhaarVerification.d.ts +7 -0
- package/lib/screens/AadhaarVerification.js +627 -0
- package/lib/screens/AddBankAccount.d.ts +22 -0
- package/lib/screens/AddBankAccount.js +381 -0
- package/lib/screens/BankDetail.d.ts +16 -0
- package/lib/screens/BankDetail.js +596 -0
- package/lib/screens/BookFD.d.ts +0 -0
- package/lib/screens/BookFD.js +315 -0
- package/lib/screens/Employee.d.ts +18 -0
- package/lib/screens/Employee.js +594 -0
- package/lib/screens/FDCalculator.d.ts +18 -0
- package/lib/screens/FDCalculator.js +759 -0
- package/lib/screens/FDList.d.ts +27 -0
- package/lib/screens/FDList.js +1008 -0
- package/lib/screens/FindIFSC.d.ts +16 -0
- package/lib/screens/FindIFSC.js +248 -0
- package/lib/screens/Home.d.ts +0 -0
- package/lib/screens/Home.js +143 -0
- package/lib/screens/NomineeDetail.d.ts +17 -0
- package/lib/screens/NomineeDetail.js +592 -0
- package/lib/screens/PayNow.d.ts +14 -0
- package/lib/screens/PayNow.js +230 -0
- package/lib/screens/Payment.d.ts +11 -0
- package/lib/screens/Payment.js +191 -0
- package/lib/screens/PaymentStatus.d.ts +16 -0
- package/lib/screens/PaymentStatus.js +397 -0
- package/lib/screens/ReviewKYC.d.ts +21 -0
- package/lib/screens/ReviewKYC.js +660 -0
- package/lib/state/paymentSession.d.ts +8 -0
- package/lib/state/paymentSession.js +13 -0
- package/lib/store/fdListSelectedSlice.d.ts +21 -0
- package/lib/store/fdListSelectedSlice.js +26 -0
- package/lib/store/hooks.d.ts +8 -0
- package/lib/store/hooks.js +31 -0
- package/lib/store/index.d.ts +3 -0
- package/lib/store/index.js +8 -0
- package/lib/store/onboardingSlice.d.ts +12 -0
- package/lib/store/onboardingSlice.js +32 -0
- package/lib/store/store.d.ts +13 -0
- package/lib/store/store.js +33 -0
- package/lib/theme/ThemeContext.d.ts +210 -0
- package/lib/theme/ThemeContext.js +90 -0
- package/lib/theme/colors.d.ts +80 -0
- package/lib/theme/colors.js +85 -0
- package/lib/theme/index.d.ts +34 -0
- package/lib/theme/index.js +69 -0
- package/lib/theme/shadows.d.ts +53 -0
- package/lib/theme/shadows.js +58 -0
- package/lib/theme/typography.d.ts +134 -0
- package/lib/theme/typography.js +143 -0
- package/lib/types/dataTypes.d.ts +34 -0
- package/lib/types/dataTypes.js +2 -0
- package/lib/types/workflowTypes.d.ts +2 -0
- package/lib/types/workflowTypes.js +2 -0
- package/lib/utils/apiLogger.d.ts +48 -0
- package/lib/utils/apiLogger.js +105 -0
- package/lib/utils/encryption.d.ts +28 -0
- package/lib/utils/encryption.js +113 -0
- package/lib/utils/getFDData.d.ts +48 -0
- package/lib/utils/getFDData.js +154 -0
- package/lib/utils/globalData.d.ts +2 -0
- package/lib/utils/globalData.js +10 -0
- package/package.json +76 -0
- package/src/api/applicationApi.ts +12 -0
- package/src/api/bankApi.ts +42 -0
- package/src/api/baseApi.ts +513 -0
- package/src/api/customerApi.ts +291 -0
- package/src/api/fdApi.ts +150 -0
- package/src/api/fdCalculatorApi.ts +41 -0
- package/src/api/index.ts +29 -0
- package/src/api/interestRateApi.ts +143 -0
- package/src/api/kycApi.ts +63 -0
- package/src/api/masterDataApi.ts +34 -0
- package/src/api/nomineeApi.ts +34 -0
- package/src/api/onboardingApi.ts +64 -0
- package/src/api/panApi.ts +25 -0
- package/src/api/paymentApi.ts +34 -0
- package/src/api/workflowApi.ts +94 -0
- package/src/assets/images/arrow-filled.png +0 -0
- package/src/assets/images/arrow-left.png +0 -0
- package/src/assets/images/backicon.png +0 -0
- package/src/assets/images/calendar.png +0 -0
- package/src/assets/images/chevron-down.png +0 -0
- package/src/assets/images/chevron-down@2x.png +0 -0
- package/src/assets/images/chevron-down@3x.png +0 -0
- package/src/assets/images/images.js +8 -0
- package/src/components/AadhaarInput.tsx +91 -0
- package/src/components/ActionButton.tsx +129 -0
- package/src/components/ActiveFDCard.tsx +158 -0
- package/src/components/AmountInput.tsx +217 -0
- package/src/components/CheckboxOption.tsx +93 -0
- package/src/components/CompanyHeader.tsx +78 -0
- package/src/components/DropdownSelector.tsx +77 -0
- package/src/components/EmptyState.tsx +109 -0
- package/src/components/ErrorDisplay.tsx +135 -0
- package/src/components/FAQItem.tsx +90 -0
- package/src/components/FDCard.tsx +165 -0
- package/src/components/FormDropdown.tsx +214 -0
- package/src/components/FormSection.tsx +86 -0
- package/src/components/Header.tsx +110 -0
- package/src/components/IFSCSearchResultCard.tsx +139 -0
- package/src/components/InfoBox.tsx +55 -0
- package/src/components/InterestRateCard.tsx +77 -0
- package/src/components/LoadingIndicator.tsx +63 -0
- package/src/components/OTPInput.tsx +213 -0
- package/src/components/PaymentDetailsCard.tsx +120 -0
- package/src/components/PendingFDBottomSheet.tsx +235 -0
- package/src/components/README.md +210 -0
- package/src/components/SafeAreaWrapper.tsx +68 -0
- package/src/components/ScreenHeader.tsx +83 -0
- package/src/components/StatusDisplay.tsx +139 -0
- package/src/components/TextFieldWithLabel.tsx +502 -0
- package/src/components/TrustBox.tsx +63 -0
- package/src/components/ValidationErrorAlert.tsx +57 -0
- package/src/components/ValidationMessage.tsx +134 -0
- package/src/components/index.tsx +47 -0
- package/src/config/apiConfig.ts +217 -0
- package/src/config/appDataConfig.ts +279 -0
- package/src/config/encryptionConfig.ts +65 -0
- package/src/config/workflowConstants.ts +43 -0
- package/src/constants/strings/README.md +146 -0
- package/src/constants/strings/bank.ts +92 -0
- package/src/constants/strings/base64Images.ts +29 -0
- package/src/constants/strings/common.ts +63 -0
- package/src/constants/strings/employee.ts +85 -0
- package/src/constants/strings/faq.ts +23 -0
- package/src/constants/strings/fd.ts +172 -0
- package/src/constants/strings/home.ts +67 -0
- package/src/constants/strings/index.ts +21 -0
- package/src/constants/strings/kyc.ts +100 -0
- package/src/constants/strings/nominee.ts +90 -0
- package/src/hooks/useAuth.ts +42 -0
- package/src/hooks/useFDData.ts +48 -0
- package/src/index.tsx +173 -0
- package/src/navigation/RootNavigator.tsx +352 -0
- package/src/navigation/SimpleNavigator.tsx +107 -0
- package/src/navigation/helpers.ts +85 -0
- package/src/navigation/index.tsx +81 -0
- package/src/navigation/types.ts +124 -0
- package/src/navigation/workflowNavigator.ts +131 -0
- package/src/providers/ApiProvider.tsx +43 -0
- package/src/providers/MasterDataProvider.tsx +30 -0
- package/src/screens/AadhaarVerification.tsx +809 -0
- package/src/screens/AddBankAccount.tsx +541 -0
- package/src/screens/BankDetail.tsx +826 -0
- package/src/screens/BookFD.tsx +330 -0
- package/src/screens/Employee.tsx +822 -0
- package/src/screens/FDCalculator.tsx +987 -0
- package/src/screens/FDList.tsx +1284 -0
- package/src/screens/FindIFSC.tsx +332 -0
- package/src/screens/Home.tsx +152 -0
- package/src/screens/NomineeDetail.tsx +800 -0
- package/src/screens/PayNow.tsx +282 -0
- package/src/screens/Payment.tsx +224 -0
- package/src/screens/PaymentStatus.tsx +561 -0
- package/src/screens/ReviewKYC.tsx +956 -0
- package/src/state/paymentSession.ts +13 -0
- package/src/store/fdListSelectedSlice.ts +42 -0
- package/src/store/hooks.ts +27 -0
- package/src/store/index.ts +3 -0
- package/src/store/onboardingSlice.ts +37 -0
- package/src/store/store.ts +35 -0
- package/src/theme/ThemeContext.tsx +82 -0
- package/src/theme/colors.ts +90 -0
- package/src/theme/index.ts +64 -0
- package/src/theme/shadows.ts +61 -0
- package/src/theme/typography.ts +151 -0
- package/src/types/dataTypes.ts +37 -0
- package/src/types/env.d.ts +93 -0
- package/src/types/workflowTypes.ts +12 -0
- package/src/utils/apiLogger.ts +166 -0
- package/src/utils/encryption.ts +159 -0
- package/src/utils/getFDData.ts +175 -0
- package/src/utils/globalData.ts +7 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Image, Platform } from 'react-native';
|
|
3
|
+
import Icon from 'react-native-vector-icons/Ionicons';
|
|
4
|
+
import { base64Images } from '../constants/strings/base64Images';
|
|
5
|
+
import { useColors, useTypography, useTheme } from '../theme/ThemeContext';
|
|
6
|
+
import { getBorderColor } from '../theme';
|
|
7
|
+
|
|
8
|
+
// Base interface for all text field variants
|
|
9
|
+
export interface BaseTextFieldProps {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
onChangeText: (text: string) => void;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
placeholderColor?: string;
|
|
15
|
+
editable?: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
success?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
testID?: string;
|
|
20
|
+
keepWhiteBackground?: boolean; // New prop to keep white background when disabled
|
|
21
|
+
onFocus?: () => void; // Callback when field receives focus
|
|
22
|
+
onBlur?: () => void; // Callback when field loses focus
|
|
23
|
+
textInputRef?: React.RefObject<TextInput>; // Ref to the text input
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extended interface for different field types
|
|
27
|
+
export interface TextFieldWithLabelProps extends BaseTextFieldProps {
|
|
28
|
+
variant?: 'text' | 'dropdown' | 'date' | 'numeric' | 'email' | 'phone';
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
multiline?: boolean;
|
|
31
|
+
numberOfLines?: number;
|
|
32
|
+
secureTextEntry?: boolean;
|
|
33
|
+
keyboardType?: 'default' | 'numeric' | 'email-address' | 'phone-pad';
|
|
34
|
+
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
|
|
35
|
+
|
|
36
|
+
// Dropdown specific props
|
|
37
|
+
options?: string[];
|
|
38
|
+
onDropdownSelect?: (option: string) => void;
|
|
39
|
+
isDropdownOpen?: boolean;
|
|
40
|
+
onDropdownToggle?: () => void;
|
|
41
|
+
|
|
42
|
+
// Date specific props
|
|
43
|
+
onDatePress?: () => void;
|
|
44
|
+
dateFormat?: string;
|
|
45
|
+
|
|
46
|
+
// Icon props
|
|
47
|
+
leftIcon?: string;
|
|
48
|
+
rightIcon?: string;
|
|
49
|
+
onRightIconPress?: () => void;
|
|
50
|
+
|
|
51
|
+
// Styling props
|
|
52
|
+
containerStyle?: object;
|
|
53
|
+
inputStyle?: object;
|
|
54
|
+
labelStyle?: object;
|
|
55
|
+
|
|
56
|
+
// Validation props
|
|
57
|
+
validator?: (value: string) => string | null;
|
|
58
|
+
validateOnBlur?: boolean;
|
|
59
|
+
validateOnChange?: boolean;
|
|
60
|
+
|
|
61
|
+
// Keyboard props
|
|
62
|
+
returnKeyType?: 'done' | 'go' | 'next' | 'search' | 'send' | 'default';
|
|
63
|
+
onSubmitEditing?: () => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const TextFieldWithLabel: React.FC<TextFieldWithLabelProps> = ({
|
|
67
|
+
label,
|
|
68
|
+
value,
|
|
69
|
+
onChangeText,
|
|
70
|
+
placeholder,
|
|
71
|
+
placeholderColor,
|
|
72
|
+
editable = true,
|
|
73
|
+
error,
|
|
74
|
+
success,
|
|
75
|
+
required = false,
|
|
76
|
+
testID,
|
|
77
|
+
variant = 'text',
|
|
78
|
+
maxLength,
|
|
79
|
+
multiline = false,
|
|
80
|
+
numberOfLines = 1,
|
|
81
|
+
secureTextEntry = false,
|
|
82
|
+
keyboardType = 'default',
|
|
83
|
+
autoCapitalize = 'sentences',
|
|
84
|
+
options = [],
|
|
85
|
+
onDropdownSelect,
|
|
86
|
+
isDropdownOpen,
|
|
87
|
+
onDropdownToggle,
|
|
88
|
+
onDatePress,
|
|
89
|
+
dateFormat = 'DD/MM/YYYY',
|
|
90
|
+
leftIcon,
|
|
91
|
+
rightIcon,
|
|
92
|
+
onRightIconPress,
|
|
93
|
+
containerStyle,
|
|
94
|
+
inputStyle,
|
|
95
|
+
labelStyle,
|
|
96
|
+
validator,
|
|
97
|
+
validateOnBlur = false,
|
|
98
|
+
validateOnChange = false,
|
|
99
|
+
keepWhiteBackground = false,
|
|
100
|
+
onFocus,
|
|
101
|
+
onBlur,
|
|
102
|
+
textInputRef,
|
|
103
|
+
returnKeyType,
|
|
104
|
+
onSubmitEditing,
|
|
105
|
+
}) => {
|
|
106
|
+
const colors = useColors();
|
|
107
|
+
const typography = useTypography();
|
|
108
|
+
const { themeName } = useTheme();
|
|
109
|
+
const styles = React.useMemo(() => createStyles(colors, typography, themeName), [colors, typography, themeName]);
|
|
110
|
+
|
|
111
|
+
const [internalDropdownOpen, setInternalDropdownOpen] = useState(false);
|
|
112
|
+
const isDropdownOpenState = isDropdownOpen !== undefined ? isDropdownOpen : internalDropdownOpen;
|
|
113
|
+
const [internalError, setInternalError] = useState<string>('');
|
|
114
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
115
|
+
|
|
116
|
+
// Validation logic
|
|
117
|
+
const validateField = (text: string) => {
|
|
118
|
+
if (validator) {
|
|
119
|
+
const validationError = validator(text);
|
|
120
|
+
setInternalError(validationError || '');
|
|
121
|
+
return validationError;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// Handle text change with validation
|
|
127
|
+
const handleTextChange = (text: string) => {
|
|
128
|
+
onChangeText(text);
|
|
129
|
+
if (validateOnChange) {
|
|
130
|
+
validateField(text);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Handle blur with validation
|
|
135
|
+
const handleBlur = () => {
|
|
136
|
+
setIsFocused(false);
|
|
137
|
+
if (validateOnBlur) {
|
|
138
|
+
validateField(value);
|
|
139
|
+
}
|
|
140
|
+
onBlur?.(); // Call the onBlur callback if provided
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Handle focus
|
|
144
|
+
const handleFocus = () => {
|
|
145
|
+
setIsFocused(true);
|
|
146
|
+
setInternalError(''); // Clear internal errors on focus
|
|
147
|
+
onFocus?.(); // Call the onFocus callback if provided
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Determine border styling
|
|
151
|
+
const getBorderStyle = () => {
|
|
152
|
+
const displayError = error || internalError;
|
|
153
|
+
if (displayError) {
|
|
154
|
+
return { borderColor: colors.error, borderWidth: 1 };
|
|
155
|
+
}
|
|
156
|
+
if (success) {
|
|
157
|
+
return { borderColor: colors.success, borderWidth: 1 };
|
|
158
|
+
}
|
|
159
|
+
if (isFocused) {
|
|
160
|
+
return { borderColor: colors.primary, borderWidth: 1 };
|
|
161
|
+
}
|
|
162
|
+
if (themeName === 'dark') {
|
|
163
|
+
return {
|
|
164
|
+
borderColor: colors.inputBorder,
|
|
165
|
+
borderWidth: 1
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
borderColor: getBorderColor({ colors } as any, 0.36),
|
|
170
|
+
borderWidth: 0.5
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Render label with required indicator
|
|
175
|
+
const renderLabel = () => (
|
|
176
|
+
<Text style={[styles.label, labelStyle]}>
|
|
177
|
+
{label}
|
|
178
|
+
{required && <Text style={styles.requiredIndicator}> *</Text>}
|
|
179
|
+
</Text>
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// Render validation message
|
|
183
|
+
const renderValidationMessage = () => {
|
|
184
|
+
const displayError = error || internalError;
|
|
185
|
+
const message = displayError || success;
|
|
186
|
+
|
|
187
|
+
if (!message) return null;
|
|
188
|
+
|
|
189
|
+
const isError = !!displayError;
|
|
190
|
+
const iconName = isError ? 'warning' : 'checkmark-circle';
|
|
191
|
+
const iconColor = isError ? colors.error : colors.success;
|
|
192
|
+
const textColor = isError ? colors.error : colors.success;
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<View style={styles.validationContainer}>
|
|
196
|
+
<Icon name={iconName} size={16} color={iconColor} style={styles.validationIcon} />
|
|
197
|
+
<Text style={[styles.validationText, { color: textColor }]}>{message}</Text>
|
|
198
|
+
</View>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Render text input
|
|
203
|
+
const renderTextInput = () => (
|
|
204
|
+
<View style={[
|
|
205
|
+
styles.inputContainer,
|
|
206
|
+
getBorderStyle(),
|
|
207
|
+
!editable && !keepWhiteBackground && styles.disabledInputContainer,
|
|
208
|
+
containerStyle
|
|
209
|
+
]}>
|
|
210
|
+
{leftIcon && (
|
|
211
|
+
<Icon name={leftIcon} size={20} color={colors.textLight} style={styles.leftIcon} />
|
|
212
|
+
)}
|
|
213
|
+
<TextInput
|
|
214
|
+
ref={textInputRef}
|
|
215
|
+
style={[
|
|
216
|
+
styles.textInput,
|
|
217
|
+
!editable && styles.disabledTextInput,
|
|
218
|
+
inputStyle
|
|
219
|
+
]}
|
|
220
|
+
placeholder={placeholder}
|
|
221
|
+
placeholderTextColor={placeholderColor || (themeName === 'dark' ? colors.placeholderColor : 'rgba(0,32,34,0.2)')}
|
|
222
|
+
value={value}
|
|
223
|
+
onChangeText={handleTextChange}
|
|
224
|
+
onFocus={handleFocus}
|
|
225
|
+
onBlur={handleBlur}
|
|
226
|
+
editable={editable}
|
|
227
|
+
maxLength={maxLength}
|
|
228
|
+
multiline={multiline}
|
|
229
|
+
numberOfLines={numberOfLines}
|
|
230
|
+
secureTextEntry={secureTextEntry}
|
|
231
|
+
keyboardType={keyboardType}
|
|
232
|
+
autoCapitalize={autoCapitalize}
|
|
233
|
+
testID={testID}
|
|
234
|
+
textAlignVertical={multiline ? 'top' : 'center'}
|
|
235
|
+
returnKeyType={returnKeyType || (Platform.OS === 'ios' && (keyboardType === 'numeric' || variant === 'numeric') ? 'done' : 'default')}
|
|
236
|
+
blurOnSubmit={Platform.OS === 'ios'}
|
|
237
|
+
onSubmitEditing={onSubmitEditing}
|
|
238
|
+
/>
|
|
239
|
+
{rightIcon && (
|
|
240
|
+
<TouchableOpacity onPress={onRightIconPress} style={styles.rightIconContainer}>
|
|
241
|
+
<Icon name={rightIcon} size={20} color={colors.textLight} />
|
|
242
|
+
</TouchableOpacity>
|
|
243
|
+
)}
|
|
244
|
+
{success && !error && !internalError && (
|
|
245
|
+
<View style={styles.successIcon}>
|
|
246
|
+
<Icon name="checkmark" size={16} color="white" />
|
|
247
|
+
</View>
|
|
248
|
+
)}
|
|
249
|
+
</View>
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
// Render dropdown
|
|
253
|
+
const renderDropdown = () => (
|
|
254
|
+
<View style={[
|
|
255
|
+
styles.inputContainer,
|
|
256
|
+
getBorderStyle(),
|
|
257
|
+
!editable && !keepWhiteBackground && styles.disabledInputContainer,
|
|
258
|
+
containerStyle
|
|
259
|
+
]}>
|
|
260
|
+
<TouchableOpacity
|
|
261
|
+
style={styles.dropdownTouchable}
|
|
262
|
+
onPress={() => {
|
|
263
|
+
if (onDropdownToggle) {
|
|
264
|
+
onDropdownToggle();
|
|
265
|
+
} else {
|
|
266
|
+
setInternalDropdownOpen(!internalDropdownOpen);
|
|
267
|
+
}
|
|
268
|
+
}}
|
|
269
|
+
disabled={!editable}
|
|
270
|
+
>
|
|
271
|
+
<Text style={[
|
|
272
|
+
styles.dropdownText,
|
|
273
|
+
!value && [styles.placeholderText, placeholderColor ? { color: placeholderColor } : null],
|
|
274
|
+
!editable && styles.disabledTextInput
|
|
275
|
+
]}>
|
|
276
|
+
{value || placeholder}
|
|
277
|
+
</Text>
|
|
278
|
+
<Image
|
|
279
|
+
source={{ uri: base64Images.dropdown }}
|
|
280
|
+
style={[styles.icon, isDropdownOpenState ? { transform: [{ rotate: '180deg' }] } : null]}
|
|
281
|
+
resizeMode="contain"
|
|
282
|
+
/>
|
|
283
|
+
</TouchableOpacity>
|
|
284
|
+
{isDropdownOpenState && !onDropdownToggle && (
|
|
285
|
+
<View style={styles.dropdownOptions}>
|
|
286
|
+
{options.map((option) => (
|
|
287
|
+
<TouchableOpacity
|
|
288
|
+
key={option}
|
|
289
|
+
style={styles.dropdownOption}
|
|
290
|
+
onPress={() => {
|
|
291
|
+
onDropdownSelect?.(option);
|
|
292
|
+
onChangeText(option);
|
|
293
|
+
setInternalDropdownOpen(false);
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
<Text style={styles.dropdownOptionText}>{option}</Text>
|
|
297
|
+
</TouchableOpacity>
|
|
298
|
+
))}
|
|
299
|
+
</View>
|
|
300
|
+
)}
|
|
301
|
+
</View>
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
// Render date field
|
|
305
|
+
const renderDateField = () => (
|
|
306
|
+
<TouchableOpacity
|
|
307
|
+
style={[
|
|
308
|
+
styles.inputContainer,
|
|
309
|
+
getBorderStyle(),
|
|
310
|
+
!editable && !keepWhiteBackground && styles.disabledInputContainer,
|
|
311
|
+
containerStyle
|
|
312
|
+
]}
|
|
313
|
+
onPress={onDatePress ? onDatePress : undefined}
|
|
314
|
+
activeOpacity={onDatePress ? 0.7 : 1}
|
|
315
|
+
disabled={!onDatePress}
|
|
316
|
+
>
|
|
317
|
+
<TextInput
|
|
318
|
+
ref={textInputRef}
|
|
319
|
+
style={[
|
|
320
|
+
styles.textInput,
|
|
321
|
+
!editable && styles.disabledTextInput,
|
|
322
|
+
inputStyle
|
|
323
|
+
]}
|
|
324
|
+
placeholder={placeholder || dateFormat}
|
|
325
|
+
placeholderTextColor={placeholderColor || (themeName === 'dark' ? colors.placeholderColor : 'rgba(0,32,34,0.2)')}
|
|
326
|
+
value={value}
|
|
327
|
+
onChangeText={handleTextChange}
|
|
328
|
+
onFocus={handleFocus}
|
|
329
|
+
onBlur={handleBlur}
|
|
330
|
+
editable={editable}
|
|
331
|
+
maxLength={10}
|
|
332
|
+
keyboardType="numeric"
|
|
333
|
+
testID={testID}
|
|
334
|
+
returnKeyType={returnKeyType || (Platform.OS === 'ios' ? 'done' : 'default')}
|
|
335
|
+
blurOnSubmit={Platform.OS === 'ios'}
|
|
336
|
+
onSubmitEditing={onSubmitEditing}
|
|
337
|
+
pointerEvents="none"
|
|
338
|
+
/>
|
|
339
|
+
<View style={styles.dateIconContainer} pointerEvents="none">
|
|
340
|
+
<Image
|
|
341
|
+
source={{ uri: base64Images.calendar }}
|
|
342
|
+
style={styles.icon}
|
|
343
|
+
resizeMode="contain"
|
|
344
|
+
/>
|
|
345
|
+
</View>
|
|
346
|
+
</TouchableOpacity>
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
// Render appropriate input based on variant
|
|
350
|
+
const renderInput = () => {
|
|
351
|
+
switch (variant) {
|
|
352
|
+
case 'dropdown':
|
|
353
|
+
return renderDropdown();
|
|
354
|
+
case 'date':
|
|
355
|
+
return renderDateField();
|
|
356
|
+
case 'numeric':
|
|
357
|
+
return renderTextInput();
|
|
358
|
+
case 'email':
|
|
359
|
+
return renderTextInput();
|
|
360
|
+
case 'phone':
|
|
361
|
+
return renderTextInput();
|
|
362
|
+
default:
|
|
363
|
+
return renderTextInput();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<View style={styles.fieldContainer}>
|
|
369
|
+
{renderLabel()}
|
|
370
|
+
{renderInput()}
|
|
371
|
+
{renderValidationMessage()}
|
|
372
|
+
</View>
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
const createStyles = (colors: any, typography: any, themeName: string) => StyleSheet.create({
|
|
377
|
+
fieldContainer: {
|
|
378
|
+
marginBottom: 26,
|
|
379
|
+
},
|
|
380
|
+
label: {
|
|
381
|
+
fontSize: 12,
|
|
382
|
+
color: themeName === 'dark' ? colors.labelColor : colors.textLight,
|
|
383
|
+
marginBottom: 8,
|
|
384
|
+
fontWeight: '400',
|
|
385
|
+
},
|
|
386
|
+
requiredIndicator: {
|
|
387
|
+
color: colors.error,
|
|
388
|
+
},
|
|
389
|
+
inputContainer: {
|
|
390
|
+
flexDirection: 'row',
|
|
391
|
+
alignItems: 'center',
|
|
392
|
+
borderRadius: themeName === 'dark' ? 5 : 25,
|
|
393
|
+
backgroundColor: themeName === 'dark' ? colors.inputBackground : 'white',
|
|
394
|
+
minHeight: 50,
|
|
395
|
+
paddingHorizontal: 16,
|
|
396
|
+
position: 'relative',
|
|
397
|
+
borderWidth: themeName === 'dark' ? 1 : 0,
|
|
398
|
+
borderColor: themeName === 'dark' ? colors.inputBorder : 'transparent',
|
|
399
|
+
},
|
|
400
|
+
disabledInputContainer: {
|
|
401
|
+
backgroundColor: '#f5f5f5',
|
|
402
|
+
},
|
|
403
|
+
textInput: {
|
|
404
|
+
fontSize: 14,
|
|
405
|
+
color: colors.text,
|
|
406
|
+
fontWeight: '600',
|
|
407
|
+
flex: 1,
|
|
408
|
+
paddingVertical: 0,
|
|
409
|
+
height: '100%',
|
|
410
|
+
},
|
|
411
|
+
disabledTextInput: {
|
|
412
|
+
color: '#000000',
|
|
413
|
+
},
|
|
414
|
+
leftIcon: {
|
|
415
|
+
marginRight: 12,
|
|
416
|
+
},
|
|
417
|
+
rightIconContainer: {
|
|
418
|
+
marginLeft: 12,
|
|
419
|
+
padding: 4,
|
|
420
|
+
},
|
|
421
|
+
icon: {
|
|
422
|
+
width: 20,
|
|
423
|
+
height: 20,
|
|
424
|
+
tintColor: colors.textLight,
|
|
425
|
+
},
|
|
426
|
+
successIcon: {
|
|
427
|
+
position: 'absolute',
|
|
428
|
+
right: 16,
|
|
429
|
+
width: 16,
|
|
430
|
+
height: 16,
|
|
431
|
+
borderRadius: 8,
|
|
432
|
+
backgroundColor: colors.success,
|
|
433
|
+
alignItems: 'center',
|
|
434
|
+
justifyContent: 'center',
|
|
435
|
+
},
|
|
436
|
+
dropdownTouchable: {
|
|
437
|
+
flex: 1,
|
|
438
|
+
flexDirection: 'row',
|
|
439
|
+
alignItems: 'center',
|
|
440
|
+
justifyContent: 'space-between',
|
|
441
|
+
paddingVertical: 12,
|
|
442
|
+
},
|
|
443
|
+
dropdownText: {
|
|
444
|
+
fontSize: 14,
|
|
445
|
+
color: colors.text,
|
|
446
|
+
fontWeight: 'bold',
|
|
447
|
+
flex: 1,
|
|
448
|
+
},
|
|
449
|
+
placeholderText: {
|
|
450
|
+
color: themeName === 'dark' ? colors.placeholderColor : 'rgba(0,32,34,0.2)',
|
|
451
|
+
},
|
|
452
|
+
dropdownOptions: {
|
|
453
|
+
position: 'absolute',
|
|
454
|
+
top: '100%',
|
|
455
|
+
left: 0,
|
|
456
|
+
right: 0,
|
|
457
|
+
backgroundColor: themeName === 'dark' ? colors.inputBackground : 'white',
|
|
458
|
+
borderWidth: themeName === 'dark' ? 1 : 0.5,
|
|
459
|
+
borderColor: themeName === 'dark' ? '#ffffff' : colors.border,
|
|
460
|
+
borderRadius: 8,
|
|
461
|
+
marginTop: 4,
|
|
462
|
+
zIndex: 1000,
|
|
463
|
+
elevation: 5,
|
|
464
|
+
shadowColor: '#000',
|
|
465
|
+
shadowOffset: {
|
|
466
|
+
width: 0,
|
|
467
|
+
height: 2,
|
|
468
|
+
},
|
|
469
|
+
shadowOpacity: 0.1,
|
|
470
|
+
shadowRadius: 4,
|
|
471
|
+
},
|
|
472
|
+
dropdownOption: {
|
|
473
|
+
paddingHorizontal: 16,
|
|
474
|
+
paddingVertical: 12,
|
|
475
|
+
borderBottomWidth: 1,
|
|
476
|
+
borderBottomColor: colors.border,
|
|
477
|
+
},
|
|
478
|
+
dropdownOptionText: {
|
|
479
|
+
fontSize: 14,
|
|
480
|
+
color: colors.text,
|
|
481
|
+
fontWeight: 'bold',
|
|
482
|
+
},
|
|
483
|
+
dateIconContainer: {
|
|
484
|
+
marginLeft: 12,
|
|
485
|
+
padding: 4,
|
|
486
|
+
},
|
|
487
|
+
validationContainer: {
|
|
488
|
+
flexDirection: 'row',
|
|
489
|
+
alignItems: 'center',
|
|
490
|
+
marginTop: 8,
|
|
491
|
+
},
|
|
492
|
+
validationIcon: {
|
|
493
|
+
marginRight: 6,
|
|
494
|
+
},
|
|
495
|
+
validationText: {
|
|
496
|
+
...typography.styles.bodySmall,
|
|
497
|
+
fontWeight: '500',
|
|
498
|
+
flex: 1,
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
export default TextFieldWithLabel;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import { useColors, useTypography, useTheme } from '../theme/ThemeContext';
|
|
4
|
+
import { getBorderColor } from '../theme';
|
|
5
|
+
|
|
6
|
+
interface TrustBoxProps {
|
|
7
|
+
title1: string;
|
|
8
|
+
title2: string;
|
|
9
|
+
style?: object;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const TrustBox: React.FC<TrustBoxProps> = ({ title1, title2, style }) => {
|
|
13
|
+
const colors = useColors();
|
|
14
|
+
const typography = useTypography();
|
|
15
|
+
const { themeName } = useTheme();
|
|
16
|
+
const styles = createStyles(colors, typography, themeName);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<View style={[styles.container, style]}>
|
|
20
|
+
{/* <View style={styles.dot} /> */}
|
|
21
|
+
<View style={styles.textColumn}>
|
|
22
|
+
<Text style={styles.titleLight}>{title1}</Text>
|
|
23
|
+
<Text style={styles.title}>{title2}</Text>
|
|
24
|
+
</View>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const createStyles = (colors: any, typography: any, themeName: string) => StyleSheet.create({
|
|
30
|
+
container: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
backgroundColor: themeName === 'dark' ? colors.inputBackground : 'transparent',
|
|
33
|
+
padding: 8,
|
|
34
|
+
borderRadius: 5,
|
|
35
|
+
borderWidth: 0.5,
|
|
36
|
+
borderColor: themeName === 'dark' ? colors.inputBorder : getBorderColor({ colors } as any, 0.36),
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
},
|
|
40
|
+
dot: {
|
|
41
|
+
width: 32,
|
|
42
|
+
height: 32,
|
|
43
|
+
borderRadius: 25,
|
|
44
|
+
backgroundColor: themeName === 'dark' ? colors.background : 'rgba(0,235,180,0.1)',
|
|
45
|
+
marginRight: 10,
|
|
46
|
+
},
|
|
47
|
+
textColumn: {
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
flex: 1,
|
|
50
|
+
},
|
|
51
|
+
titleLight: {
|
|
52
|
+
...typography.styles.bodyMedium,
|
|
53
|
+
color: themeName === 'dark' ? '#C4CDD3' : colors.textLight,
|
|
54
|
+
marginBottom: 0,
|
|
55
|
+
},
|
|
56
|
+
title: {
|
|
57
|
+
...typography.styles.bodyMedium,
|
|
58
|
+
color: themeName === 'dark' ? colors.labelColor : colors.textLight,
|
|
59
|
+
marginBottom: 0,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export default TrustBox;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Alert } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface ValidationErrorAlertProps {
|
|
5
|
+
errors: string[];
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Show validation error alert with option to cancel FD booking
|
|
11
|
+
*/
|
|
12
|
+
export const showValidationErrorAlert = (errors: string[], onCancelFDBooking: () => void) => {
|
|
13
|
+
const errorMessage = errors.length > 0
|
|
14
|
+
? `The following required information is missing from the main app:\n\n${errors.join('\n')}\n\nPlease provide all required user information to proceed with FD booking.`
|
|
15
|
+
: 'Required user information is missing from the main app.';
|
|
16
|
+
|
|
17
|
+
Alert.alert(
|
|
18
|
+
'Cannot Proceed with FD Booking',
|
|
19
|
+
errorMessage,
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
text: 'Cancel FD Booking',
|
|
23
|
+
onPress: onCancelFDBooking,
|
|
24
|
+
style: 'cancel',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
{ cancelable: false }
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Utility function to validate and show error if needed
|
|
33
|
+
*/
|
|
34
|
+
export const validateAndProceed = (
|
|
35
|
+
appData: any,
|
|
36
|
+
requiredFields: Array<{ field: string; label: string }>,
|
|
37
|
+
onCancelFDBooking: () => void
|
|
38
|
+
): boolean => {
|
|
39
|
+
const missingFields: string[] = [];
|
|
40
|
+
|
|
41
|
+
requiredFields.forEach(({ field, label }) => {
|
|
42
|
+
const value = appData?.[field];
|
|
43
|
+
if (!value || (typeof value === 'string' && !value.trim())) {
|
|
44
|
+
missingFields.push(label);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (missingFields.length > 0) {
|
|
49
|
+
showValidationErrorAlert(missingFields, onCancelFDBooking);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default { showValidationErrorAlert, validateAndProceed };
|
|
57
|
+
|