import {PaypalPayment} from "@/interfaces/paypal"; import axios from "axios"; import {useEffect, useState} from "react"; export default function usePaypalPayments() { const [payments, setPayments] = useState([]); const [isLoading, setIsLoading] = useState(false); const [isError, setIsError] = useState(false); const getData = () => { setIsLoading(true); axios .get("/api/payments/paypal") .then((response) => { return setPayments(response.data); }) .finally(() => setIsLoading(false)); }; useEffect(getData, []); return {payments, isLoading, isError, reload: getData}; }