@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,93 @@
|
|
|
1
|
+
declare module '@env' {
|
|
2
|
+
// Environment Configuration
|
|
3
|
+
export const REACT_APP_ENV: string;
|
|
4
|
+
export const NODE_ENV: string;
|
|
5
|
+
|
|
6
|
+
// API Configuration
|
|
7
|
+
export const REACT_APP_DEV_API_URL: string;
|
|
8
|
+
export const REACT_APP_STAGING_API_URL: string;
|
|
9
|
+
export const REACT_APP_PROD_API_URL: string;
|
|
10
|
+
export const SHRIRAM_DEV_API_KEY: string;
|
|
11
|
+
export const SHRIRAM_STAGING_API_KEY: string;
|
|
12
|
+
export const SHRIRAM_PROD_API_KEY: string;
|
|
13
|
+
export const SHRIRAM_API_TIMEOUT: string;
|
|
14
|
+
export const SHRIRAM_DEV_RETRY_ATTEMPTS: string;
|
|
15
|
+
export const SHRIRAM_STAGING_RETRY_ATTEMPTS: string;
|
|
16
|
+
export const SHRIRAM_PROD_RETRY_ATTEMPTS: string;
|
|
17
|
+
|
|
18
|
+
// Encryption Configuration
|
|
19
|
+
export const SHRIRAM_DEV_ENCRYPTION_KEY: string;
|
|
20
|
+
export const SHRIRAM_STAGING_ENCRYPTION_KEY: string;
|
|
21
|
+
export const SHRIRAM_ENCRYPTION_KEY: string;
|
|
22
|
+
export const REACT_APP_DEV_ENCRYPTION_KEY: string;
|
|
23
|
+
export const REACT_APP_STAGING_ENCRYPTION_KEY: string;
|
|
24
|
+
export const REACT_APP_ENCRYPTION_KEY: string;
|
|
25
|
+
export const DECRYPTION_TOKEN: string;
|
|
26
|
+
|
|
27
|
+
// SDK Configuration
|
|
28
|
+
export const SHRIRAM_SDK_VERSION: string;
|
|
29
|
+
export const SHRIRAM_CLIENT_VERSION: string;
|
|
30
|
+
|
|
31
|
+
// Financial Limits Configuration
|
|
32
|
+
export const SHRIRAM_MIN_DEPOSIT: string;
|
|
33
|
+
export const SHRIRAM_MAX_DEPOSIT: string;
|
|
34
|
+
export const SHRIRAM_MIN_TENURE: string;
|
|
35
|
+
export const SHRIRAM_DEPOSIT_MULTIPLE: string;
|
|
36
|
+
export const SHRIRAM_DEFAULT_INTEREST_RATE: string;
|
|
37
|
+
|
|
38
|
+
// UI Configuration
|
|
39
|
+
export const SHRIRAM_HEADER_HEIGHT: string;
|
|
40
|
+
export const SHRIRAM_CHECKBOX_SIZE: string;
|
|
41
|
+
export const SHRIRAM_STATUS_BAR_COLOR: string;
|
|
42
|
+
export const SHRIRAM_STATUS_BAR_STYLE: string;
|
|
43
|
+
|
|
44
|
+
// Security Configuration
|
|
45
|
+
export const SHRIRAM_ENABLE_ENCRYPTION_DEV: string;
|
|
46
|
+
export const SHRIRAM_ENABLE_ENCRYPTION_STAGING: string;
|
|
47
|
+
export const SHRIRAM_ENABLE_ENCRYPTION_PROD: string;
|
|
48
|
+
export const SHRIRAM_ALLOW_ENCRYPTION_TOGGLE_DEV: string;
|
|
49
|
+
export const SHRIRAM_ALLOW_ENCRYPTION_TOGGLE_STAGING: string;
|
|
50
|
+
export const SHRIRAM_ALLOW_ENCRYPTION_TOGGLE_PROD: string;
|
|
51
|
+
export const SHRIRAM_ENABLE_LOGGING_DEV: string;
|
|
52
|
+
export const SHRIRAM_ENABLE_LOGGING_STAGING: string;
|
|
53
|
+
export const SHRIRAM_ENABLE_LOGGING_PROD: string;
|
|
54
|
+
|
|
55
|
+
// Payment Configuration
|
|
56
|
+
export const SHRIRAM_PAYMENT_SUCCESS_URL: string;
|
|
57
|
+
export const SHRIRAM_PAYMENT_FAILURE_URL: string;
|
|
58
|
+
export const SHRIRAM_PAYMENT_STATUS_URL: string;
|
|
59
|
+
|
|
60
|
+
// Development Configuration
|
|
61
|
+
export const SHRIRAM_DEBUG_MODE: string;
|
|
62
|
+
export const SHRIRAM_VERBOSE_LOGGING: string;
|
|
63
|
+
export const SHRIRAM_ENABLE_HOT_RELOAD: string;
|
|
64
|
+
|
|
65
|
+
// Feature Flags
|
|
66
|
+
export const SHRIRAM_ENABLE_FD_CALCULATOR: string;
|
|
67
|
+
export const SHRIRAM_ENABLE_PAYMENT_GATEWAY: string;
|
|
68
|
+
export const SHRIRAM_ENABLE_KYC_VERIFICATION: string;
|
|
69
|
+
export const SHRIRAM_ENABLE_AADHAAR_VERIFICATION: string;
|
|
70
|
+
|
|
71
|
+
// Validation Configuration
|
|
72
|
+
export const SHRIRAM_PHONE_NUMBER_LENGTH: string;
|
|
73
|
+
export const SHRIRAM_PAN_NUMBER_LENGTH: string;
|
|
74
|
+
export const SHRIRAM_AADHAAR_NUMBER_LENGTH: string;
|
|
75
|
+
|
|
76
|
+
// Theme Configuration
|
|
77
|
+
export const SHRIRAM_DEFAULT_THEME: string;
|
|
78
|
+
export const SHRIRAM_PRIMARY_COLOR: string;
|
|
79
|
+
export const SHRIRAM_SECONDARY_COLOR: string;
|
|
80
|
+
export const SHRIRAM_SUCCESS_COLOR: string;
|
|
81
|
+
export const SHRIRAM_ERROR_COLOR: string;
|
|
82
|
+
export const SHRIRAM_WARNING_COLOR: string;
|
|
83
|
+
|
|
84
|
+
// Monitoring Configuration
|
|
85
|
+
export const SHRIRAM_PERFORMANCE_MONITORING: string;
|
|
86
|
+
export const SHRIRAM_ERROR_TRACKING: string;
|
|
87
|
+
export const SHRIRAM_ANALYTICS_TRACKING: string;
|
|
88
|
+
|
|
89
|
+
// Compliance Configuration
|
|
90
|
+
export const SHRIRAM_GDPR_COMPLIANCE: string;
|
|
91
|
+
export const SHRIRAM_DATA_RETENTION_DAYS: string;
|
|
92
|
+
export const SHRIRAM_AUDIT_LOGGING: string;
|
|
93
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WORKFLOW_STATES } from '../config/workflowConstants';
|
|
2
|
+
|
|
3
|
+
export type WorkflowStateSriram =
|
|
4
|
+
| typeof WORKFLOW_STATES.START
|
|
5
|
+
| typeof WORKFLOW_STATES.INITIATION
|
|
6
|
+
| typeof WORKFLOW_STATES.CREATE_FD
|
|
7
|
+
| typeof WORKFLOW_STATES.OCCUPATION
|
|
8
|
+
| typeof WORKFLOW_STATES.NOMINEE
|
|
9
|
+
| typeof WORKFLOW_STATES.BANK_DETAILS
|
|
10
|
+
| typeof WORKFLOW_STATES.KYC
|
|
11
|
+
| typeof WORKFLOW_STATES.PAYMENT
|
|
12
|
+
| typeof WORKFLOW_STATES.END;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// API Logging Utility for Shriram SDK
|
|
2
|
+
// Provides comprehensive logging for API requests, responses, and debugging
|
|
3
|
+
|
|
4
|
+
export interface LogConfig {
|
|
5
|
+
enableLogging: boolean;
|
|
6
|
+
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
7
|
+
logRequest: boolean;
|
|
8
|
+
logResponse: boolean;
|
|
9
|
+
logHeaders: boolean;
|
|
10
|
+
logBody: boolean;
|
|
11
|
+
logTiming: boolean;
|
|
12
|
+
maxBodyLength: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RequestLogData {
|
|
16
|
+
method: string;
|
|
17
|
+
url: string;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
headers: Record<string, string>;
|
|
20
|
+
body?: any;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
requestId: string;
|
|
23
|
+
isEncrypted: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ResponseLogData {
|
|
27
|
+
status: number;
|
|
28
|
+
statusText: string;
|
|
29
|
+
headers: Record<string, string>;
|
|
30
|
+
data?: any;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
requestId: string;
|
|
33
|
+
duration: number;
|
|
34
|
+
isEncrypted: boolean;
|
|
35
|
+
error?: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Default logging configuration
|
|
39
|
+
const DEFAULT_LOG_CONFIG: LogConfig = {
|
|
40
|
+
enableLogging: true,
|
|
41
|
+
logLevel: 'info',
|
|
42
|
+
logRequest: true,
|
|
43
|
+
logResponse: true,
|
|
44
|
+
logHeaders: true,
|
|
45
|
+
logBody: true,
|
|
46
|
+
logTiming: true,
|
|
47
|
+
maxBodyLength: 1000,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
class ApiLogger {
|
|
51
|
+
private config: LogConfig;
|
|
52
|
+
private requestStartTimes: Map<string, number> = new Map();
|
|
53
|
+
|
|
54
|
+
constructor(config: Partial<LogConfig> = {}) {
|
|
55
|
+
this.config = { ...DEFAULT_LOG_CONFIG, ...config };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Update logging configuration
|
|
59
|
+
updateConfig(newConfig: Partial<LogConfig>): void {
|
|
60
|
+
this.config = { ...this.config, ...newConfig };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Log API request
|
|
64
|
+
logRequest(data: RequestLogData): void {
|
|
65
|
+
if (!this.config.enableLogging || !this.config.logRequest) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { method, url, baseUrl, headers, body, timestamp, requestId, isEncrypted } = data;
|
|
70
|
+
|
|
71
|
+
// Store start time for duration calculation
|
|
72
|
+
this.requestStartTimes.set(requestId, timestamp);
|
|
73
|
+
|
|
74
|
+
// API request logging removed for security
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Log API response
|
|
78
|
+
logResponse(data: ResponseLogData): void {
|
|
79
|
+
if (!this.config.enableLogging || !this.config.logResponse) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { status, statusText, headers, data: responseData, timestamp, requestId, duration, isEncrypted, error } = data;
|
|
84
|
+
|
|
85
|
+
// Remove start time
|
|
86
|
+
this.requestStartTimes.delete(requestId);
|
|
87
|
+
|
|
88
|
+
const isSuccess = status >= 200 && status < 300;
|
|
89
|
+
const logMethod = isSuccess ? 'log' : 'error';
|
|
90
|
+
|
|
91
|
+
// API response logging removed for security
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Log API error
|
|
95
|
+
logError(error: any, requestId: string, url: string): void {
|
|
96
|
+
if (!this.config.enableLogging) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const startTime = this.requestStartTimes.get(requestId);
|
|
101
|
+
const duration = startTime ? Date.now() - startTime : 0;
|
|
102
|
+
|
|
103
|
+
// Remove start time
|
|
104
|
+
this.requestStartTimes.delete(requestId);
|
|
105
|
+
|
|
106
|
+
// API error logging removed for security
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Calculate request duration
|
|
110
|
+
getRequestDuration(requestId: string): number {
|
|
111
|
+
const startTime = this.requestStartTimes.get(requestId);
|
|
112
|
+
return startTime ? Date.now() - startTime : 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Sanitize headers for logging (remove sensitive data)
|
|
116
|
+
private sanitizeHeaders(headers: Record<string, string>): Record<string, string> {
|
|
117
|
+
const sensitiveHeaders = ['authorization', 'x-api-key', 'x-auth-token', 'cookie'];
|
|
118
|
+
const sanitized = { ...headers };
|
|
119
|
+
|
|
120
|
+
sensitiveHeaders.forEach(header => {
|
|
121
|
+
if (sanitized[header]) {
|
|
122
|
+
sanitized[header] = '***REDACTED***';
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return sanitized;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Sanitize body for logging (truncate if too long)
|
|
130
|
+
private sanitizeBody(body: any): any {
|
|
131
|
+
if (!body) return body;
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const bodyStr = typeof body === 'string' ? body : JSON.stringify(body, null, 2);
|
|
135
|
+
|
|
136
|
+
if (bodyStr.length > this.config.maxBodyLength) {
|
|
137
|
+
return bodyStr.substring(0, this.config.maxBodyLength) + '... [TRUNCATED]';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return typeof body === 'string' ? JSON.parse(bodyStr) : body;
|
|
141
|
+
} catch {
|
|
142
|
+
return '[UNPARSEABLE BODY]';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Log configuration summary
|
|
147
|
+
logConfig(): void {
|
|
148
|
+
if (!this.config.enableLogging) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Configuration logging removed for security
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Clear all stored request times
|
|
156
|
+
clearRequestTimes(): void {
|
|
157
|
+
this.requestStartTimes.clear();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Create singleton instance
|
|
162
|
+
export const apiLogger = new ApiLogger();
|
|
163
|
+
|
|
164
|
+
// Export types and utilities
|
|
165
|
+
export { ApiLogger };
|
|
166
|
+
export default apiLogger;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// encryption.ts
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
|
|
4
|
+
// Polyfill for react-native-quick-crypto
|
|
5
|
+
const g = global as any;
|
|
6
|
+
if (typeof g.Buffer === 'undefined') {
|
|
7
|
+
g.Buffer = Buffer;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof g.base64FromArrayBuffer === 'undefined') {
|
|
11
|
+
g.base64FromArrayBuffer = (data: ArrayBuffer) => {
|
|
12
|
+
return Buffer.from(data).toString('base64');
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const crypto = require('react-native-quick-crypto');
|
|
17
|
+
|
|
18
|
+
export default class CryptoUtils {
|
|
19
|
+
private static readonly SALT_LEN = 16;
|
|
20
|
+
private static readonly IV_LEN = 12;
|
|
21
|
+
private static readonly AUTH_TAG_LEN = 16;
|
|
22
|
+
private static readonly ITERATIONS = 100000;
|
|
23
|
+
private static readonly KEY_LEN = 32;
|
|
24
|
+
private static readonly MAX_CACHE = 10;
|
|
25
|
+
|
|
26
|
+
private static keyCache = new Map<string, Buffer>();
|
|
27
|
+
|
|
28
|
+
static async encryptJSONCompact(
|
|
29
|
+
json: Record<string, any>,
|
|
30
|
+
password: string,
|
|
31
|
+
): Promise<string> {
|
|
32
|
+
try {
|
|
33
|
+
const jsonString = JSON.stringify(json);
|
|
34
|
+
const plaintext = Buffer.from(jsonString, 'utf8');
|
|
35
|
+
|
|
36
|
+
const salt = this.generateSalt();
|
|
37
|
+
const iv = this.generateIV();
|
|
38
|
+
const key = this.deriveKey(password, salt);
|
|
39
|
+
|
|
40
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
41
|
+
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
42
|
+
const authTag = cipher.getAuthTag();
|
|
43
|
+
|
|
44
|
+
const packed = Buffer.concat([salt, iv, authTag, encrypted]);
|
|
45
|
+
return packed.toString('base64');
|
|
46
|
+
} catch (e) {
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static async decryptJSONCompact(
|
|
52
|
+
compactBase64: string,
|
|
53
|
+
password: string,
|
|
54
|
+
): Promise<Record<string, any>> {
|
|
55
|
+
try {
|
|
56
|
+
const all = Buffer.from(compactBase64, 'base64');
|
|
57
|
+
|
|
58
|
+
if (all.length < this.SALT_LEN + this.IV_LEN + this.AUTH_TAG_LEN) {
|
|
59
|
+
throw new Error('Invalid compact payload');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const salt = all.slice(0, this.SALT_LEN);
|
|
63
|
+
const iv = all.slice(this.SALT_LEN, this.SALT_LEN + this.IV_LEN);
|
|
64
|
+
const authTag = all.slice(
|
|
65
|
+
this.SALT_LEN + this.IV_LEN,
|
|
66
|
+
this.SALT_LEN + this.IV_LEN + this.AUTH_TAG_LEN,
|
|
67
|
+
);
|
|
68
|
+
const cipherBytes = all.slice(this.SALT_LEN + this.IV_LEN + this.AUTH_TAG_LEN);
|
|
69
|
+
|
|
70
|
+
const key = this.deriveKey(password, salt);
|
|
71
|
+
|
|
72
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
|
|
73
|
+
decipher.setAuthTag(authTag);
|
|
74
|
+
|
|
75
|
+
const decrypted = Buffer.concat([
|
|
76
|
+
decipher.update(cipherBytes),
|
|
77
|
+
decipher.final(),
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
const jsonString = decrypted.toString('utf8');
|
|
81
|
+
return JSON.parse(jsonString);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
throw e;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private static deriveKey(password: string, salt: Buffer): Buffer {
|
|
88
|
+
const cacheKey = `${password}_${salt.toString('base64')}`;
|
|
89
|
+
|
|
90
|
+
const cached = this.keyCache.get(cacheKey);
|
|
91
|
+
if (cached) return cached;
|
|
92
|
+
|
|
93
|
+
const key = crypto.pbkdf2Sync(
|
|
94
|
+
password,
|
|
95
|
+
salt,
|
|
96
|
+
this.ITERATIONS,
|
|
97
|
+
this.KEY_LEN,
|
|
98
|
+
'sha256',
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (this.keyCache.size >= this.MAX_CACHE) this.keyCache.clear();
|
|
102
|
+
this.keyCache.set(cacheKey, key);
|
|
103
|
+
|
|
104
|
+
return key;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private static generateSalt(): Buffer {
|
|
108
|
+
return crypto.randomBytes(this.SALT_LEN);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private static generateIV(): Buffer {
|
|
112
|
+
return crypto.randomBytes(this.IV_LEN);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static async encrypt(
|
|
116
|
+
data: Record<string, any>,
|
|
117
|
+
passphrase: string,
|
|
118
|
+
): Promise<string> {
|
|
119
|
+
return this.encryptJSONCompact(data, passphrase);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static async decrypt(
|
|
123
|
+
encryptedBase64: string,
|
|
124
|
+
passphrase: string,
|
|
125
|
+
): Promise<string> {
|
|
126
|
+
const result = await this.decryptJSONCompact(encryptedBase64, passphrase);
|
|
127
|
+
return JSON.stringify(result);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Legacy named exports for backward compatibility
|
|
132
|
+
export const ENCRYPTION_KEY = '60913a3b628a29ac9fdd2147e69d013135ce8be5b26d2ee5ec5e905838fcfa78';
|
|
133
|
+
|
|
134
|
+
export interface EncryptionConfig {
|
|
135
|
+
secretKey: string;
|
|
136
|
+
algorithm?: string;
|
|
137
|
+
ivLength?: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const encryptJSONCompact = (data: Record<string, any>, password: string = ENCRYPTION_KEY) =>
|
|
141
|
+
CryptoUtils.encryptJSONCompact(data, password);
|
|
142
|
+
|
|
143
|
+
export const decryptJSONCompact = (compactBase64: string, password: string = ENCRYPTION_KEY) =>
|
|
144
|
+
CryptoUtils.decryptJSONCompact(compactBase64, password);
|
|
145
|
+
|
|
146
|
+
export const encryptRequest = async (payload: any, config?: EncryptionConfig) => ({
|
|
147
|
+
encryptedRequest: await CryptoUtils.encryptJSONCompact(payload, config?.secretKey || ENCRYPTION_KEY),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const decryptResponse = async (response: any, config?: EncryptionConfig) => {
|
|
151
|
+
if (response?.encryptedResponse) {
|
|
152
|
+
try {
|
|
153
|
+
return await CryptoUtils.decryptJSONCompact(response.encryptedResponse, config?.secretKey || ENCRYPTION_KEY);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return response;
|
|
159
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get FD Data Utility
|
|
3
|
+
*
|
|
4
|
+
* This function can be called from the main app to retrieve currently booked FD details
|
|
5
|
+
* by calling the customer webhook applications API with completed status filter.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getUserInfoForAPI } from '../config/appDataConfig';
|
|
9
|
+
import { store } from '../store';
|
|
10
|
+
import { customerApi } from '../api/customerApi';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Response structure returned to main app
|
|
14
|
+
*/
|
|
15
|
+
export interface FDDataResponse {
|
|
16
|
+
|
|
17
|
+
// All applications from API
|
|
18
|
+
allApplications: any[];
|
|
19
|
+
// Currently booked FD (matched by applicationId or most recent)
|
|
20
|
+
success: boolean;
|
|
21
|
+
// Error message if any
|
|
22
|
+
error?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get FD data by calling customer webhook applications API and return response to main app
|
|
27
|
+
* Only returns applications with wfStatus='Completed'
|
|
28
|
+
*
|
|
29
|
+
* @param userReferenceId - User reference ID from main app. If not provided, will try to get from SDK's internal state.
|
|
30
|
+
* @param applicationId - Optional application ID to find specific FD. If not provided, returns most recent FD.
|
|
31
|
+
* @returns Promise that resolves to FDDataResponse containing completed applications only
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { getFDData } from '@finspringinnovations/shriramsdk';
|
|
36
|
+
*
|
|
37
|
+
* // Get FD data with user reference ID from main app
|
|
38
|
+
* const result = await getFDData('USER123');
|
|
39
|
+
* if (result.success) {
|
|
40
|
+
* // Access full API response
|
|
41
|
+
* const apiResponse = result.apiResponse;
|
|
42
|
+
* const allApplications = result.allApplications;
|
|
43
|
+
* const bookedFD = result.bookedFD;
|
|
44
|
+
* const fdAmount = result.bookedFD?.amount;
|
|
45
|
+
* const applicationId = result.bookedFD?.applicationId;
|
|
46
|
+
* } else {
|
|
47
|
+
* // Handle error
|
|
48
|
+
* const errorMessage = result.error;
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* // Get specific FD by application ID
|
|
52
|
+
* const specificFD = await getFDData('USER123', 'APP123456');
|
|
53
|
+
*
|
|
54
|
+
* // Without userReferenceId (will use SDK's internal state)
|
|
55
|
+
* const resultWithoutUserRef = await getFDData();
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const getFDData = async (userReferenceId?: string, applicationId?: string): Promise<FDDataResponse> => {
|
|
59
|
+
try {
|
|
60
|
+
// Get user reference ID - use provided parameter or fallback to SDK's internal state
|
|
61
|
+
let finalUserReferenceId: string;
|
|
62
|
+
|
|
63
|
+
if (userReferenceId) {
|
|
64
|
+
// Use userReferenceId provided by main app
|
|
65
|
+
finalUserReferenceId = userReferenceId;
|
|
66
|
+
} else {
|
|
67
|
+
// Fallback to getting from SDK's internal state
|
|
68
|
+
try {
|
|
69
|
+
const userInfo = getUserInfoForAPI();
|
|
70
|
+
finalUserReferenceId = userInfo.id;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return {
|
|
73
|
+
allApplications: [],
|
|
74
|
+
success: false,
|
|
75
|
+
error: 'User reference ID is required. Please provide userReferenceId parameter or initialize SDK first.',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ✅ CRITICAL: Use SDK store directly to ensure we always use SDK's store
|
|
81
|
+
// This prevents conflicts with parent app's store
|
|
82
|
+
if (!store) {
|
|
83
|
+
return {
|
|
84
|
+
allApplications: [],
|
|
85
|
+
success: false,
|
|
86
|
+
error: 'SDK store is not initialized. Please ensure SDK is properly set up.',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Call webhook API to get customer applications with completed status
|
|
91
|
+
const apiResponse = await store.dispatch(
|
|
92
|
+
customerApi.endpoints.getCustomerWebhookApplications.initiate({
|
|
93
|
+
userReferenceId: finalUserReferenceId,
|
|
94
|
+
wfStatus: 'Completed'
|
|
95
|
+
})
|
|
96
|
+
).unwrap();
|
|
97
|
+
|
|
98
|
+
// Extract applications from response (handle different response structures)
|
|
99
|
+
// Note: API already filters by wfStatus='Completed'
|
|
100
|
+
let applications: any[] = [];
|
|
101
|
+
if (Array.isArray(apiResponse)) {
|
|
102
|
+
applications = apiResponse;
|
|
103
|
+
} else if (apiResponse?.data && Array.isArray(apiResponse.data)) {
|
|
104
|
+
applications = apiResponse.data;
|
|
105
|
+
} else if (apiResponse?.applications && Array.isArray(apiResponse.applications)) {
|
|
106
|
+
applications = apiResponse.applications;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Map to only include specified fields
|
|
110
|
+
applications = applications.map((app: any) => ({
|
|
111
|
+
application_id: app?.application_id || app?.applicationId,
|
|
112
|
+
investment_amount: app?.investment_amount || app?.investmentAmount,
|
|
113
|
+
interest_rate: app?.interest_rate || app?.interestRate,
|
|
114
|
+
maturity_date: app?.maturity_date || app?.maturityDate,
|
|
115
|
+
maturity_amount: app?.maturity_amount || app?.maturityAmount,
|
|
116
|
+
interest_payout_term: app?.interest_payout_term || app?.interestPayoutTerm,
|
|
117
|
+
tenure_in_months: app?.tenure_in_months || app?.tenureInMonths,
|
|
118
|
+
transaction_id: app?.transaction_id || app?.transactionId,
|
|
119
|
+
fd_provider_id: app?.fd_provider_id || app?.fdProviderId,
|
|
120
|
+
fd_provider_name: app?.fd_provider_name || app?.fdProviderName,
|
|
121
|
+
transaction_status: app?.transaction_status || app?.transactionStatus,
|
|
122
|
+
transaction_description: app?.transaction_description || app?.transactionDescription,
|
|
123
|
+
wf_status: app?.wf_status || app?.wfStatus,
|
|
124
|
+
created_date: app?.created_date || app?.createdDate,
|
|
125
|
+
certificate_status: app?.certificate_status || app?.certificateStatus,
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
// Find the FD - match by applicationId or get the most recent one
|
|
129
|
+
let bookedFD: any = null;
|
|
130
|
+
|
|
131
|
+
if (applicationId) {
|
|
132
|
+
// Try to find FD matching the provided applicationId
|
|
133
|
+
bookedFD = applications.find((app: any) =>
|
|
134
|
+
app?.application_id === applicationId
|
|
135
|
+
);
|
|
136
|
+
} else {
|
|
137
|
+
// Get applicationId from Redux store if available
|
|
138
|
+
const state = store.getState() as any;
|
|
139
|
+
const storeApplicationId = state?.onboarding?.applicationId;
|
|
140
|
+
|
|
141
|
+
if (storeApplicationId) {
|
|
142
|
+
// Try to find FD matching the current applicationId from store
|
|
143
|
+
bookedFD = applications.find((app: any) =>
|
|
144
|
+
app?.application_id === storeApplicationId
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// If not found by applicationId, get the most recent one (assuming it's the latest booking)
|
|
150
|
+
if (!bookedFD && applications.length > 0) {
|
|
151
|
+
// Sort by date if available, otherwise take the last one
|
|
152
|
+
const sortedApps = [...applications].sort((a: any, b: any) => {
|
|
153
|
+
const dateA = a?.created_date || 0;
|
|
154
|
+
const dateB = b?.created_date || 0;
|
|
155
|
+
return new Date(dateB).getTime() - new Date(dateA).getTime();
|
|
156
|
+
});
|
|
157
|
+
bookedFD = sortedApps[0];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Return full API response data to main app
|
|
161
|
+
return {
|
|
162
|
+
// Full API response
|
|
163
|
+
allApplications: applications, // All applications array
|
|
164
|
+
success: true,
|
|
165
|
+
};
|
|
166
|
+
} catch (error: any) {
|
|
167
|
+
// If API call fails, return error information
|
|
168
|
+
return {
|
|
169
|
+
allApplications: [],
|
|
170
|
+
success: false,
|
|
171
|
+
error: error?.message || 'Failed to fetch FD data',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|