@finspringinnovations/fixeddepositsdk 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.
Files changed (311) hide show
  1. package/README.md +128 -0
  2. package/lib/api/applicationApi.d.ts +1 -0
  3. package/lib/api/applicationApi.js +11 -0
  4. package/lib/api/bankApi.d.ts +352 -0
  5. package/lib/api/bankApi.js +54 -0
  6. package/lib/api/baseApi.d.ts +6 -0
  7. package/lib/api/baseApi.js +406 -0
  8. package/lib/api/customerApi.d.ts +855 -0
  9. package/lib/api/customerApi.js +241 -0
  10. package/lib/api/fdApi.d.ts +979 -0
  11. package/lib/api/fdApi.js +112 -0
  12. package/lib/api/fdCalculatorApi.d.ts +179 -0
  13. package/lib/api/fdCalculatorApi.js +36 -0
  14. package/lib/api/index.d.ts +14 -0
  15. package/lib/api/index.js +45 -0
  16. package/lib/api/interestRateApi.d.ts +585 -0
  17. package/lib/api/interestRateApi.js +101 -0
  18. package/lib/api/kycApi.d.ts +486 -0
  19. package/lib/api/kycApi.js +71 -0
  20. package/lib/api/masterDataApi.d.ts +158 -0
  21. package/lib/api/masterDataApi.js +35 -0
  22. package/lib/api/nomineeApi.d.ts +325 -0
  23. package/lib/api/nomineeApi.js +46 -0
  24. package/lib/api/onboardingApi.d.ts +192 -0
  25. package/lib/api/onboardingApi.js +41 -0
  26. package/lib/api/panApi.d.ts +0 -0
  27. package/lib/api/panApi.js +23 -0
  28. package/lib/api/paymentApi.d.ts +325 -0
  29. package/lib/api/paymentApi.js +46 -0
  30. package/lib/api/workflowApi.d.ts +654 -0
  31. package/lib/api/workflowApi.js +90 -0
  32. package/lib/assets/images/images.d.ts +6 -0
  33. package/lib/assets/images/images.js +12 -0
  34. package/lib/components/AadhaarInput.d.ts +13 -0
  35. package/lib/components/AadhaarInput.js +47 -0
  36. package/lib/components/ActionButton.d.ts +12 -0
  37. package/lib/components/ActionButton.js +87 -0
  38. package/lib/components/ActiveFDCard.d.ts +18 -0
  39. package/lib/components/ActiveFDCard.js +116 -0
  40. package/lib/components/AmountInput.d.ts +20 -0
  41. package/lib/components/AmountInput.js +142 -0
  42. package/lib/components/CheckboxOption.d.ts +11 -0
  43. package/lib/components/CheckboxOption.js +41 -0
  44. package/lib/components/CompanyHeader.d.ts +7 -0
  45. package/lib/components/CompanyHeader.js +59 -0
  46. package/lib/components/DropdownSelector.d.ts +9 -0
  47. package/lib/components/DropdownSelector.js +49 -0
  48. package/lib/components/EmptyState.d.ts +17 -0
  49. package/lib/components/EmptyState.js +44 -0
  50. package/lib/components/ErrorDisplay.d.ts +17 -0
  51. package/lib/components/ErrorDisplay.js +69 -0
  52. package/lib/components/FAQItem.d.ts +9 -0
  53. package/lib/components/FAQItem.js +52 -0
  54. package/lib/components/FDCard.d.ts +23 -0
  55. package/lib/components/FDCard.js +116 -0
  56. package/lib/components/FormDropdown.d.ts +18 -0
  57. package/lib/components/FormDropdown.js +155 -0
  58. package/lib/components/FormSection.d.ts +14 -0
  59. package/lib/components/FormSection.js +38 -0
  60. package/lib/components/Header.d.ts +14 -0
  61. package/lib/components/Header.js +52 -0
  62. package/lib/components/IFSCSearchResultCard.d.ts +13 -0
  63. package/lib/components/IFSCSearchResultCard.js +70 -0
  64. package/lib/components/InfoBox.d.ts +8 -0
  65. package/lib/components/InfoBox.js +39 -0
  66. package/lib/components/InterestRateCard.d.ts +8 -0
  67. package/lib/components/InterestRateCard.js +46 -0
  68. package/lib/components/LoadingIndicator.d.ts +12 -0
  69. package/lib/components/LoadingIndicator.js +30 -0
  70. package/lib/components/OTPInput.d.ts +17 -0
  71. package/lib/components/OTPInput.js +144 -0
  72. package/lib/components/PaymentDetailsCard.d.ts +20 -0
  73. package/lib/components/PaymentDetailsCard.js +68 -0
  74. package/lib/components/PendingFDBottomSheet.d.ts +19 -0
  75. package/lib/components/PendingFDBottomSheet.js +122 -0
  76. package/lib/components/SafeAreaWrapper.d.ts +13 -0
  77. package/lib/components/SafeAreaWrapper.js +41 -0
  78. package/lib/components/ScreenHeader.d.ts +11 -0
  79. package/lib/components/ScreenHeader.js +46 -0
  80. package/lib/components/StatusDisplay.d.ts +15 -0
  81. package/lib/components/StatusDisplay.js +88 -0
  82. package/lib/components/TextFieldWithLabel.d.ts +46 -0
  83. package/lib/components/TextFieldWithLabel.js +326 -0
  84. package/lib/components/TrustBox.d.ts +8 -0
  85. package/lib/components/TrustBox.js +46 -0
  86. package/lib/components/ValidationErrorAlert.d.ts +23 -0
  87. package/lib/components/ValidationErrorAlert.js +39 -0
  88. package/lib/components/ValidationMessage.d.ts +9 -0
  89. package/lib/components/ValidationMessage.js +98 -0
  90. package/lib/components/index.d.ts +35 -0
  91. package/lib/components/index.js +64 -0
  92. package/lib/config/apiConfig.d.ts +34 -0
  93. package/lib/config/apiConfig.js +158 -0
  94. package/lib/config/appDataConfig.d.ts +159 -0
  95. package/lib/config/appDataConfig.js +310 -0
  96. package/lib/config/encryptionConfig.d.ts +21 -0
  97. package/lib/config/encryptionConfig.js +61 -0
  98. package/lib/config/workflowConstants.d.ts +62 -0
  99. package/lib/config/workflowConstants.js +63 -0
  100. package/lib/constants/strings/bank.d.ts +72 -0
  101. package/lib/constants/strings/bank.js +86 -0
  102. package/lib/constants/strings/base64Images.d.ts +26 -0
  103. package/lib/constants/strings/base64Images.js +29 -0
  104. package/lib/constants/strings/common.d.ts +53 -0
  105. package/lib/constants/strings/common.js +62 -0
  106. package/lib/constants/strings/employee.d.ts +61 -0
  107. package/lib/constants/strings/employee.js +77 -0
  108. package/lib/constants/strings/faq.d.ts +14 -0
  109. package/lib/constants/strings/faq.js +20 -0
  110. package/lib/constants/strings/fd.d.ts +122 -0
  111. package/lib/constants/strings/fd.js +151 -0
  112. package/lib/constants/strings/home.d.ts +49 -0
  113. package/lib/constants/strings/home.js +62 -0
  114. package/lib/constants/strings/index.d.ts +16 -0
  115. package/lib/constants/strings/index.js +44 -0
  116. package/lib/constants/strings/kyc.d.ts +80 -0
  117. package/lib/constants/strings/kyc.js +94 -0
  118. package/lib/constants/strings/nominee.d.ts +64 -0
  119. package/lib/constants/strings/nominee.js +81 -0
  120. package/lib/hooks/useAuth.d.ts +25 -0
  121. package/lib/hooks/useAuth.js +39 -0
  122. package/lib/hooks/useFDData.d.ts +11 -0
  123. package/lib/hooks/useFDData.js +40 -0
  124. package/lib/index.d.ts +48 -0
  125. package/lib/index.js +161 -0
  126. package/lib/navigation/RootNavigator.d.ts +9 -0
  127. package/lib/navigation/RootNavigator.js +459 -0
  128. package/lib/navigation/SimpleNavigator.d.ts +11 -0
  129. package/lib/navigation/SimpleNavigator.js +114 -0
  130. package/lib/navigation/helpers.d.ts +11 -0
  131. package/lib/navigation/helpers.js +83 -0
  132. package/lib/navigation/index.d.ts +17 -0
  133. package/lib/navigation/index.js +42 -0
  134. package/lib/navigation/types.d.ts +139 -0
  135. package/lib/navigation/types.js +2 -0
  136. package/lib/navigation/workflowNavigator.d.ts +22 -0
  137. package/lib/navigation/workflowNavigator.js +104 -0
  138. package/lib/providers/ApiProvider.d.ts +7 -0
  139. package/lib/providers/ApiProvider.js +16 -0
  140. package/lib/providers/MasterDataProvider.d.ts +10 -0
  141. package/lib/providers/MasterDataProvider.js +54 -0
  142. package/lib/screens/AadhaarVerification.d.ts +7 -0
  143. package/lib/screens/AadhaarVerification.js +627 -0
  144. package/lib/screens/AddBankAccount.d.ts +22 -0
  145. package/lib/screens/AddBankAccount.js +381 -0
  146. package/lib/screens/BankDetail.d.ts +16 -0
  147. package/lib/screens/BankDetail.js +596 -0
  148. package/lib/screens/Employee.d.ts +18 -0
  149. package/lib/screens/Employee.js +594 -0
  150. package/lib/screens/FDCalculator.d.ts +18 -0
  151. package/lib/screens/FDCalculator.js +767 -0
  152. package/lib/screens/FDList.d.ts +28 -0
  153. package/lib/screens/FDList.js +1853 -0
  154. package/lib/screens/FindIFSC.d.ts +16 -0
  155. package/lib/screens/FindIFSC.js +248 -0
  156. package/lib/screens/NomineeDetail.d.ts +17 -0
  157. package/lib/screens/NomineeDetail.js +592 -0
  158. package/lib/screens/PayNow.d.ts +14 -0
  159. package/lib/screens/PayNow.js +230 -0
  160. package/lib/screens/Payment.d.ts +11 -0
  161. package/lib/screens/Payment.js +191 -0
  162. package/lib/screens/PaymentStatus.d.ts +16 -0
  163. package/lib/screens/PaymentStatus.js +431 -0
  164. package/lib/screens/ReviewKYC.d.ts +23 -0
  165. package/lib/screens/ReviewKYC.js +727 -0
  166. package/lib/state/paymentSession.d.ts +8 -0
  167. package/lib/state/paymentSession.js +13 -0
  168. package/lib/store/fdListSelectedSlice.d.ts +21 -0
  169. package/lib/store/fdListSelectedSlice.js +26 -0
  170. package/lib/store/hooks.d.ts +8 -0
  171. package/lib/store/hooks.js +8 -0
  172. package/lib/store/index.d.ts +3 -0
  173. package/lib/store/index.js +8 -0
  174. package/lib/store/onboardingSlice.d.ts +12 -0
  175. package/lib/store/onboardingSlice.js +32 -0
  176. package/lib/store/store.d.ts +13 -0
  177. package/lib/store/store.js +27 -0
  178. package/lib/theme/ThemeContext.d.ts +210 -0
  179. package/lib/theme/ThemeContext.js +92 -0
  180. package/lib/theme/colors.d.ts +80 -0
  181. package/lib/theme/colors.js +85 -0
  182. package/lib/theme/index.d.ts +35 -0
  183. package/lib/theme/index.js +78 -0
  184. package/lib/theme/shadows.d.ts +53 -0
  185. package/lib/theme/shadows.js +58 -0
  186. package/lib/theme/typography.d.ts +134 -0
  187. package/lib/theme/typography.js +143 -0
  188. package/lib/types/dataTypes.d.ts +34 -0
  189. package/lib/types/dataTypes.js +2 -0
  190. package/lib/types/workflowTypes.d.ts +2 -0
  191. package/lib/types/workflowTypes.js +2 -0
  192. package/lib/utils/apiLogger.d.ts +48 -0
  193. package/lib/utils/apiLogger.js +105 -0
  194. package/lib/utils/encryption.d.ts +28 -0
  195. package/lib/utils/encryption.js +113 -0
  196. package/lib/utils/getFDData.d.ts +48 -0
  197. package/lib/utils/getFDData.js +145 -0
  198. package/lib/utils/globalData.d.ts +2 -0
  199. package/lib/utils/globalData.js +10 -0
  200. package/package.json +51 -0
  201. package/src/api/applicationApi.ts +12 -0
  202. package/src/api/bankApi.ts +42 -0
  203. package/src/api/baseApi.ts +463 -0
  204. package/src/api/customerApi.ts +324 -0
  205. package/src/api/fdApi.ts +150 -0
  206. package/src/api/fdCalculatorApi.ts +41 -0
  207. package/src/api/index.ts +29 -0
  208. package/src/api/interestRateApi.ts +143 -0
  209. package/src/api/kycApi.ts +63 -0
  210. package/src/api/masterDataApi.ts +37 -0
  211. package/src/api/nomineeApi.ts +34 -0
  212. package/src/api/onboardingApi.ts +64 -0
  213. package/src/api/panApi.ts +25 -0
  214. package/src/api/paymentApi.ts +34 -0
  215. package/src/api/workflowApi.ts +94 -0
  216. package/src/assets/images/Mahindra.png +0 -0
  217. package/src/assets/images/arrow-filled.png +0 -0
  218. package/src/assets/images/arrow-left.png +0 -0
  219. package/src/assets/images/backicon.png +0 -0
  220. package/src/assets/images/calendar.png +0 -0
  221. package/src/assets/images/chevron-down.png +0 -0
  222. package/src/assets/images/chevron-down@2x.png +0 -0
  223. package/src/assets/images/chevron-down@3x.png +0 -0
  224. package/src/assets/images/images.js +10 -0
  225. package/src/assets/images/shriram_logo.png +0 -0
  226. package/src/components/AadhaarInput.tsx +91 -0
  227. package/src/components/ActionButton.tsx +129 -0
  228. package/src/components/ActiveFDCard.tsx +188 -0
  229. package/src/components/AmountInput.tsx +217 -0
  230. package/src/components/CheckboxOption.tsx +93 -0
  231. package/src/components/CompanyHeader.tsx +80 -0
  232. package/src/components/DropdownSelector.tsx +77 -0
  233. package/src/components/EmptyState.tsx +109 -0
  234. package/src/components/ErrorDisplay.tsx +135 -0
  235. package/src/components/FAQItem.tsx +90 -0
  236. package/src/components/FDCard.tsx +186 -0
  237. package/src/components/FormDropdown.tsx +214 -0
  238. package/src/components/FormSection.tsx +86 -0
  239. package/src/components/Header.tsx +110 -0
  240. package/src/components/IFSCSearchResultCard.tsx +139 -0
  241. package/src/components/InfoBox.tsx +55 -0
  242. package/src/components/InterestRateCard.tsx +77 -0
  243. package/src/components/LoadingIndicator.tsx +63 -0
  244. package/src/components/OTPInput.tsx +213 -0
  245. package/src/components/PaymentDetailsCard.tsx +120 -0
  246. package/src/components/PendingFDBottomSheet.tsx +237 -0
  247. package/src/components/README.md +210 -0
  248. package/src/components/SafeAreaWrapper.tsx +68 -0
  249. package/src/components/ScreenHeader.tsx +83 -0
  250. package/src/components/StatusDisplay.tsx +139 -0
  251. package/src/components/TextFieldWithLabel.tsx +502 -0
  252. package/src/components/TrustBox.tsx +63 -0
  253. package/src/components/ValidationErrorAlert.tsx +57 -0
  254. package/src/components/ValidationMessage.tsx +134 -0
  255. package/src/components/index.tsx +47 -0
  256. package/src/config/apiConfig.ts +217 -0
  257. package/src/config/appDataConfig.ts +358 -0
  258. package/src/config/encryptionConfig.ts +65 -0
  259. package/src/config/workflowConstants.ts +70 -0
  260. package/src/constants/strings/README.md +146 -0
  261. package/src/constants/strings/bank.ts +92 -0
  262. package/src/constants/strings/base64Images.ts +31 -0
  263. package/src/constants/strings/common.ts +63 -0
  264. package/src/constants/strings/employee.ts +85 -0
  265. package/src/constants/strings/faq.ts +23 -0
  266. package/src/constants/strings/fd.ts +172 -0
  267. package/src/constants/strings/home.ts +67 -0
  268. package/src/constants/strings/index.ts +21 -0
  269. package/src/constants/strings/kyc.ts +100 -0
  270. package/src/constants/strings/nominee.ts +90 -0
  271. package/src/hooks/useAuth.ts +42 -0
  272. package/src/hooks/useFDData.ts +48 -0
  273. package/src/index.tsx +139 -0
  274. package/src/navigation/RootNavigator.tsx +687 -0
  275. package/src/navigation/SimpleNavigator.tsx +123 -0
  276. package/src/navigation/helpers.ts +85 -0
  277. package/src/navigation/index.tsx +84 -0
  278. package/src/navigation/types.ts +146 -0
  279. package/src/navigation/workflowNavigator.ts +131 -0
  280. package/src/providers/ApiProvider.tsx +23 -0
  281. package/src/providers/MasterDataProvider.tsx +30 -0
  282. package/src/screens/AadhaarVerification.tsx +809 -0
  283. package/src/screens/AddBankAccount.tsx +541 -0
  284. package/src/screens/BankDetail.tsx +826 -0
  285. package/src/screens/Employee.tsx +822 -0
  286. package/src/screens/FDCalculator.tsx +1002 -0
  287. package/src/screens/FDList.tsx +2199 -0
  288. package/src/screens/FindIFSC.tsx +332 -0
  289. package/src/screens/NomineeDetail.tsx +800 -0
  290. package/src/screens/PayNow.tsx +282 -0
  291. package/src/screens/Payment.tsx +224 -0
  292. package/src/screens/PaymentStatus.tsx +595 -0
  293. package/src/screens/ReviewKYC.tsx +1062 -0
  294. package/src/state/paymentSession.ts +13 -0
  295. package/src/store/fdListSelectedSlice.ts +42 -0
  296. package/src/store/hooks.ts +6 -0
  297. package/src/store/index.ts +3 -0
  298. package/src/store/onboardingSlice.ts +37 -0
  299. package/src/store/store.ts +27 -0
  300. package/src/theme/ThemeContext.tsx +84 -0
  301. package/src/theme/colors.ts +90 -0
  302. package/src/theme/index.ts +85 -0
  303. package/src/theme/shadows.ts +61 -0
  304. package/src/theme/typography.ts +151 -0
  305. package/src/types/dataTypes.ts +37 -0
  306. package/src/types/env.d.ts +93 -0
  307. package/src/types/workflowTypes.ts +12 -0
  308. package/src/utils/apiLogger.ts +166 -0
  309. package/src/utils/encryption.ts +159 -0
  310. package/src/utils/getFDData.ts +165 -0
  311. package/src/utils/globalData.ts +7 -0
