From 77178d87fe50a84e09720df1bf379c7a6a0c448c Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Tue, 17 Jun 2025 23:55:17 +0700 Subject: [PATCH] fix:dashboard filter --- components/form/login.tsx | 2 +- .../main/dashboard/dashboard-container.tsx | 165 +++++++++--------- services/article.ts | 3 +- 3 files changed, 84 insertions(+), 86 deletions(-) diff --git a/components/form/login.tsx b/components/form/login.tsx index d4d792f..7c22aee 100644 --- a/components/form/login.tsx +++ b/components/form/login.tsx @@ -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"); diff --git a/components/main/dashboard/dashboard-container.tsx b/components/main/dashboard/dashboard-container.tsx index 857140e..0d689b1 100644 --- a/components/main/dashboard/dashboard-container.tsx +++ b/components/main/dashboard/dashboard-container.tsx @@ -189,7 +189,7 @@ export default function DashboardContainer() { useEffect(() => { fetchPostCount(); - }, [postContentDate]); + }, [postContentDate, selectedCategory]); async function fetchPostCount() { const getDate = (data: any) => { @@ -205,7 +205,8 @@ export default function DashboardContainer() { )}:00`, `${getTime(postContentDate.end.hour)}:${getTime( postContentDate.end.minute - )}:00` + )}:00`, + selectedCategory === "polda" ? "" : selectedCategory ); setPostCount(getTableNumberStats(res?.data?.data)); } @@ -294,9 +295,10 @@ export default function DashboardContainer() { `${getTime(postContentDate.start.hour)}:${getTime( postContentDate.start.minute )}:00`, - `${getTime(postContentDate.end.hour)}-${getTime( + `${getTime(postContentDate.end.hour)}:${getTime( postContentDate.end.minute )}:00`, + "", id ); const polresNowData = getTableNumberStats(res?.data?.data); @@ -459,94 +461,75 @@ export default function DashboardContainer() {
- {roleId && Number(roleId) < 3 ? ( - selectedCategory === "polda" ? ( - handleSelectionChange(e)} - selectionMode="multiple" - className="w-full" - > - {postCount?.map((list) => ( - handleSelectionChange(e)} + selectionMode="multiple" + className="w-full" + > + {postCount?.map((list) => ( + +
{list?.no}
+
{list?.userLevelName}
-
{list?.no}
-
{list?.userLevelName}
+ {list?.totalArticle} +
+
+ } + > + {polresData[list?.userLevelId] ? ( + polresData[list?.userLevelId]?.map( + (child: any, index: number) => (
- {list?.totalArticle} -
- - } - > - {polresData[list?.userLevelId] ? ( - polresData[list?.userLevelId]?.map( - (child: any, index: number) => ( -
+
+ {child?.userLevelName} +
+ { + if (list?.totalArticle !== 0) { + setSelectedUnit(child?.userLevelName); + openModalArticle(); + } + }} + className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${ + list?.totalArticle === 0 && + "bg-red-600 text-white cursor-default " }`} > -
-
- {child?.userLevelName} -
-
{ - if (list?.totalArticle !== 0) { - setSelectedUnit(child?.userLevelName); - openModalArticle(); - } - }} - className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${ - list?.totalArticle === 0 && - "bg-red-600 text-white cursor-default " - }`} - > - {child?.totalArticle} - - - - ) + {child?.totalArticle} + + + ) - ) : ( - - )} - - ))} - - ) : ( -
-
-
-
Article Seluruh Polres
-
- { - setSelectedUnit("Seluruh Polres"); - openModalArticle(); - }} - className="flex flex-row gap-1 items-center cursor-pointer" - > - 122 - - -
-
- ) + ) + ) : ( + + )} + + ))} + ) : ( postCount?.map((list) => (
- {list?.totalArticle} + { + if (list?.totalArticle !== 0) { + setSelectedUnit(list?.userLevelName); + openModalArticle(); + } + }} + className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${ + list?.totalArticle === 0 && + "bg-red-600 text-white cursor-default " + }`} + > + {list?.totalArticle} + +
)) diff --git a/services/article.ts b/services/article.ts index 3d71e8a..db5c71d 100644 --- a/services/article.ts +++ b/services/article.ts @@ -193,6 +193,7 @@ export async function getUserLevelDataStat( endDate: string, startTime: string, endTime: string, + levelType: string, levelId?: number ) { // const headers = { @@ -200,7 +201,7 @@ export async function getUserLevelDataStat( // Authorization: `Bearer ${token}`, // }; return await httpGetInterceptor( - `/articles/statistic/user-levels?startDate=${startDate}&endDate=${endDate}&startTime=${startTime}&endTime=${endTime}&userLevelId=${ + `/articles/statistic/user-levels?startDate=${startDate}&endDate=${endDate}&startTime=${startTime}&endTime=${endTime}&levelType=${levelType}&userLevelId=${ levelId || "" }` );