Update free plan logic

This commit is contained in:
Tuan Dang
2023-07-10 13:48:46 +07:00
parent 25b1673321
commit e91e7f96c2
10 changed files with 180 additions and 32 deletions
+3 -1
View File
@@ -13,4 +13,6 @@ export {
useGetOrgPmtMethods,
useGetOrgTaxIds,
useRenameOrg,
useUpdateOrgBillingDetails} from "./queries";
useGetOrgTrialUrl,
useUpdateOrgBillingDetails
} from "./queries";
@@ -10,8 +10,10 @@ import {
PlanBillingInfo,
PmtMethod,
ProductsTable,
RenameOrgDTO,
TaxID} from "./types";
RenameOrgDTO,
GetOrgTrialUrlDTO,
TaxID
} from "./types";
const organizationKeys = {
getUserOrganization: ["organization"] as const,
@@ -47,6 +49,24 @@ export const useRenameOrg = () => {
});
};
export const useGetOrgTrialUrl = () => {
return useMutation({
mutationFn: async ({
orgId,
success_url
}: {
orgId: string;
success_url: string;
}) => {
const { data: { url } } = await apiRequest.post(`/api/v1/organizations/${orgId}/session/trial`, {
success_url
})
return url;
}
});
};
export const useGetOrgPlanBillingInfo = (organizationId: string) => {
return useQuery({
queryKey: organizationKeys.getOrgPlanBillingInfo(organizationId),
@@ -10,6 +10,11 @@ export type RenameOrgDTO = {
newOrgName: string;
};
export type GetOrgTrialUrlDTO = {
orgId: string;
success_url: string;
}
export type BillingDetails = {
name: string;
email: string;
@@ -15,4 +15,5 @@ export type SubscriptionPlan = {
environmentLimit: number;
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "canceled" | "unpaid" | null;
trial_end: number | null;
has_used_trial: boolean;
};