mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
104 lines
3.0 KiB
TypeScript
104 lines
3.0 KiB
TypeScript
import { withHeaders } from "@/record-management/services/api/withHeaders";
|
|
import axiosInstance from "@/shared/services/axiosInstance";
|
|
import { AxiosResponse } from "axios";
|
|
|
|
export interface UserRoleHeaders {
|
|
delegatorPositionId: string;
|
|
currentProjectId?: string;
|
|
}
|
|
|
|
|
|
export interface RemoveOrAssignUnitAdminPayload {
|
|
unitId: string;
|
|
userId: string;
|
|
}
|
|
|
|
export interface RemoveOrAssignOrgAdminPayload {
|
|
organizationId: string;
|
|
userId: string;
|
|
}
|
|
|
|
// Assign Org Admin Role
|
|
export const assignOrgAdminRole = async (
|
|
payload: RemoveOrAssignOrgAdminPayload
|
|
): Promise<AxiosResponse> =>
|
|
axiosInstance.post("/user-roles/assign-org-admin-role", payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Remove Org Admin Role
|
|
export const removeOrgAdminRole = async (
|
|
payload: RemoveOrAssignOrgAdminPayload
|
|
): Promise<AxiosResponse> =>
|
|
axiosInstance.post("/user-roles/remove-org-admin-role", payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
//Assign unit Admin Role
|
|
export const assignUnitAdminRole = async (
|
|
payload: RemoveOrAssignUnitAdminPayload
|
|
): Promise<AxiosResponse> =>
|
|
axiosInstance.post("/user-roles/assign-unit-admin-role", payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Remove Unit Admin Role
|
|
export const removeUnitAdminRole = async (
|
|
payload: RemoveOrAssignUnitAdminPayload
|
|
): Promise<AxiosResponse> =>
|
|
axiosInstance.post("/user-roles/remove-unit-admin-role", payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Get roles given first (e.g., user has been assigned roles)
|
|
export const getRolesGivenFirst = async (id: string): Promise<AxiosResponse> =>
|
|
axiosInstance.get(`/user-roles/given-first/${id}`, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Get roles given second (e.g., entities assigned to a user)
|
|
export const getRolesGivenSecond = async (id: string): Promise<AxiosResponse> =>
|
|
axiosInstance.get(`/user-roles/given-second/${id}`, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Assign firsts for second
|
|
export const assignFirstsForSecond = async (payload: {
|
|
secondId: string;
|
|
firstIds: string[];
|
|
}): Promise<AxiosResponse> =>
|
|
axiosInstance.post(`/user-roles/assign-firsts-for-second`, payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Assign seconds for first
|
|
export const assignSecondsForFirst = async (payload: {
|
|
firstId: string;
|
|
secondIds: string[];
|
|
}): Promise<AxiosResponse> =>
|
|
axiosInstance.post(`/user-roles/assign-seconds-for-first`, payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Delete user role by id
|
|
export const deleteUserRole = async (id: string): Promise<AxiosResponse> =>
|
|
axiosInstance.delete(`/user-roles/${id}`, { headers: withHeaders() });
|
|
|
|
// Remove firsts for second
|
|
export const removeFirstsForSecond = async (payload: {
|
|
secondId: string;
|
|
firstIds: string[];
|
|
}): Promise<AxiosResponse> =>
|
|
axiosInstance.post(`/user-roles/remove-firsts-for-second`, payload, {
|
|
headers: withHeaders(),
|
|
});
|
|
|
|
// Remove seconds for first
|
|
export const removeSecondsForFirst = async (payload: {
|
|
firstId: string;
|
|
secondIds: string[];
|
|
}): Promise<AxiosResponse> =>
|
|
axiosInstance.post(`/user-roles/remove-seconds-for-first`, payload, {
|
|
headers: withHeaders(),
|
|
});
|