@@ -0,0 +1,767 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ // FDCalculator.tsx
40
+ const react_1 = __importStar(require("react"));
41
+ const react_native_1 = require("react-native");
42
+ const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
43
+ const SafeAreaWrapper_1 = __importDefault(require("../components/SafeAreaWrapper"));
44
+ const components_1 = require("../components");
45
+ const ThemeContext_1 = require("../theme/ThemeContext");
46
+ const MasterDataProvider_1 = require("../providers/MasterDataProvider");
47
+ const fdCalculatorApi_1 = require("../api/fdCalculatorApi");
48
+ const interestRateApi_1 = require("../api/interestRateApi");
49
+ const onboardingApi_1 = require("../api/onboardingApi");
50
+ const masterDataApi_1 = require("../api/masterDataApi");
51
+ const appDataConfig_1 = require("../config/appDataConfig");
52
+ const store_1 = require("../store");
53
+ // import { setFDCalculationData } from '../store/fdCalculationSlice';
54
+ const fdListSelectedSlice_1 = require("../store/fdListSelectedSlice");
55
+ const helpers_1 = require("../navigation/helpers");
56
+ const strings_1 = require("../constants/strings");
57
+ const base64Images_1 = require("../constants/strings/base64Images");
58
+ const formatTenureDisplay = (months) => {
59
+ if (months <= 12) {
60
+ return `${months} Months`;
61
+ }
62
+ const years = Math.floor(months / 12);
63
+ const remainingMonths = months % 12;
64
+ if (remainingMonths === 0) {
65
+ return `${years} Y`;
66
+ }
67
+ return `${years} Y ${remainingMonths} M`;
68
+ };
69
+ const parseTenureToMonths = (displayValue) => {
70
+ const monthsMatch = displayValue.match(/^(\d+)\s*Months?$/i);
71
+ if (monthsMatch) {
72
+ return parseInt(monthsMatch[1], 10);
73
+ }
74
+ const yearMonthMatch = displayValue.match(/(\d+)\s*Y(?:\s+(\d+)\s*M)?/i);
75
+ if (yearMonthMatch) {
76
+ const years = parseInt(yearMonthMatch[1], 10);
77
+ const months = yearMonthMatch[2] ? parseInt(yearMonthMatch[2], 10) : 0;
78
+ return years * 12 + months;
79
+ }
80
+ const numberMatch = displayValue.match(/\d+/);
81
+ return numberMatch ? parseInt(numberMatch[0], 10) : 0;
82
+ };
83
+ const DEFAULT_FAQ_ITEMS = [
84
+ {
85
+ title: strings_1.FAQ_STRINGS.FAQ_WITHDRAWAL_QUESTION,
86
+ description: strings_1.FAQ_STRINGS.FAQ_WITHDRAWAL_ANSWER,
87
+ },
88
+ {
89
+ title: strings_1.FAQ_STRINGS.FAQ_CREDIT_QUESTION,
90
+ description: strings_1.FAQ_STRINGS.FAQ_CREDIT_ANSWER,
91
+ },
92
+ {
93
+ title: strings_1.FAQ_STRINGS.FAQ_TAX_EXEMPTION_QUESTION,
94
+ description: strings_1.FAQ_STRINGS.FAQ_TAX_EXEMPTION_ANSWER,
95
+ },
96
+ {
97
+ title: strings_1.FAQ_STRINGS.FAQ_CUMULATIVE_QUESTION,
98
+ description: strings_1.FAQ_STRINGS.FAQ_CUMULATIVE_ANSWER,
99
+ },
100
+ {
101
+ title: strings_1.FAQ_STRINGS.FAQ_OPENING_TIME_QUESTION,
102
+ description: strings_1.FAQ_STRINGS.FAQ_OPENING_TIME_ANSWER,
103
+ },
104
+ {
105
+ title: strings_1.FAQ_STRINGS.FAQ_TDS_AVOIDANCE_QUESTION,
106
+ description: strings_1.FAQ_STRINGS.FAQ_TDS_AVOIDANCE_ANSWER,
107
+ },
108
+ ];
109
+ const FDCalculator = ({ onGoBack, onNavigateToReviewKYC, fdData }) => {
110
+ const typography = (0, ThemeContext_1.useTypography)();
111
+ const colors = (0, ThemeContext_1.useColors)();
112
+ const { themeName } = (0, ThemeContext_1.useTheme)();
113
+ const styles = react_1.default.useMemo(() => createStyles(typography, colors, themeName), [typography, colors, themeName]);
114
+ const { masterData, setMasterData } = (0, MasterDataProvider_1.useMasterData)();
115
+ // Get FD data from Redux as fallback if not passed as props
116
+ const fdListSelectedData = (0, store_1.useAppSelector)((state) => state === null || state === void 0 ? void 0 : state.fdListSelected);
117
+ const effectiveFdData = fdData || fdListSelectedData;
118
+ const [amount, setAmount] = (0, react_1.useState)('');
119
+ const [seniorCitizen, setSeniorCitizen] = (0, react_1.useState)(false);
120
+ const [taxResident, setTaxResident] = (0, react_1.useState)(true);
121
+ const [autoRenewal, setAutoRenewal] = (0, react_1.useState)(false);
122
+ const [expandedIndex, setExpandedIndex] = (0, react_1.useState)(null);
123
+ const [calculationResult, setCalculationResult] = (0, react_1.useState)(null);
124
+ const [debounceTimer, setDebounceTimer] = (0, react_1.useState)(null);
125
+ const [amountError, setAmountError] = (0, react_1.useState)('');
126
+ const [taxResidentError, setTaxResidentError] = (0, react_1.useState)('');
127
+ const [isAmountEditing, setIsAmountEditing] = (0, react_1.useState)(false);
128
+ // Calculate age from DOB and set senior citizen status
129
+ const calculateAgeAndSetSeniorCitizen = react_1.default.useCallback((dob) => {
130
+ if (!dob)
131
+ return;
132
+ const today = new Date();
133
+ const birthDate = new Date(dob);
134
+ let age = today.getFullYear() - birthDate.getFullYear();
135
+ const monthDiff = today.getMonth() - birthDate.getMonth();
136
+ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
137
+ age--;
138
+ }
139
+ setSeniorCitizen(age >= 60);
140
+ }, []);
141
+ // Interest payout dropdown state - will be updated after master data is loaded
142
+ const [payoutValue, setPayoutValue] = (0, react_1.useState)('');
143
+ const [showPayoutModal, setShowPayoutModal] = (0, react_1.useState)(false);
144
+ // Map dropdown values to API values
145
+ const mapPayoutToAPI = (dropdownValue) => {
146
+ const mapping = {
147
+ 'On Maturity': 'On Maturity',
148
+ 'Monthly': 'Monthly',
149
+ 'Quarterly': 'Quarterly',
150
+ 'Yearly': 'Yearly',
151
+ 'Half-Yearly': 'Half-Yearly',
152
+ };
153
+ return mapping[dropdownValue] || '';
154
+ };
155
+ // Check senior citizen status on component mount
156
+ react_1.default.useEffect(() => {
157
+ try {
158
+ const appData = (0, appDataConfig_1.getAppData)();
159
+ if (appData === null || appData === void 0 ? void 0 : appData.dob) {
160
+ calculateAgeAndSetSeniorCitizen(appData.dob);
161
+ }
162
+ }
163
+ catch (error) {
164
+ // Handle error silently
165
+ }
166
+ }, [calculateAgeAndSetSeniorCitizen]);
167
+ // Interest rates for Tenure options (real API)
168
+ const [getInterestRates, { data: interestRates }] = (0, interestRateApi_1.useGetInterestRatesMutation)();
169
+ react_1.default.useEffect(() => {
170
+ try {
171
+ getInterestRates({});
172
+ }
173
+ catch (e) {
174
+ // Handle error silently
175
+ }
176
+ }, [getInterestRates]);
177
+ // Fallback: Load master data if not available from global state
178
+ const defaultProviderId = (0, store_1.useAppSelector)((state) => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.onboarding) === null || _a === void 0 ? void 0 : _a.providerId; }); // Default FD provider ID
179
+ const { data: fallbackMasterData, isLoading: isLoadingFallback, error: fallbackError, refetch: refetchMasterData } = (0, masterDataApi_1.useGetMasterDataQuery)({ providerId: defaultProviderId }, // Use default provider ID
180
+ { skip: !!masterData } // Skip if master data is already available
181
+ );
182
+ // Use fallback master data if global master data is not available
183
+ // Store only the data parameter after stringifying instead of complete response
184
+ const effectiveMasterData = react_1.default.useMemo(() => {
185
+ const sourceData = masterData || fallbackMasterData;
186
+ if (!sourceData)
187
+ return null;
188
+ // If sourceData has a data property, extract and stringify it
189
+ if (sourceData.data) {
190
+ return JSON.stringify(sourceData.data);
191
+ }
192
+ // If sourceData is already the data object, stringify it
193
+ return JSON.stringify(sourceData);
194
+ }, [masterData, fallbackMasterData]);
195
+ // Default payout options as fallback
196
+ // const defaultPayoutOptions = ['Maturity', 'Monthly eee', 'Quarterly', 'Half-Yearly', 'Yearly'];
197
+ const payoutOptions = react_1.default.useMemo(() => {
198
+ try {
199
+ const parsedData = JSON.parse(effectiveMasterData || '{}');
200
+ // If master data gives a single value instead of an array
201
+ const rawValue = parsedData === null || parsedData === void 0 ? void 0 : parsedData.interestPayoutTerm;
202
+ if (!rawValue)
203
+ return [];
204
+ // Handle both array and string types
205
+ if (Array.isArray(rawValue)) {
206
+ return rawValue;
207
+ }
208
+ // If it's a comma-separated string or a single string
209
+ if (typeof rawValue === 'string') {
210
+ // e.g. "Maturity,Monthly,Quarterly" → ['Maturity', 'Monthly', 'Quarterly']
211
+ return rawValue.split(',').map(v => v.trim());
212
+ }
213
+ return [];
214
+ }
215
+ catch (error) {
216
+ return [];
217
+ }
218
+ }, [effectiveMasterData]);
219
+ // Store fallback master data in global state if it becomes available
220
+ react_1.default.useEffect(() => {
221
+ if (fallbackMasterData && !masterData) {
222
+ setMasterData(fallbackMasterData);
223
+ }
224
+ }, [fallbackMasterData, masterData, setMasterData]);
225
+ // Update payout value when master data becomes available
226
+ react_1.default.useEffect(() => {
227
+ if (payoutOptions.length > 0 && !payoutValue) {
228
+ // Set "On Maturity" as default if available, otherwise use first option
229
+ const defaultOption = payoutOptions.find(option => option === 'On Maturity') || payoutOptions[0];
230
+ setPayoutValue(defaultOption);
231
+ }
232
+ }, [payoutOptions]);
233
+ react_1.default.useEffect(() => {
234
+ if (amount && payoutValue) {
235
+ // Only call if amount is valid
236
+ const numericValue = parseInt(amount.replace(/,/g, ''), 10);
237
+ if (numericValue >= 5000 && numericValue <= 50000000 && numericValue % 1000 === 0) {
238
+ handleCalculateFD(amount, payoutValue);
239
+ }
240
+ }
241
+ }, [payoutValue]);
242
+ // Master data processing complete
243
+ // FD Calculator API
244
+ const [calculateFD, { isLoading: isCalculating }] = (0, fdCalculatorApi_1.useCalculateFDMutation)();
245
+ // Onboarding API
246
+ const [startOnboarding, { isLoading: isOnboarding }] = (0, onboardingApi_1.useStartOnboardingMutation)();
247
+ const [isBooking, setIsBooking] = react_1.default.useState(false);
248
+ const dispatch = (0, store_1.useAppDispatch)();
249
+ const { setOnboardingIds } = require('../store/onboardingSlice');
250
+ const tenureOptions = react_1.default.useMemo(() => {
251
+ var _a, _b;
252
+ const months = [];
253
+ const sdr = ((_a = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _a === void 0 ? void 0 : _a.sdrScheme) || [];
254
+ const fdr = ((_b = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _b === void 0 ? void 0 : _b.fdrScheme) || [];
255
+ sdr.forEach((r) => { if (typeof (r === null || r === void 0 ? void 0 : r.perdMonth) === 'number')
256
+ months.push(r.perdMonth); });
257
+ fdr.forEach((r) => { if (typeof (r === null || r === void 0 ? void 0 : r.perdMonth) === 'number')
258
+ months.push(r.perdMonth); });
259
+ const unique = Array.from(new Set(months)).sort((a, b) => a - b);
260
+ return unique.map(m => formatTenureDisplay(m));
261
+ }, [interestRates]);
262
+ (0, react_1.useEffect)(() => {
263
+ console.log("following are the tenure options at the fd", tenureOptions);
264
+ });
265
+ const [tenureValue, setTenureValue] = (0, react_1.useState)('');
266
+ react_1.default.useEffect(() => {
267
+ if (tenureOptions.length > 0) {
268
+ // If effectiveFdData has tenure, use it; otherwise use first option
269
+ if (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.tenure) {
270
+ const tenureMonths = parseTenureToMonths(effectiveFdData.tenure);
271
+ const formattedTenure = formatTenureDisplay(tenureMonths);
272
+ const matchingTenure = tenureOptions.find(option => option === formattedTenure);
273
+ setTenureValue(matchingTenure || formattedTenure);
274
+ }
275
+ else {
276
+ setTenureValue(tenureOptions[0]);
277
+ }
278
+ }
279
+ }, [tenureOptions, effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.tenure]);
280
+ const [showTenureMenu, setShowTenureMenu] = (0, react_1.useState)(false);
281
+ // Function to close all dropdown menus
282
+ const closeAllMenus = () => {
283
+ setShowTenureMenu(false);
284
+ setShowPayoutModal(false);
285
+ };
286
+ // Function to call FD calculator API
287
+ const handleCalculateFD = react_1.default.useCallback(async (currentAmount, selectedPayout) => {
288
+ var _a, _b;
289
+ const payoutToUse = selectedPayout || payoutValue;
290
+ const amountToUse = currentAmount || amount; // ✅ use latest if provided
291
+ if (!amountToUse || !payoutToUse)
292
+ return;
293
+ try {
294
+ const amountValue = parseFloat(amountToUse.replace(/,/g, ''));
295
+ const tenureMonths = parseTenureToMonths(tenureValue);
296
+ if (isNaN(amountValue) || isNaN(tenureMonths) || amountValue <= 0 || tenureMonths <= 0)
297
+ return;
298
+ const sdr = ((_a = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _a === void 0 ? void 0 : _a.sdrScheme) || [];
299
+ const fdr = ((_b = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _b === void 0 ? void 0 : _b.fdrScheme) || [];
300
+ const firstRate = sdr[0] || fdr[0];
301
+ const providerId = firstRate === null || firstRate === void 0 ? void 0 : firstRate.providerId;
302
+ const appData = (0, appDataConfig_1.getAppData)();
303
+ const userDob = (appData === null || appData === void 0 ? void 0 : appData.dob) || '1990-01-01';
304
+ const isWomenDepositor = (appData === null || appData === void 0 ? void 0 : appData.gender) === 'F';
305
+ const requestData = {
306
+ principalAmount: amountValue,
307
+ tenureInMonths: tenureMonths,
308
+ dob: userDob,
309
+ isWomenDepositor,
310
+ investmentType: payoutToUse === 'On Maturity' ? 'SDR' : 'FDR',
311
+ providerId,
312
+ interestPayout: payoutToUse,
313
+ };
314
+ const result = await calculateFD(requestData).unwrap();
315
+ setCalculationResult(result);
316
+ }
317
+ catch (error) {
318
+ // FD calculation failed
319
+ }
320
+ finally {
321
+ setIsAmountEditing(false);
322
+ }
323
+ }, [amount, tenureValue, payoutValue, calculateFD, interestRates]);
324
+ // Debounced amount change handler
325
+ const handleAmountChange = react_1.default.useCallback((text) => {
326
+ setIsAmountEditing(true);
327
+ // Step 1: Always remove commas first
328
+ const unformatted = text.replace(/,/g, '');
329
+ // Step 2: Allow only numbers
330
+ let cleanedText = unformatted.replace(/[^0-9]/g, '');
331
+ if (cleanedText.length > 1 && cleanedText.startsWith('0')) {
332
+ cleanedText = cleanedText.replace(/^0+/, '');
333
+ }
334
+ // Step 3: Stop if greater than 5 crores
335
+ const numericValue = parseInt(cleanedText || '0', 10);
336
+ if (numericValue > 50000000)
337
+ return;
338
+ // Step 4: Update state with raw digits (not formatted)
339
+ setAmount(cleanedText);
340
+ // Step 5: Validate
341
+ if (!cleanedText) {
342
+ setAmountError('');
343
+ setIsAmountEditing(false);
344
+ }
345
+ else if (numericValue < 5000)
346
+ setAmountError(strings_1.FD_STRINGS.MINIMUM_AMOUNT_ERROR);
347
+ else if (numericValue % 1000 !== 0)
348
+ setAmountError(strings_1.FD_STRINGS.AMOUNT_MULTIPLES_ERROR);
349
+ else
350
+ setAmountError('');
351
+ // Step 6: Clear previous debounce timer
352
+ if (debounceTimer)
353
+ clearTimeout(debounceTimer);
354
+ // Step 7: Debounced API call
355
+ const isValidLocal = numericValue >= 5000 && numericValue <= 50000000 && numericValue % 1000 === 0;
356
+ if (cleanedText && isValidLocal && payoutValue) {
357
+ const newTimer = setTimeout(() => {
358
+ // Pass latest cleanedText directly to avoid stale state
359
+ handleCalculateFD(cleanedText);
360
+ }, 1000);
361
+ setDebounceTimer(newTimer);
362
+ }
363
+ }, [debounceTimer, handleCalculateFD, payoutValue]);
364
+ // Function to call onboarding API
365
+ const handleStartOnboarding = react_1.default.useCallback(async (selectedPayout) => {
366
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
367
+ if (isBooking)
368
+ return;
369
+ setIsBooking(true);
370
+ const payoutToUse = selectedPayout || payoutValue;
371
+ try {
372
+ // Check if required fields are filled
373
+ if (!amount || !tenureValue) {
374
+ return;
375
+ }
376
+ const amountValue = parseFloat(amount.replace(/,/g, ''));
377
+ const tenureMonths = parseTenureToMonths(tenureValue);
378
+ if (isNaN(amountValue) || isNaN(tenureMonths) || amountValue <= 0 || tenureMonths <= 0) {
379
+ return;
380
+ }
381
+ // Check minimum amount requirement
382
+ if (amountValue < 5000) {
383
+ return;
384
+ }
385
+ // Get providerId from interest rates data
386
+ const sdr = ((_a = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _a === void 0 ? void 0 : _a.sdrScheme) || [];
387
+ const fdr = ((_b = interestRates === null || interestRates === void 0 ? void 0 : interestRates.data) === null || _b === void 0 ? void 0 : _b.fdrScheme) || [];
388
+ const firstRate = sdr[0] || fdr[0];
389
+ const providerId = firstRate === null || firstRate === void 0 ? void 0 : firstRate.providerId;
390
+ // Get user data for all required fields
391
+ const appData = (0, appDataConfig_1.getAppData)();
392
+ const userDob = (appData === null || appData === void 0 ? void 0 : appData.dob) || '1990-01-01';
393
+ const isWomenDepositor = (appData === null || appData === void 0 ? void 0 : appData.gender) === 'F';
394
+ // Get calculated values from API response based on investment type
395
+ const investmentType = payoutValue === 'On Maturity' ? 'SDR' : 'FDR';
396
+ const calcData = investmentType === 'SDR'
397
+ ? (_d = (_c = calculationResult === null || calculationResult === void 0 ? void 0 : calculationResult.data) === null || _c === void 0 ? void 0 : _c.sdrCalc) === null || _d === void 0 ? void 0 : _d[0]
398
+ : (_f = (_e = calculationResult === null || calculationResult === void 0 ? void 0 : calculationResult.data) === null || _e === void 0 ? void 0 : _e.fdrCalc) === null || _f === void 0 ? void 0 : _f[0];
399
+ const interestRate = calcData === null || calcData === void 0 ? void 0 : calcData.wRoi;
400
+ const maturityAmount = calcData === null || calcData === void 0 ? void 0 : calcData.maturityAmount;
401
+ // Calculate maturity date
402
+ const maturityDate = new Date();
403
+ maturityDate.setMonth(maturityDate.getMonth() + tenureMonths);
404
+ const formattedMaturityDate = maturityDate.toISOString().split('T')[0];
405
+ const onboardingData = {
406
+ // User personal details
407
+ mobile: (appData === null || appData === void 0 ? void 0 : appData.mobNo) || '',
408
+ prefix: (appData === null || appData === void 0 ? void 0 : appData.gender) === 'M' ? 'Mr.' : ((appData === null || appData === void 0 ? void 0 : appData.gender) === 'F' ? 'Ms.' : 'Mr.'),
409
+ fullName: (appData === null || appData === void 0 ? void 0 : appData.name) || '',
410
+ firstName: ((_g = appData === null || appData === void 0 ? void 0 : appData.name) === null || _g === void 0 ? void 0 : _g.split(' ')[0]) || '',
411
+ lastName: ((_h = appData === null || appData === void 0 ? void 0 : appData.name) === null || _h === void 0 ? void 0 : _h.split(' ').slice(1).join(' ')) || '',
412
+ userReferenceId: (appData === null || appData === void 0 ? void 0 : appData.id) || '',
413
+ dob: userDob,
414
+ email: (appData === null || appData === void 0 ? void 0 : appData.email) || '',
415
+ gender: (appData === null || appData === void 0 ? void 0 : appData.gender) === 'M' ? 'Male' : ((appData === null || appData === void 0 ? void 0 : appData.gender) === 'F' ? 'Female' : 'Male'),
416
+ // FD details
417
+ autoRenewal: autoRenewal,
418
+ investmentAmount: amountValue,
419
+ tenureInMonths: tenureMonths,
420
+ interestPayoutTerm: payoutToUse,
421
+ interestRate: interestRate,
422
+ maturityDate: formattedMaturityDate,
423
+ maturityAmount: Math.round(maturityAmount),
424
+ // Additional fields
425
+ principalAmount: amountValue,
426
+ isWomenDepositor: isWomenDepositor,
427
+ investmentType: payoutToUse === 'On Maturity' ? 'SDR' : 'FDR',
428
+ providerId: providerId,
429
+ eventNotifyUrl: appData === null || appData === void 0 ? void 0 : appData.eventNotifyUrl,
430
+ };
431
+ const result = await startOnboarding(onboardingData).unwrap();
432
+ // Store FD calculation data directly into FDListSelected for PayNow screen
433
+ try {
434
+ const fdListSelectedData = {
435
+ id: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.id) || '',
436
+ providerId: providerId || '',
437
+ name: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.name) || '',
438
+ accountNumber: '',
439
+ roi: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.roi) || '',
440
+ tenure: tenureValue,
441
+ amount: parseInt(amount) || 0,
442
+ maturityDate: '',
443
+ status: 'pending',
444
+ creditRating: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.creditRating) || 'NA',
445
+ companyName: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.name) || '',
446
+ fdRate: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.roi) || '',
447
+ interestPayout: payoutToUse,
448
+ };
449
+ dispatch((0, fdListSelectedSlice_1.setFDListSelected)(fdListSelectedData));
450
+ }
451
+ catch (e) {
452
+ // Handle error silently
453
+ }
454
+ // Persist onboarding identifiers globally for subsequent API calls
455
+ try {
456
+ const ids = {
457
+ workflowInstanceId: (_j = result === null || result === void 0 ? void 0 : result.data) === null || _j === void 0 ? void 0 : _j.workflowInstanceId,
458
+ applicationId: (_k = result === null || result === void 0 ? void 0 : result.data) === null || _k === void 0 ? void 0 : _k.applicationId,
459
+ entityid: (_l = result === null || result === void 0 ? void 0 : result.data) === null || _l === void 0 ? void 0 : _l.entityid,
460
+ customerId: (_m = result === null || result === void 0 ? void 0 : result.data) === null || _m === void 0 ? void 0 : _m.customerId,
461
+ fdId: (_o = result === null || result === void 0 ? void 0 : result.data) === null || _o === void 0 ? void 0 : _o.fdId,
462
+ };
463
+ if (dispatch && setOnboardingIds) {
464
+ dispatch(setOnboardingIds(ids));
465
+ }
466
+ else {
467
+ // Dispatch or setOnboardingIds unavailable
468
+ }
469
+ }
470
+ catch (e) {
471
+ // Handle error silently
472
+ }
473
+ // Navigate to ReviewKYC after successful onboarding
474
+ if (result.status === 'success' && onNavigateToReviewKYC) {
475
+ onNavigateToReviewKYC();
476
+ }
477
+ }
478
+ catch (error) {
479
+ // Handle error silently
480
+ }
481
+ finally {
482
+ setIsBooking(false);
483
+ }
484
+ }, [amount, tenureValue, interestRates, startOnboarding, onNavigateToReviewKYC, isBooking, payoutValue, calculationResult, autoRenewal]);
485
+ // Cleanup timer on unmount
486
+ react_1.default.useEffect(() => {
487
+ return () => {
488
+ if (debounceTimer) {
489
+ clearTimeout(debounceTimer);
490
+ }
491
+ };
492
+ }, [debounceTimer]);
493
+ // Derived validation state for amount input
494
+ const isAmountValid = react_1.default.useMemo(() => {
495
+ const amountValue = parseFloat(amount.replace(/,/g, ''));
496
+ return !!amount && !isNaN(amountValue) && amountValue >= 5000 && amountValue <= 50000000 && amountValue % 1000 === 0;
497
+ }, [amount]);
498
+ // Derived validation state for payout selection
499
+ const isPayoutValid = react_1.default.useMemo(() => {
500
+ return !!payoutValue && payoutValue.trim() !== '';
501
+ }, [payoutValue]);
502
+ // Handle tax resident checkbox change
503
+ const handleTaxResidentChange = () => {
504
+ const newValue = !taxResident;
505
+ setTaxResident(newValue);
506
+ // Show error if unchecked
507
+ if (!newValue) {
508
+ setTaxResidentError(strings_1.FD_STRINGS.TAX_RESIDENT_ERROR);
509
+ }
510
+ else {
511
+ setTaxResidentError('');
512
+ }
513
+ };
514
+ // Extract FAQ data from master data API response
515
+ const faqData = react_1.default.useMemo(() => {
516
+ const fallback = [...DEFAULT_FAQ_ITEMS];
517
+ try {
518
+ const parsedData = JSON.parse(effectiveMasterData || '{}');
519
+ const masterDataFaq = (parsedData === null || parsedData === void 0 ? void 0 : parsedData.Faq) || (parsedData === null || parsedData === void 0 ? void 0 : parsedData.faq) || (parsedData === null || parsedData === void 0 ? void 0 : parsedData.faqData) || (parsedData === null || parsedData === void 0 ? void 0 : parsedData.frequentlyAskedQuestions);
520
+ if (masterDataFaq && Array.isArray(masterDataFaq) && masterDataFaq.length > 0) {
521
+ const normalized = masterDataFaq
522
+ .map((faq) => ({
523
+ title: faq.title || faq.question || faq.q || '',
524
+ description: faq.description || faq.answer || faq.a || ''
525
+ }))
526
+ .filter((faq) => faq.title && faq.description);
527
+ const containsLegacyBrand = normalized.some(item => /shriram/i.test(`${item.title} ${item.description}`));
528
+ if (!containsLegacyBrand && normalized.length > 0) {
529
+ return normalized;
530
+ }
531
+ }
532
+ }
533
+ catch (error) {
534
+ // Ignore and use fallback
535
+ }
536
+ return fallback;
537
+ }, [effectiveMasterData]);
538
+ // Handle Android hardware back button - use same navigation as header back button
539
+ (0, react_1.useEffect)(() => {
540
+ if (react_native_1.Platform.OS !== 'android')
541
+ return;
542
+ const onHardwareBackPress = () => {
543
+ (0, helpers_1.navigate)('FDList'); // Same as header back button
544
+ return true; // Prevent default behavior
545
+ };
546
+ const backHandler = react_native_1.BackHandler.addEventListener('hardwareBackPress', onHardwareBackPress);
547
+ return () => backHandler.remove();
548
+ }, []);
549
+ return (react_1.default.createElement(SafeAreaWrapper_1.default, { includeTop: false, bottomPadding: 25, statusBarColor: "#000000", statusBarStyle: "light-content" },
550
+ react_1.default.createElement(react_native_1.View, { style: styles.header },
551
+ react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => (0, helpers_1.navigate)('FDList'), style: styles.backButton },
552
+ react_1.default.createElement(react_native_1.Image, { source: { uri: base64Images_1.base64Images.backArrow }, style: [styles.backIcon, { tintColor: themeName === 'dark' ? colors.headerText : undefined }], resizeMode: "contain", width: 24, height: 24 }))),
553
+ react_1.default.createElement(react_native_1.View, { style: { flex: 1, justifyContent: 'space-between' } },
554
+ react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollContainer, contentContainerStyle: styles.scrollContent, showsVerticalScrollIndicator: false, onScrollBeginDrag: closeAllMenus, scrollEnabled: !(isOnboarding || isBooking), keyboardShouldPersistTaps: "handled", bounces: true, alwaysBounceVertical: true },
555
+ react_1.default.createElement(components_1.CompanyHeader, { companyName: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.name) || '', rating: (effectiveFdData === null || effectiveFdData === void 0 ? void 0 : effectiveFdData.creditRating) || 'AA+' }),
556
+ react_1.default.createElement(components_1.AmountInput, { label: strings_1.FD_STRINGS.INVESTMENT_AMOUNT_LABEL, value: amount, onChangeText: handleAmountChange, onFocus: closeAllMenus, placeholder: strings_1.FD_STRINGS.AMOUNT_PLACEHOLDER, noteText: strings_1.FD_STRINGS.AMOUNT_NOTE, minMaxText: strings_1.FD_STRINGS.AMOUNT_MIN_MAX, errorMessage: amountError }),
557
+ react_1.default.createElement(components_1.DropdownSelector, { label: strings_1.FD_STRINGS.TENURE_LABEL, value: tenureValue || strings_1.COMMON_STRINGS.SELECT, onPress: () => {
558
+ react_native_1.Keyboard.dismiss();
559
+ closeAllMenus();
560
+ setShowTenureMenu(prev => !prev);
561
+ } }),
562
+ showTenureMenu && (react_1.default.createElement(react_native_1.View, { style: styles.inlineMenu }, (tenureOptions.length > 0 ? tenureOptions : [strings_1.FD_STRINGS.TENURE_12_MONTHS, strings_1.FD_STRINGS.TENURE_24_MONTHS, strings_1.FD_STRINGS.TENURE_36_MONTHS]).map((option) => (react_1.default.createElement(react_native_1.TouchableOpacity, { key: option, style: styles.modalOption, onPress: () => {
563
+ setTenureValue(option);
564
+ setShowTenureMenu(false);
565
+ // Call API after dropdown value changes
566
+ setTimeout(() => handleCalculateFD(), 100);
567
+ } },
568
+ react_1.default.createElement(react_native_1.Text, { style: styles.modalOptionText }, option)))))),
569
+ react_1.default.createElement(components_1.DropdownSelector, { label: strings_1.FD_STRINGS.INTEREST_PAYOUT_TERM_LABEL, value: payoutValue, onPress: () => {
570
+ react_native_1.Keyboard.dismiss();
571
+ closeAllMenus();
572
+ setShowPayoutModal(prev => !prev);
573
+ }, placeholder: strings_1.FD_STRINGS.PAYOUT_MONTHLY }),
574
+ showPayoutModal && (react_1.default.createElement(react_native_1.View, { style: styles.inlineMenu }, payoutOptions
575
+ .filter((v, i, a) => !!v && a.indexOf(v) === i)
576
+ .map((option) => (react_1.default.createElement(react_native_1.TouchableOpacity, { key: option, style: styles.modalOption, onPress: () => {
577
+ setPayoutValue(option);
578
+ setShowPayoutModal(false);
579
+ handleCalculateFD(amount, option);
580
+ // Pass the selected option directly to avoid stale state
581
+ // setTimeout(() => handleCalculateFD(option), 100);
582
+ } },
583
+ react_1.default.createElement(react_native_1.Text, { style: styles.modalOptionText }, option)))))),
584
+ isCalculating && (react_1.default.createElement(react_native_1.View, { style: styles.loadingContainer },
585
+ react_1.default.createElement(react_native_1.ActivityIndicator, { size: "small", color: colors.primary }),
586
+ react_1.default.createElement(react_native_1.Text, { style: styles.loadingText }, strings_1.COMMON_STRINGS.PROCESSING))),
587
+ react_1.default.createElement(components_1.InterestRateCard, { interestRate: (() => {
588
+ var _a, _b;
589
+ const data = calculationResult === null || calculationResult === void 0 ? void 0 : calculationResult.data;
590
+ const investmentType = payoutValue === 'On Maturity' ? 'SDR' : 'FDR';
591
+ const calcData = investmentType === 'SDR'
592
+ ? (_a = data === null || data === void 0 ? void 0 : data.sdrCalc) === null || _a === void 0 ? void 0 : _a[0]
593
+ : (_b = data === null || data === void 0 ? void 0 : data.fdrCalc) === null || _b === void 0 ? void 0 : _b[0];
594
+ const wroi = (calcData === null || calcData === void 0 ? void 0 : calcData.wRoi) || (data === null || data === void 0 ? void 0 : data.wroi) || (data === null || data === void 0 ? void 0 : data.interestRate) || (data === null || data === void 0 ? void 0 : data.rate);
595
+ return wroi ? `${Number(wroi).toFixed(2)}% p.a.` : "";
596
+ })(), maturityAmount: (() => {
597
+ var _a, _b;
598
+ const data = calculationResult === null || calculationResult === void 0 ? void 0 : calculationResult.data;
599
+ const investmentType = payoutValue === 'On Maturity' ? 'SDR' : 'FDR';
600
+ const calcData = investmentType === 'SDR'
601
+ ? (_a = data === null || data === void 0 ? void 0 : data.sdrCalc) === null || _a === void 0 ? void 0 : _a[0]
602
+ : (_b = data === null || data === void 0 ? void 0 : data.fdrCalc) === null || _b === void 0 ? void 0 : _b[0];
603
+ const maturityAmount = (calcData === null || calcData === void 0 ? void 0 : calcData.maturityAmount) || (data === null || data === void 0 ? void 0 : data.maturityAmount) || (data === null || data === void 0 ? void 0 : data.totalAmount) || (data === null || data === void 0 ? void 0 : data.finalAmount) || (data === null || data === void 0 ? void 0 : data.amount);
604
+ return maturityAmount ? `₹${maturityAmount.toLocaleString()}` : "";
605
+ })() },
606
+ react_1.default.createElement(components_1.CheckboxOption, { label: strings_1.FD_STRINGS.SENIOR_CITIZEN_BENEFIT, checked: seniorCitizen, onPress: () => setSeniorCitizen(!seniorCitizen), numberOfLines: 1, containerStyle: { marginTop: 12 }, disabled: true })),
607
+ react_1.default.createElement(react_native_1.View, { style: [styles.checkboxCard, !taxResident && styles.checkboxCardError] },
608
+ react_1.default.createElement(components_1.CheckboxOption, { label: strings_1.FD_STRINGS.TAX_RESIDENT_CONFIRMATION, checked: taxResident, onPress: handleTaxResidentChange })),
609
+ taxResidentError && (react_1.default.createElement(react_native_1.View, { style: styles.errorContainer },
610
+ react_native_1.Platform.OS === 'android' && (react_1.default.createElement(Ionicons_1.default, { name: "warning", size: 16, color: colors.error || '#FF0000', style: styles.errorIcon })),
611
+ react_1.default.createElement(react_native_1.Text, { style: styles.errorText }, taxResidentError))),
612
+ react_1.default.createElement(react_native_1.View, { style: styles.checkboxCard },
613
+ react_1.default.createElement(components_1.CheckboxOption, { label: strings_1.FD_STRINGS.MATURITY_AUTO_RENEWAL, checked: autoRenewal, onPress: () => setAutoRenewal(!autoRenewal) })),
614
+ react_1.default.createElement(components_1.InfoBox, { message: strings_1.FD_STRINGS.WITHDRAWAL_INFO, containerStyle: styles.infoBoxCard, showNonStockIcon: true }),
615
+ react_1.default.createElement(react_native_1.Text, { style: styles.sectionTitle }, strings_1.FD_STRINGS.SAFETY_TRUST_TITLE),
616
+ react_1.default.createElement(react_native_1.View, { style: styles.trustRow },
617
+ react_1.default.createElement(components_1.TrustBox, { title1: strings_1.FD_STRINGS.TRUSTED_BY, title2: strings_1.FD_STRINGS.CRORES_INDIANS }),
618
+ react_1.default.createElement(components_1.TrustBox, { title1: strings_1.FD_STRINGS.AAA_RATING, title2: strings_1.FD_STRINGS.RATING, style: { marginLeft: 10 } })),
619
+ react_1.default.createElement(react_native_1.Text, { style: styles.sectionTitle }, strings_1.FD_STRINGS.FAQ_TITLE),
620
+ faqData.map((item, index) => (react_1.default.createElement(components_1.FAQItem, { key: index, question: item.title, answer: item.description, isExpanded: expandedIndex === index, onToggle: () => setExpandedIndex(expandedIndex === index ? null : index) })))),
621
+ react_1.default.createElement(react_native_1.TouchableOpacity, { style: [
622
+ styles.startButton,
623
+ (!taxResident || isOnboarding || isBooking || !isAmountValid || !isPayoutValid || isCalculating || isAmountEditing) ? styles.startButtonDisabled : null
624
+ ], disabled: !taxResident || isOnboarding || isBooking || !isAmountValid || !isPayoutValid || isCalculating || isAmountEditing, activeOpacity: (!taxResident || isOnboarding || isBooking || !isAmountValid || !isPayoutValid || isCalculating || isAmountEditing) ? 1 : 0.7, onPress: () => {
625
+ if (taxResident && !isOnboarding && !isBooking && isAmountValid && isPayoutValid && !isCalculating && !isAmountEditing) {
626
+ handleStartOnboarding(payoutValue);
627
+ }
628
+ } }, (isOnboarding || isBooking) ? (react_1.default.createElement(react_native_1.View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center' } },
629
+ react_1.default.createElement(react_native_1.ActivityIndicator, { size: "small", color: themeName === 'dark' ? colors.buttonTextColor : colors.background, style: { marginRight: 8 } }),
630
+ react_1.default.createElement(react_native_1.Text, { style: [
631
+ styles.startButtonText,
632
+ (!taxResident || isOnboarding || isBooking || !isAmountValid || !isPayoutValid || isCalculating || isAmountEditing) ? styles.startButtonTextDisabled : null
633
+ ] }, strings_1.COMMON_STRINGS.PROCESSING))) : (react_1.default.createElement(react_native_1.Text, { style: [
634
+ styles.startButtonText,
635
+ (!taxResident || isOnboarding || isBooking || !isAmountValid || !isPayoutValid || isCalculating || isAmountEditing) ? styles.startButtonTextDisabled : null
636
+ ] }, strings_1.FD_STRINGS.BOOK_FD_BUTTON)))),
637
+ (isOnboarding || isBooking) && (react_1.default.createElement(react_native_1.View, { style: styles.loadingOverlay, pointerEvents: "auto" }))));
638
+ };
639
+ exports.default = FDCalculator;
640
+ const isAndroid15OrHigher = react_native_1.Platform.OS === "android" && react_native_1.Platform.Version >= 15;
641
+ const createStyles = (typography, colors, themeName) => react_native_1.StyleSheet.create({
642
+ header: {
643
+ flexDirection: 'row',
644
+ justifyContent: 'flex-start',
645
+ alignItems: 'center',
646
+ paddingHorizontal: 16,
647
+ paddingTop: react_native_1.Platform.OS === 'ios' ? 40 : 20,
648
+ paddingBottom: 10,
649
+ backgroundColor: colors.background,
650
+ },
651
+ backIcon: {
652
+ // Icon styling handled by Ionicons component
653
+ width: 24,
654
+ height: 24,
655
+ resizeMode: 'contain',
656
+ // backgroundColor: "red",
657
+ },
658
+ backButton: {
659
+ padding: 8,
660
+ marginTop: isAndroid15OrHigher ? 10 : 0,
661
+ },
662
+ scrollContainer: {
663
+ flex: 1,
664
+ },
665
+ scrollContent: {
666
+ paddingHorizontal: 16,
667
+ paddingBottom: 40,
668
+ },
669
+ checkboxCard: {
670
+ backgroundColor: themeName === 'dark' ? colors.inputBackground : 'rgba(0,235,180,0.1)',
671
+ padding: 12,
672
+ borderRadius: 4,
673
+ marginTop: 16,
674
+ },
675
+ infoBoxCard: {
676
+ backgroundColor: themeName === 'dark' ? colors.inputBackground : 'rgba(0,235,180,0.1)',
677
+ padding: 16,
678
+ borderRadius: 4,
679
+ marginTop: 16,
680
+ },
681
+ sectionTitle: Object.assign(Object.assign({}, typography.styles.bodyMedium), { fontWeight: typography.fontWeight.semiBold, marginTop: 25, marginBottom: 8, color: colors.text, fontSize: 16 }),
682
+ trustRow: {
683
+ flexDirection: 'row',
684
+ justifyContent: 'space-between',
685
+ marginTop: 10,
686
+ },
687
+ startButtonWrapper: {
688
+ position: 'relative',
689
+ },
690
+ startButton: {
691
+ backgroundColor: themeName === 'dark' ? colors.buttonBackground : colors.headerBg,
692
+ paddingVertical: themeName === 'dark' ? 1 : 20,
693
+ paddingHorizontal: 20,
694
+ borderRadius: themeName === 'dark' ? 10 : 30,
695
+ marginTop: 30,
696
+ alignItems: 'center',
697
+ justifyContent: 'center',
698
+ height: themeName === 'dark' ? 50 : 56,
699
+ width: '90%',
700
+ alignSelf: 'center',
701
+ },
702
+ startButtonDisabled: {
703
+ backgroundColor: '#909090',
704
+ color: '#ffffff',
705
+ },
706
+ startButtonText: Object.assign(Object.assign({}, typography.styles.button), { color: themeName === 'dark' ? colors.buttonTextColor : colors.background, lineHeight: themeName === 'dark' ? 24 : typography.styles.button.lineHeight, fontSize: 16 }),
707
+ startButtonTextDisabled: {
708
+ color: themeName === 'dark' ? "#ffffff" : colors.tabSelected,
709
+ },
710
+ inlineMenu: {
711
+ backgroundColor: themeName === 'dark' ? colors.inputBackground : colors.background,
712
+ borderWidth: themeName === 'dark' ? 1 : 0.5,
713
+ borderColor: themeName === 'dark' ? '#ffffff' : 'rgba(0,0,0,0.2)',
714
+ borderRadius: 8,
715
+ marginTop: 6,
716
+ paddingHorizontal: 12,
717
+ paddingVertical: 6,
718
+ },
719
+ modalOption: {
720
+ paddingVertical: 14,
721
+ },
722
+ modalOptionText: Object.assign(Object.assign({}, typography.styles.bodyLarge), { color: colors.text, fontSize: 16, placeholderTextColor: '#9ca9b0' }),
723
+ loadingContainer: {
724
+ flexDirection: 'row',
725
+ alignItems: 'center',
726
+ justifyContent: 'center',
727
+ paddingVertical: 12,
728
+ fontSize: 14,
729
+ marginTop: 16,
730
+ },
731
+ loadingText: Object.assign(Object.assign({}, typography.styles.bodyMedium), { color: colors.textLight, marginLeft: 8 }),
732
+ overlayAboveInterestRate: {
733
+ position: 'absolute',
734
+ top: 0,
735
+ left: 0,
736
+ right: 0,
737
+ height: 20,
738
+ backgroundColor: 'rgba(128, 128, 128, 0.3)', // Light gray translucent overlay
739
+ zIndex: 1,
740
+ },
741
+ errorContainer: {
742
+ flexDirection: 'row',
743
+ alignItems: 'center',
744
+ marginTop: 8,
745
+ },
746
+ errorIcon: {
747
+ marginRight: 6,
748
+ },
749
+ errorText: {
750
+ fontSize: 14,
751
+ color: colors.error || '#FF0000',
752
+ fontWeight: '500',
753
+ flex: 1,
754
+ },
755
+ checkboxCardError: {
756
+ backgroundColor: 'rgba(255, 0, 0, 0.08)', // Red with same opacity as the original green
757
+ },
758
+ loadingOverlay: {
759
+ position: 'absolute',
760
+ top: 0,
761
+ left: 0,
762
+ right: 0,
763
+ bottom: 0,
764
+ backgroundColor: 'rgba(0, 0, 0, 0.3)',
765
+ zIndex: 1000,
766
+ },
767
+ });