Continue ST V3 roles

This commit is contained in:
Tuan Dang
2023-11-23 11:56:56 +07:00
parent c37ff79927
commit 597e1e1ca8
49 changed files with 1104 additions and 390 deletions
@@ -14,6 +14,7 @@ export {
useGetOrgPlansTable,
useGetOrgPlanTable,
useGetOrgPmtMethods,
useGetOrgServiceMemberships,
useGetOrgTaxIds,
useGetOrgTrialUrl,
useRenameOrg,
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { ServiceMembershipOrg } from "../serviceTokens/types";
import {
BillingDetails,
Invoice,
@@ -15,7 +16,7 @@ import {
TaxID
} from "./types";
const organizationKeys = {
export const organizationKeys = {
getUserOrganizations: ["organization"] as const,
getOrgPlanBillingInfo: (orgId: string) => [{ orgId }, "organization-plan-billing"] as const,
getOrgPlanTable: (orgId: string) => [{ orgId }, "organization-plan-table"] as const,
@@ -25,7 +26,8 @@ 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
getOrgLicenses: (orgId: string) => [{ orgId }, "organization-licenses"] as const,
getOrgServiceMemberships: (orgId: string) => [{ orgId }, "organization-service-memberships"] as const,
};
export const fetchOrganizations = async () => {
@@ -349,6 +351,22 @@ export const useGetOrgLicenses = (organizationId: string) => {
});
};
export const useGetOrgServiceMemberships = (organizationId: string) => {
return useQuery({
queryKey: organizationKeys.getOrgServiceMemberships(organizationId),
queryFn: async () => {
const {
data: { serviceMemberships }
} = await apiRequest.get<{ serviceMemberships: ServiceMembershipOrg[] }>(
`/api/v2/organizations/${organizationId}/service-memberships`
);
return serviceMemberships;
},
enabled: true
});
};
export const useDeleteOrgById = () => {
const queryClient = useQueryClient();