web-humas-fe/service/master-user.ts

89 lines
2.3 KiB
TypeScript

import {
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
const id = Cookies.get("uie");
export async function listMasterUsers(data: any) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/users?page=${data.page}&limit=${data.limit}`, headers);
}
export async function createMasterUser(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/users`;
return await httpPost(pathUrl, headers, data);
}
export async function deleteMasterUser(id: string) {
return await httpDeleteInterceptor(`/users/${id}`);
}
export async function postSignIn(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/users/login`;
return await httpPost(pathUrl, headers, data);
}
export async function getProfile(code?: string) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${code || token}`,
};
return await httpGet(`/users/info`, headers);
}
export async function updateProfile(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
return await httpPut(`/users/${id}`, headers, data);
}
export async function savePassword(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
return await httpPost(`/users/save-password`, headers, data);
}
export async function resetPassword(data: any) {
const headers = {
"content-type": "application/json",
};
return await httpPost(`/users/reset-password`, headers, data);
}
export async function checkUsernames(username: string) {
const headers = {
"content-type": "application/json",
};
return await httpPost(`/users/forgot-password`, headers, { username });
}
export async function otpRequest(email: string) {
const headers = {
"content-type": "application/json",
};
return await httpPost(`/users/otp-request`, headers, { email });
}
export async function otpValidation(email: string, otpCode: string) {
const headers = {
"content-type": "application/json",
};
return await httpPost(`/users/otp-validation`, headers, { email, otpCode });
}