From d7907e1d648cc433ac1afbf77e2eecfa1200a070 Mon Sep 17 00:00:00 2001 From: Abin Toppo Date: Tue, 26 May 2026 16:51:33 +0530 Subject: [PATCH] Fix TypeScript compilation errors across components, selectors, and profile module --- src/components/Button/index.tsx | 4 ++ src/components/DatePicker/index.tsx | 10 ++- .../agent/components/AgentSkeletonLoader.tsx | 3 +- src/modules/agent/components/CustomerCard.tsx | 2 +- src/modules/agent/services/agentApi.ts | 2 +- src/modules/agent/utils/agentMockData.ts | 2 +- .../cards/screens/CardsOverviewScreen.tsx | 2 +- .../home/screens/MiniStatementScreen.tsx | 2 +- src/modules/home/store/accountSelectors.ts | 1 + .../profile/screens/PrivacySettingsScreen.tsx | 2 +- src/modules/profile/services/profileApi.ts | 61 +++++++++++++------ 11 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index be4acaf..c27428d 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -8,6 +8,7 @@ import { type GestureResponderEvent, type StyleProp, type ViewStyle, + type TextStyle, } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; @@ -24,6 +25,7 @@ interface ButtonProps { loading?: boolean; fullWidth?: boolean; style?: StyleProp; + textStyle?: StyleProp; leftAccessory?: React.ReactNode; } @@ -35,6 +37,7 @@ const ButtonComponent = ({ loading = false, fullWidth = true, style, + textStyle, leftAccessory, }: ButtonProps) => { const theme = useTheme(); @@ -94,6 +97,7 @@ const ButtonComponent = ({ letterSpacing: variant === 'cyber' ? 2 : 0, textTransform: variant === 'cyber' ? 'uppercase' : 'none', }, + textStyle, ]} > {title} diff --git a/src/components/DatePicker/index.tsx b/src/components/DatePicker/index.tsx index 30d3e4b..48c0371 100644 --- a/src/components/DatePicker/index.tsx +++ b/src/components/DatePicker/index.tsx @@ -51,9 +51,13 @@ const parseDDMMYYYY = (str: string | undefined): Date | null => { if (!str) return null; const parts = str.split('/'); if (parts.length !== 3) return null; - const d = parseInt(parts[0], 10); - const m = parseInt(parts[1], 10) - 1; - const y = parseInt(parts[2], 10); + const part0 = parts[0]; + const part1 = parts[1]; + const part2 = parts[2]; + if (!part0 || !part1 || !part2) return null; + const d = parseInt(part0, 10); + const m = parseInt(part1, 10) - 1; + const y = parseInt(part2, 10); if (isNaN(d) || isNaN(m) || isNaN(y)) return null; return new Date(y, m, d); }; diff --git a/src/modules/agent/components/AgentSkeletonLoader.tsx b/src/modules/agent/components/AgentSkeletonLoader.tsx index 35d9804..d5bc0d1 100644 --- a/src/modules/agent/components/AgentSkeletonLoader.tsx +++ b/src/modules/agent/components/AgentSkeletonLoader.tsx @@ -32,7 +32,7 @@ export const AgentSkeletonLoader = ({ type }: AgentSkeletonLoaderProps) => { opacity: opacity.value, })); - const SkeletonBlock = ({ width = '100%', height = 20, borderRadius = 4, mb = 0 }: { width?: DimensionValue; height?: number; borderRadius?: number; mb?: number }) => ( + const SkeletonBlock = ({ width = '100%', height = 20, borderRadius = 4, mb = 0, mt = 0 }: { width?: DimensionValue; height?: number; borderRadius?: number; mb?: number; mt?: number }) => ( { height, borderRadius, marginBottom: mb, + marginTop: mt, backgroundColor: theme.colors.cardBorder, }, animatedStyle, diff --git a/src/modules/agent/components/CustomerCard.tsx b/src/modules/agent/components/CustomerCard.tsx index 5259557..c1e8a74 100644 --- a/src/modules/agent/components/CustomerCard.tsx +++ b/src/modules/agent/components/CustomerCard.tsx @@ -9,7 +9,7 @@ interface CustomerCardProps { customer: AgentCustomer; onPress?: () => void; onAction?: () => void; - actionIcon?: string; + actionIcon?: any; actionColor?: string; } diff --git a/src/modules/agent/services/agentApi.ts b/src/modules/agent/services/agentApi.ts index 2c7f4e9..ffc3e13 100644 --- a/src/modules/agent/services/agentApi.ts +++ b/src/modules/agent/services/agentApi.ts @@ -20,7 +20,7 @@ import { } from '../utils/agentMockData'; import { generateReceiptNumber } from '../utils/agentFormatters'; -const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); +const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); export const agentApi = baseApi.injectEndpoints({ endpoints: (builder) => ({ diff --git a/src/modules/agent/utils/agentMockData.ts b/src/modules/agent/utils/agentMockData.ts index 4a0809f..a031109 100644 --- a/src/modules/agent/utils/agentMockData.ts +++ b/src/modules/agent/utils/agentMockData.ts @@ -192,7 +192,7 @@ export const MOCK_LOAN_REQUESTS: AgentLoanRequest[] = [ export const MOCK_ROUTE: AgentRoute = { id: 'route-today', - date: new Date().toISOString().split('T')[0], + date: new Date().toISOString().split('T')[0] ?? '', totalDistance: '12.5 km', estimatedDuration: '2h 30m', completionPercent: 61, diff --git a/src/modules/cards/screens/CardsOverviewScreen.tsx b/src/modules/cards/screens/CardsOverviewScreen.tsx index dd445e6..8014369 100644 --- a/src/modules/cards/screens/CardsOverviewScreen.tsx +++ b/src/modules/cards/screens/CardsOverviewScreen.tsx @@ -196,7 +196,7 @@ export default function CardsOverviewScreen({ navigation }: Props) { const cardsStatus = useAppSelector(selectCardsStatus); const selectedCard = useAppSelector(selectSelectedCard); const selectedIndex = useAppSelector(selectSelectedCardIndex); - const accounts = useAppSelector((state) => state.account.accounts); + const accounts = useAppSelector(selectAllAccounts); const selectedTransactions = useMemo( () => diff --git a/src/modules/home/screens/MiniStatementScreen.tsx b/src/modules/home/screens/MiniStatementScreen.tsx index 4728ac8..2116c74 100644 --- a/src/modules/home/screens/MiniStatementScreen.tsx +++ b/src/modules/home/screens/MiniStatementScreen.tsx @@ -94,7 +94,7 @@ export default function MiniStatementScreen({ route }: Props) { const [isStartDatePickerVisible, setIsStartDatePickerVisible] = useState(false); const [isEndDatePickerVisible, setIsEndDatePickerVisible] = useState(false); - const accounts = useAppSelector(state => state.account.accounts); + const accounts = useAppSelector(selectAllAccounts); const allTransactions = useAppSelector(state => state.account.transactions); const account = accounts.find((item) => item.id === selectedId) ?? accounts[0]; diff --git a/src/modules/home/store/accountSelectors.ts b/src/modules/home/store/accountSelectors.ts index 321679f..7c0362e 100644 --- a/src/modules/home/store/accountSelectors.ts +++ b/src/modules/home/store/accountSelectors.ts @@ -13,3 +13,4 @@ export const selectSelectedAccount = createSelector( export const selectRecentTransactions = (state: RootState) => state.account.transactions; export const selectDashboardShortcuts = (state: RootState) => state.account.quickActions; +export const selectAllAccounts = (state: RootState) => state.account.accounts; diff --git a/src/modules/profile/screens/PrivacySettingsScreen.tsx b/src/modules/profile/screens/PrivacySettingsScreen.tsx index 43d7e89..650983d 100644 --- a/src/modules/profile/screens/PrivacySettingsScreen.tsx +++ b/src/modules/profile/screens/PrivacySettingsScreen.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, View, Text, ScrollView } from 'react-native'; +import { StyleSheet, View, Text, ScrollView, Alert } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { ScreenShell, Card } from '../../../components'; diff --git a/src/modules/profile/services/profileApi.ts b/src/modules/profile/services/profileApi.ts index 728b413..3d2a3c1 100644 --- a/src/modules/profile/services/profileApi.ts +++ b/src/modules/profile/services/profileApi.ts @@ -6,36 +6,57 @@ import { resolveWithMock } from '../../../services/api/serviceHelpers'; export const profileApi = baseApi.injectEndpoints({ endpoints: (builder) => ({ getProfile: builder.query({ - queryFn: () => resolveWithMock({ mockData: demoUser }), - providesTags: ['UserProfile'], + queryFn: () => + resolveWithMock({ + mockData: demoUser, + request: async () => demoUser, + }), + providesTags: ['Profile'], }), updateProfile: builder.mutation>({ - queryFn: (updates) => resolveWithMock({ mockData: { ...demoUser, ...updates } }), - invalidatesTags: ['UserProfile'], + queryFn: (updates) => { + const updated = { ...demoUser, ...updates }; + return resolveWithMock({ + mockData: updated, + request: async () => updated, + }); + }, + invalidatesTags: ['Profile'], }), getLinkedAccounts: builder.query({ - queryFn: () => resolveWithMock({ mockData: demoAccounts }), + queryFn: () => + resolveWithMock({ + mockData: demoAccounts, + request: async () => demoAccounts, + }), providesTags: ['Accounts'], }), addLinkedAccount: builder.mutation>({ - queryFn: (accountData) => - resolveWithMock({ - mockData: { - id: `acc_${Math.random().toString(36).substr(2, 9)}`, - type: 'Savings', - accountHolder: demoUser.firstName + ' ' + demoUser.lastName, - branch: 'Mumbai Main', - maskedNumber: `XXXX ${accountData.maskedNumber?.slice(-4) || '9999'}`, - availableBalance: 0, - currentBalance: 0, - currency: 'INR', - ...accountData, - } as AccountSummary, - }), + queryFn: (accountData) => { + const newAccount = { + id: `acc_${Math.random().toString(36).substr(2, 9)}`, + type: 'Savings', + accountHolder: demoUser.firstName + ' ' + demoUser.lastName, + branch: 'Mumbai Main', + maskedNumber: `XXXX ${accountData.maskedNumber?.slice(-4) || '9999'}`, + availableBalance: 0, + currentBalance: 0, + currency: 'INR', + ...accountData, + } as AccountSummary; + return resolveWithMock({ + mockData: newAccount, + request: async () => newAccount, + }); + }, invalidatesTags: ['Accounts'], }), removeLinkedAccount: builder.mutation({ - queryFn: () => resolveWithMock({ mockData: undefined }), + queryFn: () => + resolveWithMock({ + mockData: undefined as any, + request: async () => undefined as any, + }), invalidatesTags: ['Accounts'], }), }),