fix:dashboard filter

This commit is contained in:
Rama Priyanto 2025-06-17 23:55:17 +07:00
parent f0bd7e2513
commit 77178d87fe
3 changed files with 84 additions and 86 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

@ -189,7 +189,7 @@ export default function DashboardContainer() {
useEffect(() => { useEffect(() => {
fetchPostCount(); fetchPostCount();
}, [postContentDate]); }, [postContentDate, selectedCategory]);
async function fetchPostCount() { async function fetchPostCount() {
const getDate = (data: any) => { const getDate = (data: any) => {
@ -205,7 +205,8 @@ export default function DashboardContainer() {
)}:00`, )}:00`,
`${getTime(postContentDate.end.hour)}:${getTime( `${getTime(postContentDate.end.hour)}:${getTime(
postContentDate.end.minute postContentDate.end.minute
)}:00` )}:00`,
selectedCategory === "polda" ? "" : selectedCategory
); );
setPostCount(getTableNumberStats(res?.data?.data)); setPostCount(getTableNumberStats(res?.data?.data));
} }
@ -294,9 +295,10 @@ export default function DashboardContainer() {
`${getTime(postContentDate.start.hour)}:${getTime( `${getTime(postContentDate.start.hour)}:${getTime(
postContentDate.start.minute postContentDate.start.minute
)}:00`, )}:00`,
`${getTime(postContentDate.end.hour)}-${getTime( `${getTime(postContentDate.end.hour)}:${getTime(
postContentDate.end.minute postContentDate.end.minute
)}:00`, )}:00`,
"",
id id
); );
const polresNowData = getTableNumberStats(res?.data?.data); const polresNowData = getTableNumberStats(res?.data?.data);
@ -459,94 +461,75 @@ export default function DashboardContainer() {
</div> </div>
</div> </div>
<div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto"> <div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto">
{roleId && Number(roleId) < 3 ? ( {roleId && Number(roleId) < 3 && selectedCategory == "polda" ? (
selectedCategory === "polda" ? ( <Accordion
<Accordion selectedKeys={selectedAccordion}
selectedKeys={selectedAccordion} onSelectionChange={(e) => handleSelectionChange(e)}
onSelectionChange={(e) => handleSelectionChange(e)} selectionMode="multiple"
selectionMode="multiple" className="w-full"
className="w-full" >
> {postCount?.map((list) => (
{postCount?.map((list) => ( <AccordionItem
<AccordionItem key={list.userLevelId}
key={list.userLevelId} aria-label={list.userLevelName}
aria-label={list.userLevelName} title={
title={ <div
key={list.userLevelId}
className="flex flex-row gap-1 py-1"
>
<div className="w-[5%]">{list?.no}</div>
<div className="w-[85%]">{list?.userLevelName}</div>
<div <div
key={list.userLevelId} className={`w-[10%] text-center ${
className="flex flex-row gap-1 py-1" list?.totalArticle === 0 &&
"bg-red-600 text-white "
}`}
> >
<div className="w-[5%]">{list?.no}</div> {list?.totalArticle}
<div className="w-[85%]">{list?.userLevelName}</div> </div>
</div>
}
>
{polresData[list?.userLevelId] ? (
polresData[list?.userLevelId]?.map(
(child: any, index: number) => (
<div <div
className={`w-[10%] text-center ${ key={child.userLevelId}
list?.totalArticle === 0 && className={`flex flex-row gap-1 py-1 ${
"bg-red-600 text-white " index ===
polresData[list?.userLevelId].length - 1
? ""
: "border-b-1"
}`} }`}
> >
{list?.totalArticle} <div className="w-[5%]"></div>
</div> <div className="w-[85%]">
</div> {child?.userLevelName}
} </div>
> <a
{polresData[list?.userLevelId] ? ( onClick={() => {
polresData[list?.userLevelId]?.map( if (list?.totalArticle !== 0) {
(child: any, index: number) => ( setSelectedUnit(child?.userLevelName);
<div openModalArticle();
key={child.userLevelId} }
className={`flex flex-row gap-1 py-1 ${ }}
index === className={`w-[10%] text-start cursor-pointer flex flex-row gap-1 items-center justify-end ${
polresData[list?.userLevelId].length - 1 list?.totalArticle === 0 &&
? "" "bg-red-600 text-white cursor-default "
: "border-b-1"
}`} }`}
> >
<div className="w-[5%]"></div> {child?.totalArticle}
<div className="w-[85%]"> <EyeIconMdi size={12} />
{child?.userLevelName} </a>
</div> </div>
<a
onClick={() => {
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}
<EyeIconMdi size={12} />
</a>
</div>
)
) )
) : ( )
<Skeleton className="h-3 w-full rounded-lg" /> ) : (
)} <Skeleton className="h-3 w-full rounded-lg" />
</AccordionItem> )}
))} </AccordionItem>
</Accordion> ))}
) : ( </Accordion>
<div className="flex flex-row gap-1 py-1">
<div className="w-[5%]">-</div>
<div className="w-[85%]">Article Seluruh Polres</div>
<div className={`w-[10%] text-center `}>
<a
onClick={() => {
setSelectedUnit("Seluruh Polres");
openModalArticle();
}}
className="flex flex-row gap-1 items-center cursor-pointer"
>
122
<EyeIconMdi size={12} />
</a>
</div>
</div>
)
) : ( ) : (
postCount?.map((list) => ( postCount?.map((list) => (
<div <div
@ -560,7 +543,21 @@ export default function DashboardContainer() {
list?.totalArticle === 0 && "bg-red-600 text-white" list?.totalArticle === 0 && "bg-red-600 text-white"
}`} }`}
> >
{list?.totalArticle} <a
onClick={() => {
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}
<EyeIconMdi />
</a>
</div> </div>
</div> </div>
)) ))

View File

@ -193,6 +193,7 @@ export async function getUserLevelDataStat(
endDate: string, endDate: string,
startTime: string, startTime: string,
endTime: string, endTime: string,
levelType: string,
levelId?: number levelId?: number
) { ) {
// const headers = { // const headers = {
@ -200,7 +201,7 @@ export async function getUserLevelDataStat(
// Authorization: `Bearer ${token}`, // Authorization: `Bearer ${token}`,
// }; // };
return await httpGetInterceptor( 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 || "" levelId || ""
}` }`
); );