fix:article bearer

This commit is contained in:
Rama Priyanto 2025-05-25 16:23:15 +07:00
parent 686fa7bc95
commit 0413d190e1
3 changed files with 38 additions and 3 deletions

View File

@ -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);
}

View File

@ -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();

View File

@ -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;