fix:dashboard recap

This commit is contained in:
Rama Priyanto 2025-06-18 09:32:56 +07:00
parent 77178d87fe
commit c61e7d0adb
4 changed files with 40 additions and 17 deletions

View File

@ -93,7 +93,7 @@ export default function Login() {
} }
// login tanpa otp // login tanpa otp
loading(); // loading();
// const response = await postSignIn(data); // const response = await postSignIn(data);
// if (response?.error) { // if (response?.error) {
// error("Username / Password Tidak Sesuai"); // error("Username / Password Tidak Sesuai");

View File

@ -292,7 +292,7 @@ export default function HeaderNews() {
src={ src={
newsItem?.thumbnailUrl === "" newsItem?.thumbnailUrl === ""
? "/no-image.jpg" ? "/no-image.jpg"
: newsItem?.thumbnailUrl : newsItem?.thumbnailUrl + "?isBanner=true"
} }
className={`!object-cover !rounded-none ${ className={`!object-cover !rounded-none ${
portraitMap[index] portraitMap[index]

View File

@ -41,6 +41,7 @@ import { Fragment, useEffect, useState } from "react";
import { import {
getListArticle, getListArticle,
getListArticleAdminPage, getListArticleAdminPage,
getRecapArticleData,
getStatisticSummary, getStatisticSummary,
getTopArticles, getTopArticles,
getUserLevelDataStat, getUserLevelDataStat,
@ -128,7 +129,10 @@ export default function DashboardContainer() {
const [polresData, setPolresData] = useState<any>({}); const [polresData, setPolresData] = useState<any>({});
const [selectedAccordion, setSelectedAccordion] = useState<any>(new Set([])); const [selectedAccordion, setSelectedAccordion] = useState<any>(new Set([]));
const [recapArticleList, setRecapArticleList] = useState<any>([]); const [recapArticleList, setRecapArticleList] = useState<any>([]);
const [selectedUnit, setSelectedUnit] = useState(""); const [selectedUnit, setSelectedUnit] = useState<{
id: number;
name: string;
}>();
const roleId = Cookies.get("urie"); const roleId = Cookies.get("urie");
const [recapArticlePage, setRecapArticlePage] = useState(1); const [recapArticlePage, setRecapArticlePage] = useState(1);
@ -328,23 +332,27 @@ export default function DashboardContainer() {
getRecapArticle(); getRecapArticle();
}, [recapArticlePage]); }, [recapArticlePage]);
const getRecapArticle = async () => { const getRecapArticle = async (userLevelId?: number) => {
const req = { const req = {
limit: `10`, id: userLevelId || selectedUnit?.id,
page: recapArticlePage, page: recapArticlePage,
search: "", startDate: getDate(postContentDate.start),
sort: "desc", endDate: getDate(postContentDate.end),
startDate: getDate(topContentDate.startDate), startTime: `${getTime(postContentDate.start.hour)}:${getTime(
endDate: getDate(topContentDate.endDate), postContentDate.start.minute
)}:00`,
endTime: `${getTime(postContentDate.end.hour)}:${getTime(
postContentDate.end.minute
)}:00`,
}; };
const res = await getTopArticles(req); const res = await getRecapArticleData(req);
setRecapArticleList(getTableNumber(10, res.data?.data, "recapArticle")); setRecapArticleList(getTableNumber(10, res.data?.data, "recapArticle"));
setRecapArticleTotalPage(res?.data?.meta?.totalPage); setRecapArticleTotalPage(res?.data?.meta?.totalPage);
}; };
const openModalArticle = async () => { const openModalArticle = async (userLevelId: number) => {
setRecapArticlePage(1); setRecapArticlePage(1);
getRecapArticle(); getRecapArticle(userLevelId);
onOpen(); onOpen();
}; };
@ -509,8 +517,11 @@ export default function DashboardContainer() {
<a <a
onClick={() => { onClick={() => {
if (list?.totalArticle !== 0) { if (list?.totalArticle !== 0) {
setSelectedUnit(child?.userLevelName); setSelectedUnit({
openModalArticle(); name: child?.userLevelName,
id: child.userLevelId,
});
openModalArticle(child.userLevelId);
} }
}} }}
className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${ className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${
@ -546,8 +557,11 @@ export default function DashboardContainer() {
<a <a
onClick={() => { onClick={() => {
if (list?.totalArticle !== 0) { if (list?.totalArticle !== 0) {
setSelectedUnit(list?.userLevelName); setSelectedUnit({
openModalArticle(); name: list?.userLevelName,
id: list.userLevelId,
});
openModalArticle(list.userLevelId);
} }
}} }}
className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${ className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${
@ -794,7 +808,7 @@ export default function DashboardContainer() {
{(onClose) => ( {(onClose) => (
<> <>
<ModalHeader className="flex flex-col gap-1"> <ModalHeader className="flex flex-col gap-1">
{selectedUnit} List Content {selectedUnit?.name} List Content
</ModalHeader> </ModalHeader>
<ModalBody className="flex flex-col gap-2"> <ModalBody className="flex flex-col gap-2">
<div className="grid grid-cols-12 text-xs "> <div className="grid grid-cols-12 text-xs ">

View File

@ -129,6 +129,15 @@ export async function getArticleById(id: any) {
}; };
return await httpGet(`/articles/${id}`, headers); return await httpGet(`/articles/${id}`, headers);
} }
export async function getRecapArticleData(data: any) {
const headers = {
"content-type": "application/json",
};
return await httpGet(
`/articles?page=${data.page}&userLevelId=${data.id}&startDate=${data.startDate}&endDate=${data.endDate}&startTime=${data.startTime}&endTime=${data.endTime}`,
headers
);
}
// export async function deleteArticle(id: string) { // export async function deleteArticle(id: string) {
// const headers = { // const headers = {