From 0413d190e10edc676668e61c8ddd35bc0c6f87f1 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Sun, 25 May 2025 16:23:15 +0700 Subject: [PATCH 1/2] 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; From e6994c1f8cac62fc96d4976ae93c4805523c9118 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Mon, 26 May 2025 08:54:54 +0700 Subject: [PATCH 2/2] fix:top article dashboard number, article author placeholder --- components/main/dashboard/dashboard-container.tsx | 4 +++- components/table/article-table.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/main/dashboard/dashboard-container.tsx b/components/main/dashboard/dashboard-container.tsx index d4e9e2a..d96c550 100644 --- a/components/main/dashboard/dashboard-container.tsx +++ b/components/main/dashboard/dashboard-container.tsx @@ -108,6 +108,7 @@ export default function DashboardContainer() { limit: "4", page: page, search: "", + sort: "desc", }; const res = await getListArticleAdminPage(req); setArticle(res.data?.data); @@ -128,6 +129,7 @@ export default function DashboardContainer() { limit: "10", page: topPagespage, search: "", + sort: "desc", }; const res = await getTopArticles(req); setTopPages(getTableNumber(10, res.data?.data)); @@ -152,7 +154,7 @@ export default function DashboardContainer() { const getTableNumber = (limit: number, data: any) => { if (data) { - const startIndex = limit * (page - 1); + const startIndex = limit * (topPagespage - 1); let iterate = 0; const newData = data.map((value: any) => { iterate++; diff --git a/components/table/article-table.tsx b/components/table/article-table.tsx index b95d846..adfcf42 100644 --- a/components/table/article-table.tsx +++ b/components/table/article-table.tsx @@ -533,7 +533,7 @@ export default function ArticleTable() { isClearable={true} isSearchable={true} isMulti={true} - placeholder="Kategori..." + placeholder="Author..." name="sub-module" options={users} />