2024-11-08 09:01:21 +00:00
|
|
|
import {
|
|
|
|
|
httpDeleteInterceptor,
|
|
|
|
|
httpGet,
|
|
|
|
|
httpPost,
|
2025-01-24 15:12:23 +00:00
|
|
|
httpPut,
|
2024-11-08 09:01:21 +00:00
|
|
|
} from "./http-config/axios-base-service";
|
2025-01-22 14:22:22 +00:00
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
|
|
|
|
|
const token = Cookies.get("access_token");
|
2025-01-24 15:12:23 +00:00
|
|
|
const id = Cookies.get("uie");
|
2024-04-24 10:10:26 +00:00
|
|
|
|
2024-12-02 13:19:30 +00:00
|
|
|
export async function listMasterUsers(data: any) {
|
2024-11-08 09:01:21 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
2024-12-02 13:19:30 +00:00
|
|
|
return await httpGet(`/users?page=${data.page}&limit=${data.limit}`, headers);
|
2024-04-24 10:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function createMasterUser(data: any) {
|
2024-11-08 09:01:21 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
const pathUrl = `/users`;
|
|
|
|
|
return await httpPost(pathUrl, headers, data);
|
2024-04-24 10:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-11 06:01:48 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 10:10:26 +00:00
|
|
|
export async function deleteMasterUser(id: string) {
|
2024-11-08 09:01:21 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-23 15:30:33 +00:00
|
|
|
export async function getProfile(code?: string) {
|
2024-11-08 09:01:21 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
2025-01-23 15:30:33 +00:00
|
|
|
Authorization: `Bearer ${code || token}`,
|
2024-11-08 09:01:21 +00:00
|
|
|
};
|
|
|
|
|
return await httpGet(`/users/info`, headers);
|
|
|
|
|
}
|
2025-01-24 15:12:23 +00:00
|
|
|
|
|
|
|
|
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 });
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 12:42:40 +00:00
|
|
|
export async function otpRequest(email: string, name: string) {
|
2025-01-24 15:12:23 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
2025-01-31 12:42:40 +00:00
|
|
|
return await httpPost(`/users/otp-request`, headers, { email, name });
|
2025-01-24 15:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function otpValidation(email: string, otpCode: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpPost(`/users/otp-validation`, headers, { email, otpCode });
|
|
|
|
|
}
|
2025-01-31 12:42:40 +00:00
|
|
|
|
|
|
|
|
export async function postArticleComment(data: any) {
|
2025-02-07 09:37:39 +00:00
|
|
|
const headers = token
|
|
|
|
|
? {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${token}`,
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
2025-01-31 12:42:40 +00:00
|
|
|
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}`);
|
|
|
|
|
}
|