import {Payment} from "@/interfaces/paypal";
import {Group, User} from "@/interfaces/user";
import axios from "axios";
import {useEffect, useState} from "react";

export default function usePayments() {
	const [payments, setPayments] = useState<Payment[]>([]);
	const [isLoading, setIsLoading] = useState(false);
	const [isError, setIsError] = useState(false);

	const getData = () => {
		setIsLoading(true);
		axios
			.get<Payment[]>("/api/payments")
			.then((response) => {
				return setPayments(response.data);
			})
			.finally(() => setIsLoading(false));
	};

	useEffect(getData, []);

	return {payments, isLoading, isError, reload: getData};
}
