Fix TypeScript compilation errors across components, selectors, and profile module

This commit is contained in:
Abin Toppo
2026-05-26 16:51:33 +05:30
parent 9ac5e95d52
commit d7907e1d64
11 changed files with 61 additions and 30 deletions
+4
View File
@@ -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<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
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}
+7 -3
View File
@@ -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);
};
@@ -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 }) => (
<Animated.View
style={[
{
@@ -40,6 +40,7 @@ export const AgentSkeletonLoader = ({ type }: AgentSkeletonLoaderProps) => {
height,
borderRadius,
marginBottom: mb,
marginTop: mt,
backgroundColor: theme.colors.cardBorder,
},
animatedStyle,
@@ -9,7 +9,7 @@ interface CustomerCardProps {
customer: AgentCustomer;
onPress?: () => void;
onAction?: () => void;
actionIcon?: string;
actionIcon?: any;
actionColor?: string;
}
+1 -1
View File
@@ -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<void>(resolve => setTimeout(resolve, ms));
export const agentApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
+1 -1
View File
@@ -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,
@@ -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(
() =>
@@ -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];
@@ -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;
@@ -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';
+41 -20
View File
@@ -6,36 +6,57 @@ import { resolveWithMock } from '../../../services/api/serviceHelpers';
export const profileApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
getProfile: builder.query<UserProfile, void>({
queryFn: () => resolveWithMock({ mockData: demoUser }),
providesTags: ['UserProfile'],
queryFn: () =>
resolveWithMock({
mockData: demoUser,
request: async () => demoUser,
}),
providesTags: ['Profile'],
}),
updateProfile: builder.mutation<UserProfile, Partial<UserProfile>>({
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<AccountSummary[], void>({
queryFn: () => resolveWithMock({ mockData: demoAccounts }),
queryFn: () =>
resolveWithMock({
mockData: demoAccounts,
request: async () => demoAccounts,
}),
providesTags: ['Accounts'],
}),
addLinkedAccount: builder.mutation<AccountSummary, Partial<AccountSummary>>({
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<void, string>({
queryFn: () => resolveWithMock({ mockData: undefined }),
queryFn: () =>
resolveWithMock<void>({
mockData: undefined as any,
request: async () => undefined as any,
}),
invalidatesTags: ['Accounts'],
}),
}),