39 lines
751 B
TypeScript
39 lines
751 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|||
|
|
import {getUserPayments} from '@/app/actions/referralsActions';
|
||
|
|
|
||
|
|
export interface PaymentsData {
|
||
|
|
amount: number,
|
||
|
|
cancellationReason: string | null,
|
||
|
|
createdAt: string,
|
||
|
|
id: number,
|
||
|
|
operationType: string,
|
||
|
|
paymentUuid: string,
|
||
|
|
status: string,
|
||
|
|
updatedAt: string,
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
export interface UserPayments {
|
||
|
|
payments: PaymentsData[],
|
||
|
|
error: string | null
|
||
|
|
}
|
||
|
|
|
||
|
|
export const useGetReferralPayments = () => {
|
||
|
|
return useQuery({
|
||
|
|
queryKey: ['referralPayments'],
|
||
|
|
queryFn: getUserPayments,
|
||
|
|
select: (data): UserPayments => {
|
||
|
|
/* console.log('referralPayments');
|
||
|
|
console.log(data); */
|
||
|
|
if (!data) {
|
||
|
|
return {
|
||
|
|
payments: [],
|
||
|
|
error: null
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return data;
|
||
|
|
},
|
||
|
|
retry: false
|
||
|
|
});
|
||
|
|
};
|