From 0413d190e10edc676668e61c8ddd35bc0c6f87f1 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Sun, 25 May 2025 16:23:15 +0700 Subject: [PATCH] fix:article bearer --- .../main/dashboard/dashboard-container.tsx | 3 +- components/table/article-table.tsx | 4 +-- services/article.ts | 34 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/components/main/dashboard/dashboard-container.tsx b/components/main/dashboard/dashboard-container.tsx index be68314..d4e9e2a 100644 --- a/components/main/dashboard/dashboard-container.tsx +++ b/components/main/dashboard/dashboard-container.tsx @@ -30,6 +30,7 @@ import Link from "next/link"; import { useEffect, useState } from "react"; import { getListArticle, + getListArticleAdminPage, getStatisticSummary, getTopArticles, getUserLevelDataStat, @@ -108,7 +109,7 @@ export default function DashboardContainer() { page: page, search: "", }; - const res = await getListArticle(req); + const res = await getListArticleAdminPage(req); setArticle(res.data?.data); setTotalPage(res?.data?.meta?.totalPage); } diff --git a/components/table/article-table.tsx b/components/table/article-table.tsx index e55cec3..b95d846 100644 --- a/components/table/article-table.tsx +++ b/components/table/article-table.tsx @@ -14,6 +14,7 @@ import { deleteArticle, getArticleByCategory, getListArticle, + getListArticleAdminPage, updateIsBannerArticle, } from "@/services/article"; import { Article } from "@/types/globals"; @@ -197,7 +198,6 @@ export default function ArticleTable() { async function initState() { loading(); - console.log("test", getIds(selectedCategories)); const req = { limit: showData, page: page, @@ -209,7 +209,7 @@ export default function ArticleTable() { sort: "desc", sortBy: "created_at", }; - const res = await getListArticle(req); + const res = await getListArticleAdminPage(req); await getTableNumber(parseInt(showData), res.data?.data); setTotalPage(res?.data?.meta?.totalPage); close(); diff --git a/services/article.ts b/services/article.ts index 235e578..4264e1f 100644 --- a/services/article.ts +++ b/services/article.ts @@ -42,6 +42,40 @@ export async function getListArticle(props: PaginationRequest) { ); } +export async function getListArticleAdminPage(props: PaginationRequest) { + const { + page, + limit, + search, + startDate, + endDate, + isPublish, + category, + sortBy, + sort, + categorySlug, + isBanner, + categoryIds, + createdByIds, + } = props; + const headers = { + "content-type": "application/json", + Authorization: `Bearer ${token}`, + }; + return await httpGet( + `/articles?limit=${limit}&page=${page}&isPublish=${ + isPublish === undefined ? "" : isPublish + }&title=${search}&startDate=${startDate || ""}&endDate=${ + endDate || "" + }&categoryId=${category || ""}&sortBy=${sortBy || "created_at"}&sort=${ + sort || "asc" + }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ + categoryIds || "" + }&createdByIds=${createdByIds || ""}`, + headers + ); +} + export async function getTopArticles(props: PaginationRequest) { const { page, limit, search, startDate, endDate, isPublish, category } = props;