37 lines
696 B
TypeScript
37 lines
696 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { fetchPaymentsHistory } from '@/app/actions/yooKassa';
|
|
|
|
export interface PaymentsData {
|
|
amount: number,
|
|
cancellationReason: string | null,
|
|
createdAt: string,
|
|
id: number,
|
|
operationType: string,
|
|
paymentUuid: string,
|
|
status: string,
|
|
updatedAt: string,
|
|
}
|
|
|
|
|
|
export interface UserPaymentsData {
|
|
payments: PaymentsData[],
|
|
error: string | null
|
|
}
|
|
|
|
export const useUserPaymentsData = () => {
|
|
return useQuery({
|
|
queryKey: ['userPaymentsData'],
|
|
queryFn: fetchPaymentsHistory,
|
|
select: (data): UserPaymentsData => {
|
|
if (!data) {
|
|
return {
|
|
payments: [],
|
|
error: null
|
|
}
|
|
}
|
|
|
|
return data;
|
|
},
|
|
retry: false
|
|
});
|
|
}; |