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
+2 -2
View File
@@ -7,6 +7,7 @@ export {
useGetOrganization,
useGetOrgBillingDetails,
useGetOrgInvoices,
useGetOrgLicenses,
useGetOrgPlanBillingInfo,
useGetOrgPlansTable,
useGetOrgPlanTable,
@@ -14,5 +15,4 @@ export {
useGetOrgTaxIds,
useGetOrgTrialUrl,
useRenameOrg,
useUpdateOrgBillingDetails
} from "./queries";
useUpdateOrgBillingDetails} from "./queries";
@@ -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
});
}
@@ -49,6 +49,17 @@ export type TaxID = {
value: string;
}
export type License = {
_id: string;
customerId: string;
prefix: string;
licenseKey: string;
isActivated: boolean;
expiresAt: string;
createdAt: string;
updatedAt: string;
}
export type OrgPlanTableHead = {
name: string;
}