mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-25 03:39:31 -05:00
33919578dd
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
35 lines
948 B
TypeScript
35 lines
948 B
TypeScript
import { TTeamBilling } from "@formbricks/types/teams";
|
|
import { useState, useEffect } from "react";
|
|
import { getTeamBillingInfoAction } from "./actions";
|
|
|
|
export const useGetBillingInfo = (teamId: string) => {
|
|
const [billingInfo, setBillingInfo] = useState<TTeamBilling>();
|
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
const [error, setError] = useState<string>("");
|
|
|
|
useEffect(() => {
|
|
const getBillingInfo = async () => {
|
|
try {
|
|
setIsLoading(true);
|
|
const billingInfo = await getTeamBillingInfoAction(teamId);
|
|
|
|
if (!billingInfo) {
|
|
setError("No billing info found");
|
|
setIsLoading(false);
|
|
return;
|
|
}
|
|
|
|
setIsLoading(false);
|
|
setBillingInfo(billingInfo);
|
|
} catch (err: any) {
|
|
setIsLoading(false);
|
|
setError(err.message);
|
|
}
|
|
};
|
|
|
|
getBillingInfo();
|
|
}, [teamId]);
|
|
|
|
return { billingInfo, isLoading, error };
|
|
};
|