Complete LDAP group mapping data structure + frontend/backend

This commit is contained in:
Tuan Dang
2024-04-23 13:58:23 -07:00
parent 2d51445dd9
commit 961c6391a8
16 changed files with 661 additions and 8 deletions
+20 -1
View File
@@ -2,8 +2,11 @@ import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { LDAPGroupMap } from "./types";
export const ldapConfigKeys = {
getLDAPConfig: (orgId: string) => [{ orgId }, "organization-ldap"] as const
getLDAPConfig: (orgId: string) => [{ orgId }, "organization-ldap"] as const,
getLDAPGroupMaps: (ldapConfigId: string) => [{ ldapConfigId }, "ldap-group-maps"] as const
};
export const useGetLDAPConfig = (organizationId: string) => {
@@ -17,3 +20,19 @@ export const useGetLDAPConfig = (organizationId: string) => {
enabled: true
});
};
export const useGetLDAPGroupMaps = (ldapConfigId: string) => {
return useQuery({
queryKey: ldapConfigKeys.getLDAPGroupMaps(ldapConfigId),
queryFn: async () => {
if (!ldapConfigId) return [];
const { data } = await apiRequest.get<LDAPGroupMap[]>(
`/api/v1/ldap/config/${ldapConfigId}/group-maps`
);
return data;
},
enabled: true
});
};