Fix TypeScript compilation errors across components, selectors, and profile module
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
type GestureResponderEvent,
|
type GestureResponderEvent,
|
||||||
type StyleProp,
|
type StyleProp,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
|
type TextStyle,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import LinearGradient from 'react-native-linear-gradient';
|
import LinearGradient from 'react-native-linear-gradient';
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ interface ButtonProps {
|
|||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
fullWidth?: boolean;
|
fullWidth?: boolean;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
|
textStyle?: StyleProp<TextStyle>;
|
||||||
leftAccessory?: React.ReactNode;
|
leftAccessory?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ const ButtonComponent = ({
|
|||||||
loading = false,
|
loading = false,
|
||||||
fullWidth = true,
|
fullWidth = true,
|
||||||
style,
|
style,
|
||||||
|
textStyle,
|
||||||
leftAccessory,
|
leftAccessory,
|
||||||
}: ButtonProps) => {
|
}: ButtonProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -94,6 +97,7 @@ const ButtonComponent = ({
|
|||||||
letterSpacing: variant === 'cyber' ? 2 : 0,
|
letterSpacing: variant === 'cyber' ? 2 : 0,
|
||||||
textTransform: variant === 'cyber' ? 'uppercase' : 'none',
|
textTransform: variant === 'cyber' ? 'uppercase' : 'none',
|
||||||
},
|
},
|
||||||
|
textStyle,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{title}
|
{title}
|
||||||
|
|||||||
@@ -51,9 +51,13 @@ const parseDDMMYYYY = (str: string | undefined): Date | null => {
|
|||||||
if (!str) return null;
|
if (!str) return null;
|
||||||
const parts = str.split('/');
|
const parts = str.split('/');
|
||||||
if (parts.length !== 3) return null;
|
if (parts.length !== 3) return null;
|
||||||
const d = parseInt(parts[0], 10);
|
const part0 = parts[0];
|
||||||
const m = parseInt(parts[1], 10) - 1;
|
const part1 = parts[1];
|
||||||
const y = parseInt(parts[2], 10);
|
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;
|
if (isNaN(d) || isNaN(m) || isNaN(y)) return null;
|
||||||
return new Date(y, m, d);
|
return new Date(y, m, d);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const AgentSkeletonLoader = ({ type }: AgentSkeletonLoaderProps) => {
|
|||||||
opacity: opacity.value,
|
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
|
<Animated.View
|
||||||
style={[
|
style={[
|
||||||
{
|
{
|
||||||
@@ -40,6 +40,7 @@ export const AgentSkeletonLoader = ({ type }: AgentSkeletonLoaderProps) => {
|
|||||||
height,
|
height,
|
||||||
borderRadius,
|
borderRadius,
|
||||||
marginBottom: mb,
|
marginBottom: mb,
|
||||||
|
marginTop: mt,
|
||||||
backgroundColor: theme.colors.cardBorder,
|
backgroundColor: theme.colors.cardBorder,
|
||||||
},
|
},
|
||||||
animatedStyle,
|
animatedStyle,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ interface CustomerCardProps {
|
|||||||
customer: AgentCustomer;
|
customer: AgentCustomer;
|
||||||
onPress?: () => void;
|
onPress?: () => void;
|
||||||
onAction?: () => void;
|
onAction?: () => void;
|
||||||
actionIcon?: string;
|
actionIcon?: any;
|
||||||
actionColor?: string;
|
actionColor?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
} from '../utils/agentMockData';
|
} from '../utils/agentMockData';
|
||||||
import { generateReceiptNumber } from '../utils/agentFormatters';
|
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({
|
export const agentApi = baseApi.injectEndpoints({
|
||||||
endpoints: (builder) => ({
|
endpoints: (builder) => ({
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ export const MOCK_LOAN_REQUESTS: AgentLoanRequest[] = [
|
|||||||
|
|
||||||
export const MOCK_ROUTE: AgentRoute = {
|
export const MOCK_ROUTE: AgentRoute = {
|
||||||
id: 'route-today',
|
id: 'route-today',
|
||||||
date: new Date().toISOString().split('T')[0],
|
date: new Date().toISOString().split('T')[0] ?? '',
|
||||||
totalDistance: '12.5 km',
|
totalDistance: '12.5 km',
|
||||||
estimatedDuration: '2h 30m',
|
estimatedDuration: '2h 30m',
|
||||||
completionPercent: 61,
|
completionPercent: 61,
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ export default function CardsOverviewScreen({ navigation }: Props) {
|
|||||||
const cardsStatus = useAppSelector(selectCardsStatus);
|
const cardsStatus = useAppSelector(selectCardsStatus);
|
||||||
const selectedCard = useAppSelector(selectSelectedCard);
|
const selectedCard = useAppSelector(selectSelectedCard);
|
||||||
const selectedIndex = useAppSelector(selectSelectedCardIndex);
|
const selectedIndex = useAppSelector(selectSelectedCardIndex);
|
||||||
const accounts = useAppSelector((state) => state.account.accounts);
|
const accounts = useAppSelector(selectAllAccounts);
|
||||||
|
|
||||||
const selectedTransactions = useMemo(
|
const selectedTransactions = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export default function MiniStatementScreen({ route }: Props) {
|
|||||||
const [isStartDatePickerVisible, setIsStartDatePickerVisible] = useState(false);
|
const [isStartDatePickerVisible, setIsStartDatePickerVisible] = useState(false);
|
||||||
const [isEndDatePickerVisible, setIsEndDatePickerVisible] = 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 allTransactions = useAppSelector(state => state.account.transactions);
|
||||||
const account = accounts.find((item) => item.id === selectedId) ?? accounts[0];
|
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 selectRecentTransactions = (state: RootState) => state.account.transactions;
|
||||||
export const selectDashboardShortcuts = (state: RootState) => state.account.quickActions;
|
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 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 { NativeStackScreenProps } from '@react-navigation/native-stack';
|
||||||
|
|
||||||
import { ScreenShell, Card } from '../../../components';
|
import { ScreenShell, Card } from '../../../components';
|
||||||
|
|||||||
@@ -6,36 +6,57 @@ import { resolveWithMock } from '../../../services/api/serviceHelpers';
|
|||||||
export const profileApi = baseApi.injectEndpoints({
|
export const profileApi = baseApi.injectEndpoints({
|
||||||
endpoints: (builder) => ({
|
endpoints: (builder) => ({
|
||||||
getProfile: builder.query<UserProfile, void>({
|
getProfile: builder.query<UserProfile, void>({
|
||||||
queryFn: () => resolveWithMock({ mockData: demoUser }),
|
queryFn: () =>
|
||||||
providesTags: ['UserProfile'],
|
resolveWithMock({
|
||||||
|
mockData: demoUser,
|
||||||
|
request: async () => demoUser,
|
||||||
|
}),
|
||||||
|
providesTags: ['Profile'],
|
||||||
}),
|
}),
|
||||||
updateProfile: builder.mutation<UserProfile, Partial<UserProfile>>({
|
updateProfile: builder.mutation<UserProfile, Partial<UserProfile>>({
|
||||||
queryFn: (updates) => resolveWithMock({ mockData: { ...demoUser, ...updates } }),
|
queryFn: (updates) => {
|
||||||
invalidatesTags: ['UserProfile'],
|
const updated = { ...demoUser, ...updates };
|
||||||
|
return resolveWithMock({
|
||||||
|
mockData: updated,
|
||||||
|
request: async () => updated,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
invalidatesTags: ['Profile'],
|
||||||
}),
|
}),
|
||||||
getLinkedAccounts: builder.query<AccountSummary[], void>({
|
getLinkedAccounts: builder.query<AccountSummary[], void>({
|
||||||
queryFn: () => resolveWithMock({ mockData: demoAccounts }),
|
queryFn: () =>
|
||||||
|
resolveWithMock({
|
||||||
|
mockData: demoAccounts,
|
||||||
|
request: async () => demoAccounts,
|
||||||
|
}),
|
||||||
providesTags: ['Accounts'],
|
providesTags: ['Accounts'],
|
||||||
}),
|
}),
|
||||||
addLinkedAccount: builder.mutation<AccountSummary, Partial<AccountSummary>>({
|
addLinkedAccount: builder.mutation<AccountSummary, Partial<AccountSummary>>({
|
||||||
queryFn: (accountData) =>
|
queryFn: (accountData) => {
|
||||||
resolveWithMock({
|
const newAccount = {
|
||||||
mockData: {
|
id: `acc_${Math.random().toString(36).substr(2, 9)}`,
|
||||||
id: `acc_${Math.random().toString(36).substr(2, 9)}`,
|
type: 'Savings',
|
||||||
type: 'Savings',
|
accountHolder: demoUser.firstName + ' ' + demoUser.lastName,
|
||||||
accountHolder: demoUser.firstName + ' ' + demoUser.lastName,
|
branch: 'Mumbai Main',
|
||||||
branch: 'Mumbai Main',
|
maskedNumber: `XXXX ${accountData.maskedNumber?.slice(-4) || '9999'}`,
|
||||||
maskedNumber: `XXXX ${accountData.maskedNumber?.slice(-4) || '9999'}`,
|
availableBalance: 0,
|
||||||
availableBalance: 0,
|
currentBalance: 0,
|
||||||
currentBalance: 0,
|
currency: 'INR',
|
||||||
currency: 'INR',
|
...accountData,
|
||||||
...accountData,
|
} as AccountSummary;
|
||||||
} as AccountSummary,
|
return resolveWithMock({
|
||||||
}),
|
mockData: newAccount,
|
||||||
|
request: async () => newAccount,
|
||||||
|
});
|
||||||
|
},
|
||||||
invalidatesTags: ['Accounts'],
|
invalidatesTags: ['Accounts'],
|
||||||
}),
|
}),
|
||||||
removeLinkedAccount: builder.mutation<void, string>({
|
removeLinkedAccount: builder.mutation<void, string>({
|
||||||
queryFn: () => resolveWithMock({ mockData: undefined }),
|
queryFn: () =>
|
||||||
|
resolveWithMock<void>({
|
||||||
|
mockData: undefined as any,
|
||||||
|
request: async () => undefined as any,
|
||||||
|
}),
|
||||||
invalidatesTags: ['Accounts'],
|
invalidatesTags: ['Accounts'],
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user