134 lines
3.5 KiB
TypeScript
134 lines
3.5 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 getDetailMasterUsers(id: string) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpGet(`/users/detail/${id}`, headers);
|
|
}
|
|
|
|
export async function editMasterUsers(data: any) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpPut(`/users/${id}`, 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, name: string) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpPost(`/users/otp-request`, headers, { email, name });
|
|
}
|
|
|
|
export async function otpValidation(email: string, otpCode: string) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpPost(`/users/otp-validation`, headers, { email, otpCode });
|
|
}
|
|
|
|
export async function postArticleComment(data: any) {
|
|
const headers = token
|
|
? {
|
|
"content-type": "application/json",
|
|
Authorization: `Bearer ${token}`,
|
|
}
|
|
: {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpPost(`/article-comments`, headers, data);
|
|
}
|
|
|
|
export async function editArticleComment(data: any, id: number) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
Authorization: `Bearer ${token}`,
|
|
};
|
|
return await httpPut(`/article-comments/${id}`, headers, data);
|
|
}
|
|
|
|
export async function getArticleComment(id: string) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpGet(`/article-comments?articleId=${id}`, headers);
|
|
}
|
|
|
|
export async function deleteArticleComment(id: number) {
|
|
return await httpDeleteInterceptor(`/article-comments/${id}`);
|
|
}
|