add payments history tanstak-table
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user