Add section for users to view purchased enterprise license keys in organization usage and billing section

This commit is contained in:
Tuan Dang
2023-08-03 11:48:10 +07:00
parent 62fa59619b
commit bc65bf1238
11 changed files with 153 additions and 7 deletions
@@ -5,14 +5,14 @@ import { apiRequest } from "@app/config/request";
import {
BillingDetails,
Invoice,
License,
Organization,
OrgPlanTable,
PlanBillingInfo,
PmtMethod,
ProductsTable,
RenameOrgDTO,
TaxID
} from "./types";
TaxID} from "./types";
const organizationKeys = {
getUserOrganization: ["organization"] as const,
@@ -23,6 +23,7 @@ const organizationKeys = {
getOrgPmtMethods: (orgId: string) => [{ orgId }, "organization-pmt-methods"] as const,
getOrgTaxIds: (orgId: string) => [{ orgId }, "organization-tax-ids"] as const,
getOrgInvoices: (orgId: string) => [{ orgId }, "organization-invoices"] as const,
getOrgLicenses: (orgId: string) => [{ orgId }, "organization-licenses"] as const
};
export const useGetOrganization = () => {
@@ -311,4 +312,20 @@ export const useCreateCustomerPortalSession = () => {
return data;
}
});
};
};
export const useGetOrgLicenses = (organizationId: string) => {
return useQuery({
queryKey: organizationKeys.getOrgLicenses(organizationId),
queryFn: async () => {
if (organizationId === "") return undefined;
const { data } = await apiRequest.get<License[]>(
`/api/v1/organizations/${organizationId}/licenses`
);
return data;
},
enabled: true
});
}