2025-07-02 15:44:00 +00:00
|
|
|
import Cookies from "js-cookie";
|
2025-07-03 14:55:53 +00:00
|
|
|
import { httpGet, httpPost } from "./http-config/http-base-services";
|
|
|
|
|
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
2025-07-02 15:44:00 +00:00
|
|
|
|
|
|
|
|
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 pathUrl = `/users`;
|
2025-07-03 14:55:53 +00:00
|
|
|
return await httpPostInterceptor(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
2025-07-03 14:55:53 +00:00
|
|
|
|
2025-07-02 15:44:00 +00:00
|
|
|
export async function emailValidation(data: any) {
|
|
|
|
|
const pathUrl = `/users/email-validation`;
|
2025-07-03 14:55:53 +00:00
|
|
|
return await httpPost(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
export async function setupEmail(data: any) {
|
|
|
|
|
const pathUrl = `/users/setup-email`;
|
2025-07-03 14:55:53 +00:00
|
|
|
return await httpPost(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getDetailMasterUsers(id: string) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/detail/${id}`;
|
|
|
|
|
return await httpGetInterceptor(pathUrl);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function editMasterUsers(data: any, id: string) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/${id}`
|
|
|
|
|
return await httpPutInterceptor(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteMasterUser(id: string) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/${id}`
|
|
|
|
|
return await httpDeleteInterceptor(pathUrl);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function postSignIn(data: any) {
|
|
|
|
|
const pathUrl = `/users/login`;
|
2025-07-03 16:50:28 +00:00
|
|
|
return await httpPost(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 17:18:54 +00:00
|
|
|
export async function getProfile(token?: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
"Authorization": `Bearer ${token}`,
|
|
|
|
|
};
|
2025-07-03 16:50:28 +00:00
|
|
|
const pathUrl = `/users/info`;
|
2025-07-03 17:18:54 +00:00
|
|
|
return await httpGet(pathUrl, headers);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateProfile(data: any) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/${id}`;
|
|
|
|
|
return await httpPutInterceptor(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
export async function savePassword(data: any) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/save-password`
|
|
|
|
|
return await httpPostInterceptor(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/otp-request`;
|
|
|
|
|
return await httpPost(pathUrl, { email, name });
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function otpValidation(email: string, otpCode: string) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/users/otp-validation`
|
|
|
|
|
return await httpPost(pathUrl, { email, otpCode });
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/article-comments/${id}`;
|
|
|
|
|
return await httpPutInterceptor(pathUrl, data);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getArticleComment(id: string) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/article-comments?isPublic=true&articleId=${id}`;
|
|
|
|
|
return await httpGet(pathUrl);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteArticleComment(id: number) {
|
2025-07-03 14:55:53 +00:00
|
|
|
const pathUrl = `/article-comments/${id}`
|
|
|
|
|
return await httpDeleteInterceptor(pathUrl);
|
2025-07-02 15:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getCsrfToken() {
|
|
|
|
|
const pathUrl = "csrf-token";
|
2025-07-03 14:55:53 +00:00
|
|
|
return httpGet(pathUrl);
|
2025-07-03 06:57:17 +00:00
|
|
|
}
|