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> => axiosInstance.get("/users/pending", { headers: withHeaders(), params }); // Dashboard Information export const getUnitInfo = async ( params?: ExternalQueryParams ): Promise> => 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> => recordAxiosInstance.get(`/record-boxes/summary/${UnitId}`, { headers: withHeaders(), params, }); // 🔵 Get all users (both external_organization and employee) export const getAllExternalUsers = async ( params?: ExternalQueryParams ): Promise> => { 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> => { 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> => axiosInstance.delete(`/users/${id}`, { headers: withHeaders() }); export const getUserById = async (id: string): Promise> => axiosInstance.get(`/users/${id}`, { headers: withHeaders() }); // 🟢 Activate user export const activateUser = async (id: string): Promise> => axiosInstance.patch(`/users/activate-user/${id}`, null, { headers: withHeaders(), }); export const approveUser = async ( id: string, status: string ): Promise> => axiosInstance.patch( `/users/approve/${id}`, { status }, { headers: withHeaders(), } ); // 🟠 Deactivate user export const deactivateUser = async ( id: string ): Promise> => axiosInstance.patch(`/users/deactivate-user/${id}`, null, { headers: withHeaders(), }); export const getAllRecords = async ( UnitId: string, params?: ExternalQueryParams ): Promise> => recordAxiosInstance.get(`/record-boxes/unit-box/${UnitId}`, { headers: withHeaders(), params, });