Files
no-copy-frontend/src/app/hooks/react-query/useGetReferralPayments.ts
T

39 lines
773 B
TypeScript
Raw Normal View History

2026-02-24 17:22:01 +07:00
import { useQuery } from '@tanstack/react-query';
2026-02-25 12:53:18 +07:00
import { getUserPayments } from '@/app/actions/referralsActions';
2026-02-24 17:22:01 +07:00
2026-02-25 12:53:18 +07:00
export interface ReferralPayments {
2026-02-24 17:22:01 +07:00
amount: number,
2026-02-25 12:53:18 +07:00
completedAt: string | null,
2026-02-24 17:22:01 +07:00
createdAt: string,
id: number,
2026-02-25 12:53:18 +07:00
processAt: string | null
rejectionReason: string | null,
2026-02-24 17:22:01 +07:00
status: string,
updatedAt: string,
}
2026-02-25 12:53:18 +07:00
export interface UserReferralPayments {
payments: ReferralPayments[],
2026-02-24 17:22:01 +07:00
error: string | null
}
export const useGetReferralPayments = () => {
return useQuery({
queryKey: ['referralPayments'],
queryFn: getUserPayments,
2026-02-25 12:53:18 +07:00
select: (data): UserReferralPayments => {
2026-02-24 17:22:01 +07:00
if (!data) {
return {
payments: [],
2026-02-25 12:53:18 +07:00
error: 'error'
2026-02-24 17:22:01 +07:00
}
}
2026-02-25 12:53:18 +07:00
return {
payments: data.payments,
error: data.error
}
2026-02-24 17:22:01 +07:00
},
retry: false
});
};