Added integration for paypal payments
This commit is contained in:
23
src/hooks/usePaypalPayments.tsx
Normal file
23
src/hooks/usePaypalPayments.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import {PaypalPayment} from "@/interfaces/paypal";
|
||||
import axios from "axios";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export default function usePaypalPayments() {
|
||||
const [payments, setPayments] = useState<PaypalPayment[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isError, setIsError] = useState(false);
|
||||
|
||||
const getData = () => {
|
||||
setIsLoading(true);
|
||||
axios
|
||||
.get<PaypalPayment[]>("/api/payments/paypal")
|
||||
.then((response) => {
|
||||
return setPayments(response.data);
|
||||
})
|
||||
.finally(() => setIsLoading(false));
|
||||
};
|
||||
|
||||
useEffect(getData, []);
|
||||
|
||||
return {payments, isLoading, isError, reload: getData};
|
||||
}
|
||||
Reference in New Issue
Block a user