Files
formbricks/apps/web/modules/utils/hooks/useGetBillingInfo.ts
Piyush Gupta 1af1a92fec feat: granular team roles (#3975)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
Co-authored-by: Johannes <johannes@formbricks.com>
2024-11-08 06:03:14 +00:00

34 lines
1008 B
TypeScript

import { useEffect, useState } from "react";
import { TOrganizationBilling } from "@formbricks/types/organizations";
import { getOrganizationBillingInfoAction } from "./actions";
export const useGetBillingInfo = (organizationId: string) => {
const [billingInfo, setBillingInfo] = useState<TOrganizationBilling>();
const [isLoading, setIsLoading] = useState<boolean>(false);
const [error, setError] = useState<string>("");
useEffect(() => {
const getBillingInfo = async () => {
try {
setIsLoading(true);
const billingInfo = await getOrganizationBillingInfoAction({ organizationId });
if (billingInfo?.data) {
setIsLoading(false);
setBillingInfo(billingInfo.data);
}
setError("No billing info found");
setIsLoading(false);
} catch (err: any) {
setIsLoading(false);
setError(err.message);
}
};
getBillingInfo();
}, [organizationId]);
return { billingInfo, isLoading, error };
};