155 lines
3.9 KiB
TypeScript
155 lines
3.9 KiB
TypeScript
import {
|
|
httpDeleteInterceptor,
|
|
httpGetInterceptor,
|
|
httpPostInterceptor,
|
|
httpPutInterceptor,
|
|
} from "../http-config/http-interceptor-service";
|
|
|
|
// User CRUD Operations
|
|
export interface CreateUserRequest {
|
|
address: string;
|
|
clientId: string;
|
|
dateOfBirth: string;
|
|
email: string;
|
|
fullname: string;
|
|
password: string;
|
|
phoneNumber: string;
|
|
userLevelId: number;
|
|
userRoleId: number;
|
|
username: string;
|
|
}
|
|
|
|
export interface UpdateUserRequest extends Partial<CreateUserRequest> {
|
|
id?: number;
|
|
}
|
|
|
|
export async function getUserListAll() {
|
|
const url = `users/pagination/all?enablePage=0`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function AdministrationUserList(
|
|
id: string,
|
|
page: number,
|
|
name = "",
|
|
size: string,
|
|
featureId: string,
|
|
role = "",
|
|
) {
|
|
const url = `users/pagination/internal?enablePage=1&size=${size}&page=${page}&levelId=${id}&name=${name}&featureId=${featureId}&roleFilter=${role}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getAllUsers({
|
|
count = 1,
|
|
limit = 10,
|
|
nextPage = 1,
|
|
page = 1,
|
|
previousPage = 1,
|
|
sort = "desc",
|
|
sortBy = "id",
|
|
totalPage = 10,
|
|
}: {
|
|
count?: number;
|
|
limit?: number;
|
|
nextPage?: number;
|
|
page?: number;
|
|
previousPage?: number;
|
|
sort?: string;
|
|
sortBy?: string;
|
|
totalPage?: number;
|
|
}) {
|
|
const url = `users?count=${count}&limit=${limit}&nextPage=${nextPage}&page=${page}&previousPage=${previousPage}&sort=${sort}&sortBy=${sortBy}&totalPage=${totalPage}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function AdministrationLevelList() {
|
|
const url = "users/user-levels/list";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getListEducation() {
|
|
const url = "users/user-educations/list";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getListSchools() {
|
|
const url = "users/user-schools/list";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getListCompetencies() {
|
|
const url = "users/user-competencies/list";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function updateUserInternal(id: number, data: any) {
|
|
const url = `users/${id}`;
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function getListExperiences() {
|
|
const url = "users/user-experiences/list";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function saveUserInternal(data: any) {
|
|
const url = "users/save";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function checkRolePlacementsAvailability(data: any) {
|
|
const url = "users/role-placements/availability";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function saveUserRolePlacements(data: any) {
|
|
const url = "users/role-placements";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function getUserRolePlacements(userId: number) {
|
|
const url = `users/role-placements?userId=${userId}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getUserById(id: string) {
|
|
const url = `users?id=${id}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function disableUser(userId: number | string) {
|
|
const url = `users/disable-user?userId=${userId}`;
|
|
return httpPostInterceptor(url);
|
|
}
|
|
|
|
export async function deleteUser(userId: number | string) {
|
|
const url = `users/delete-user?userId=${userId}`;
|
|
return httpDeleteInterceptor(url);
|
|
}
|
|
|
|
export async function getOperatorUser(typeId: any) {
|
|
const url = `users/search-operator-user?code=opt-id&typeId=${typeId}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function createUser(data: CreateUserRequest) {
|
|
const url = "users";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function updateUser(id: number, data: UpdateUserRequest) {
|
|
const url = `users/${id}`;
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function deleteUserById(id: number) {
|
|
const url = `users/${id}`;
|
|
return httpDeleteInterceptor(url);
|
|
}
|
|
|
|
export async function getUserDetail(id: number) {
|
|
const url = `users/detail/${id}`;
|
|
return httpGetInterceptor(url);
|
|
}
|