fix:dashboard recap
This commit is contained in:
parent
77178d87fe
commit
c61e7d0adb
|
|
@ -93,7 +93,7 @@ export default function Login() {
|
|||
}
|
||||
|
||||
// login tanpa otp
|
||||
loading();
|
||||
// loading();
|
||||
// const response = await postSignIn(data);
|
||||
// if (response?.error) {
|
||||
// error("Username / Password Tidak Sesuai");
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ export default function HeaderNews() {
|
|||
src={
|
||||
newsItem?.thumbnailUrl === ""
|
||||
? "/no-image.jpg"
|
||||
: newsItem?.thumbnailUrl
|
||||
: newsItem?.thumbnailUrl + "?isBanner=true"
|
||||
}
|
||||
className={`!object-cover !rounded-none ${
|
||||
portraitMap[index]
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import { Fragment, useEffect, useState } from "react";
|
|||
import {
|
||||
getListArticle,
|
||||
getListArticleAdminPage,
|
||||
getRecapArticleData,
|
||||
getStatisticSummary,
|
||||
getTopArticles,
|
||||
getUserLevelDataStat,
|
||||
|
|
@ -128,7 +129,10 @@ export default function DashboardContainer() {
|
|||
const [polresData, setPolresData] = useState<any>({});
|
||||
const [selectedAccordion, setSelectedAccordion] = useState<any>(new Set([]));
|
||||
const [recapArticleList, setRecapArticleList] = useState<any>([]);
|
||||
const [selectedUnit, setSelectedUnit] = useState("");
|
||||
const [selectedUnit, setSelectedUnit] = useState<{
|
||||
id: number;
|
||||
name: string;
|
||||
}>();
|
||||
const roleId = Cookies.get("urie");
|
||||
|
||||
const [recapArticlePage, setRecapArticlePage] = useState(1);
|
||||
|
|
@ -328,23 +332,27 @@ export default function DashboardContainer() {
|
|||
getRecapArticle();
|
||||
}, [recapArticlePage]);
|
||||
|
||||
const getRecapArticle = async () => {
|
||||
const getRecapArticle = async (userLevelId?: number) => {
|
||||
const req = {
|
||||
limit: `10`,
|
||||
id: userLevelId || selectedUnit?.id,
|
||||
page: recapArticlePage,
|
||||
search: "",
|
||||
sort: "desc",
|
||||
startDate: getDate(topContentDate.startDate),
|
||||
endDate: getDate(topContentDate.endDate),
|
||||
startDate: getDate(postContentDate.start),
|
||||
endDate: getDate(postContentDate.end),
|
||||
startTime: `${getTime(postContentDate.start.hour)}:${getTime(
|
||||
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"));
|
||||
setRecapArticleTotalPage(res?.data?.meta?.totalPage);
|
||||
};
|
||||
|
||||
const openModalArticle = async () => {
|
||||
const openModalArticle = async (userLevelId: number) => {
|
||||
setRecapArticlePage(1);
|
||||
getRecapArticle();
|
||||
getRecapArticle(userLevelId);
|
||||
onOpen();
|
||||
};
|
||||
|
||||
|
|
@ -509,8 +517,11 @@ export default function DashboardContainer() {
|
|||
<a
|
||||
onClick={() => {
|
||||
if (list?.totalArticle !== 0) {
|
||||
setSelectedUnit(child?.userLevelName);
|
||||
openModalArticle();
|
||||
setSelectedUnit({
|
||||
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 ${
|
||||
|
|
@ -546,8 +557,11 @@ export default function DashboardContainer() {
|
|||
<a
|
||||
onClick={() => {
|
||||
if (list?.totalArticle !== 0) {
|
||||
setSelectedUnit(list?.userLevelName);
|
||||
openModalArticle();
|
||||
setSelectedUnit({
|
||||
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 ${
|
||||
|
|
@ -794,7 +808,7 @@ export default function DashboardContainer() {
|
|||
{(onClose) => (
|
||||
<>
|
||||
<ModalHeader className="flex flex-col gap-1">
|
||||
{selectedUnit} List Content
|
||||
{selectedUnit?.name} List Content
|
||||
</ModalHeader>
|
||||
<ModalBody className="flex flex-col gap-2">
|
||||
<div className="grid grid-cols-12 text-xs ">
|
||||
|
|
|
|||
|
|
@ -129,6 +129,15 @@ export async function getArticleById(id: any) {
|
|||
};
|
||||
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) {
|
||||
// const headers = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue