2026-02-21 15:07:37 +07:00
|
|
|
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;
|
|
|
|
|
},
|
2026-03-30 14:51:48 +07:00
|
|
|
refetchInterval: 10000,
|
2026-02-21 15:07:37 +07:00
|
|
|
retry: false
|
|
|
|
|
});
|
|
|
|
|
};
|