From 92bea89d29fe9372c3e0542f8ab03022b93c9dc6 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Fri, 29 Aug 2025 13:43:53 +0700 Subject: [PATCH] fix:bearer --- services/advertisement.ts | 3 +++ services/article.ts | 6 ++++++ services/comment.ts | 2 ++ services/feedbacks.ts | 2 ++ services/magazine.tsx | 5 +++++ services/master-categories.tsx | 3 +++ services/master-user-level.ts | 5 +++++ services/master-user-role.ts | 1 + services/master-user.ts | 6 ++++++ services/static-page-service.ts | 4 ++++ services/user-levels/user-levels-service.ts | 1 + 11 files changed, 38 insertions(+) diff --git a/services/advertisement.ts b/services/advertisement.ts index 8679d7d..1ff1161 100644 --- a/services/advertisement.ts +++ b/services/advertisement.ts @@ -19,6 +19,7 @@ export async function createAdvertise(data: any) { export async function createMediaFileAdvertise(id: string | number, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; const pathUrl = `/advertisement/upload/${id}`; return await httpPost(pathUrl, headers, data); @@ -45,6 +46,7 @@ export async function createAdvertiseById(id: number) { export async function editAdvertise(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/advertisement/${data?.id}`; return await httpPut(pathUrl, headers, data); @@ -69,6 +71,7 @@ export async function editAdvertiseIsActive(data: any) { export async function deleteAdvertise(id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/advertisement/delete/${id}`; return await httpPut(pathUrl, headers); diff --git a/services/article.ts b/services/article.ts index 23e6f57..4e612da 100644 --- a/services/article.ts +++ b/services/article.ts @@ -118,6 +118,7 @@ export async function createArticleSchedule(data: any) { export async function updateArticle(id: string, data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/articles/${id}`; return await httpPut(pathUrl, headers, data); @@ -148,6 +149,7 @@ export async function getRecapArticleData(data: any) { export async function deleteArticle(id: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPut(`articles/delete/${id}`, headers); } @@ -174,12 +176,14 @@ export async function getCategoryPagination(data: any) { export async function uploadArticleFile(id: string, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPost(`/article-files/${id}`, headers, data); } export async function uploadArticleThumbnail(id: string, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPost(`/articles/thumbnail/${id}`, headers, data); } @@ -193,6 +197,7 @@ export async function uploadArticleThumbnail(id: string, data: any) { export async function deleteArticleFiles(id: number) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPut(`article-files/delete/${id}`, headers); } @@ -297,6 +302,7 @@ export async function submitApproval(data: { export async function updateIsBannerArticle(id: number, status: boolean) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/articles/banner/${id}?isBanner=${status}`; return await httpPut(pathUrl, headers); diff --git a/services/comment.ts b/services/comment.ts index 7ac40ff..c550b8f 100644 --- a/services/comment.ts +++ b/services/comment.ts @@ -21,6 +21,7 @@ export async function getComments(data: any) { export async function deleteComment(id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`/article-comments/${id}`, headers); } @@ -39,6 +40,7 @@ export async function saveCommentStatus(data: { }) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/article-comments/approval`; return await httpPost(pathUrl, headers, data); diff --git a/services/feedbacks.ts b/services/feedbacks.ts index 96d8f65..f32381a 100644 --- a/services/feedbacks.ts +++ b/services/feedbacks.ts @@ -11,6 +11,7 @@ const token = Cookies.get("access_token"); export async function createFeedback(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/feedbacks`; return await httpPost(pathUrl, headers, data); @@ -38,6 +39,7 @@ export async function getFeedbacksById(id: number) { export async function deleteFeedback(id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`/feedbacks/${id}`, headers); } diff --git a/services/magazine.tsx b/services/magazine.tsx index 9c76d36..13e2f73 100644 --- a/services/magazine.tsx +++ b/services/magazine.tsx @@ -34,6 +34,7 @@ export async function getListMagazine(props: PaginationRequest) { export async function updateMagazine(id: string, data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/magazines/${id}`; return await httpPut(pathUrl, headers, data); @@ -49,6 +50,7 @@ export async function getMagazineById(id: string) { export async function deleteMagazine(id: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`magazines/${id}`, headers); } @@ -56,6 +58,7 @@ export async function deleteMagazine(id: string) { export async function uploadMagazineFile(id: string, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPost(`/magazine-files/${id}`, headers, data); } @@ -63,6 +66,7 @@ export async function uploadMagazineFile(id: string, data: any) { export async function uploadMagazineThumbnail(id: string, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPost(`/magazines/thumbnail/${id}`, headers, data); } @@ -70,6 +74,7 @@ export async function uploadMagazineThumbnail(id: string, data: any) { export async function deleteMagazineFiles(id: number) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`magazine-files/${id}`, headers); } diff --git a/services/master-categories.tsx b/services/master-categories.tsx index 2d6d073..cc92b9f 100644 --- a/services/master-categories.tsx +++ b/services/master-categories.tsx @@ -20,6 +20,7 @@ export async function createCategory(data: any) { export async function updateCategory(id: string, data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/article-categories/${id}`; return await httpPut(pathUrl, headers, data); @@ -41,6 +42,7 @@ export async function getCategoryById(id: number) { export async function deleteCategory(id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPut(`article-categories/delete/${id}`, headers); } @@ -48,6 +50,7 @@ export async function deleteCategory(id: number) { export async function uploadCategoryThumbnail(id: string, data: any) { const headers = { "content-type": "multipart/form-data", + Authorization: `Bearer ${token}`, }; return await httpPost(`/article-categories/thumbnail/${id}`, headers, data); } diff --git a/services/master-user-level.ts b/services/master-user-level.ts index dcf1013..55d6f55 100644 --- a/services/master-user-level.ts +++ b/services/master-user-level.ts @@ -1,3 +1,4 @@ +import Cookies from "js-cookie"; import { httpDeleteInterceptor, httpGet, @@ -5,6 +6,8 @@ import { httpPut, } from "./http-config/axios-base-service"; +const token = Cookies.get("access_token"); + export async function createUserLevel(data: any) { const headers = { "content-type": "application/json", @@ -16,6 +19,7 @@ export async function createUserLevel(data: any) { export async function getUserLevel() { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpGet(`/user-levels?levelNumber=2&parentLevelId=79`, headers); } @@ -23,6 +27,7 @@ export async function getUserLevel() { export async function editUserLevel(data: any, id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/user-levels/${id}`; return await httpPut(pathUrl, headers, data); diff --git a/services/master-user-role.ts b/services/master-user-role.ts index eda2837..929c0cd 100644 --- a/services/master-user-role.ts +++ b/services/master-user-role.ts @@ -37,6 +37,7 @@ export async function getMasterUserRoleById(id: any) { export async function deleteMasterUserRole(id: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`/user-roles/${id}`, headers); } diff --git a/services/master-user.ts b/services/master-user.ts index 5825bbb..d9c0cae 100644 --- a/services/master-user.ts +++ b/services/master-user.ts @@ -26,6 +26,7 @@ export async function listMasterUsers(data: any) { export async function createMasterUser(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/users`; return await httpPost(pathUrl, headers, data); @@ -55,6 +56,7 @@ export async function getDetailMasterUsers(id: string) { export async function editMasterUsers(data: any, id: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPut(`/users/${id}`, headers, data); } @@ -62,6 +64,7 @@ export async function editMasterUsers(data: any, id: string) { export async function deleteMasterUser(id: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`/users/${id}`, headers); } @@ -101,6 +104,7 @@ export async function savePassword(data: any) { export async function resetPassword(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPost(`/users/reset-password`, headers, data); } @@ -108,6 +112,7 @@ export async function resetPassword(data: any) { export async function checkUsernames(username: string) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPost(`/users/forgot-password`, headers, { username }); } @@ -165,6 +170,7 @@ export async function getArticleComment(id: string) { export async function deleteArticleComment(id: number) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpDeleteInterceptor(`/article-comments/${id}`, headers); } diff --git a/services/static-page-service.ts b/services/static-page-service.ts index ad2a87d..6d7fb90 100644 --- a/services/static-page-service.ts +++ b/services/static-page-service.ts @@ -5,10 +5,13 @@ import { httpPost, httpPut, } from "./http-config/axios-base-service"; +import Cookies from "js-cookie"; +const token = Cookies.get("access_token"); export async function createCustomStaticPage(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/custom-static-pages`; return await httpPost(pathUrl, headers, data); @@ -17,6 +20,7 @@ export async function createCustomStaticPage(data: any) { export async function editCustomStaticPage(data: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; const pathUrl = `/custom-static-pages/${data.id}`; return await httpPut(pathUrl, headers, data); diff --git a/services/user-levels/user-levels-service.ts b/services/user-levels/user-levels-service.ts index e9b1fc6..14d9d76 100644 --- a/services/user-levels/user-levels-service.ts +++ b/services/user-levels/user-levels-service.ts @@ -37,6 +37,7 @@ export async function getAccountById(id: string) { export async function createUserLevels(request: any) { const headers = { "content-type": "application/json", + Authorization: `Bearer ${token}`, }; return await httpPost(`user-levels`, headers, request); }