mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 21:50:57 +00:00
user management ui
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import { withHeaders } from "@/record-management/services/api/withHeaders";
|
||||
import axiosInstance from "@/shared/services/axiosInstance";
|
||||
import recordAxiosInstance from "@/shared/services/recordAxiosInstance";
|
||||
import {
|
||||
ExternalUsersResponseDto,
|
||||
UserTypeDto,
|
||||
} from "@/super-admin/dto/ExternalUsersDto";
|
||||
import { MainDtoResponse } from "@/super-admin/dto/SuperAdminDto";
|
||||
import { ExternalQueryParams } from "@/super-admin/hooks/useExternalUsers";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
// 🔵 Get pending users
|
||||
export const getPendingUsers = async (
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<ExternalUsersResponseDto>> =>
|
||||
axiosInstance.get("/users/pending", { headers: withHeaders(), params });
|
||||
|
||||
// Dashboard Information
|
||||
export const getUnitInfo = async (
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<UserTypeDto>> =>
|
||||
recordAxiosInstance.get("/record-boxes/my-units-dashboard", {
|
||||
headers: withHeaders(),
|
||||
params,
|
||||
});
|
||||
|
||||
// unit infromation from super admin side
|
||||
export const getUnitInfoByUnitID = async (
|
||||
UnitId: string,
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<UserTypeDto>> =>
|
||||
recordAxiosInstance.get(`/record-boxes/summary/${UnitId}`, {
|
||||
headers: withHeaders(),
|
||||
params,
|
||||
});
|
||||
|
||||
// 🔵 Get all users (both external_organization and employee)
|
||||
export const getAllExternalUsers = async (
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<ExternalUsersResponseDto>> => {
|
||||
const queryParams = {
|
||||
...params,
|
||||
// No userType filter - fetch both external_organization and employee users
|
||||
};
|
||||
return axiosInstance.get("/users/filter", {
|
||||
headers: withHeaders(),
|
||||
params: queryParams,
|
||||
});
|
||||
};
|
||||
export const getExternalUsersNeesApproval = async (
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<ExternalUsersResponseDto>> => {
|
||||
const queryParams = {
|
||||
...params,
|
||||
// No userType filter - fetch both external_organization and employee users
|
||||
};
|
||||
return axiosInstance.get("/users/filter", {
|
||||
headers: withHeaders(),
|
||||
params: queryParams,
|
||||
});
|
||||
};
|
||||
|
||||
// 🔴 Delete user
|
||||
export const deleteUser = async (id: string): Promise<AxiosResponse<void>> =>
|
||||
axiosInstance.delete(`/users/${id}`, { headers: withHeaders() });
|
||||
|
||||
export const getUserById = async (id: string): Promise<AxiosResponse<any>> =>
|
||||
axiosInstance.get(`/users/${id}`, { headers: withHeaders() });
|
||||
|
||||
// 🟢 Activate user
|
||||
export const activateUser = async (id: string): Promise<AxiosResponse<void>> =>
|
||||
axiosInstance.patch(`/users/activate-user/${id}`, null, {
|
||||
headers: withHeaders(),
|
||||
});
|
||||
|
||||
export const approveUser = async (
|
||||
id: string,
|
||||
status: string
|
||||
): Promise<AxiosResponse<void>> =>
|
||||
axiosInstance.patch(
|
||||
`/users/approve/${id}`,
|
||||
{ status },
|
||||
{
|
||||
headers: withHeaders(),
|
||||
}
|
||||
);
|
||||
|
||||
// 🟠 Deactivate user
|
||||
export const deactivateUser = async (
|
||||
id: string
|
||||
): Promise<AxiosResponse<void>> =>
|
||||
axiosInstance.patch(`/users/deactivate-user/${id}`, null, {
|
||||
headers: withHeaders(),
|
||||
});
|
||||
|
||||
export const getAllRecords = async (
|
||||
UnitId: string,
|
||||
params?: ExternalQueryParams
|
||||
): Promise<AxiosResponse<MainDtoResponse>> =>
|
||||
recordAxiosInstance.get(`/record-boxes/unit-box/${UnitId}`, {
|
||||
headers: withHeaders(),
|
||||
params,
|
||||
});
|
||||
Reference in New Issue
Block a user