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,8 +461,7 @@ 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)}
@ -529,24 +530,6 @@ export default function DashboardContainer() {
</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
@ -559,8 +542,22 @@ export default function DashboardContainer() {
className={`w-[10%] text-center ${ className={`w-[10%] text-center ${
list?.totalArticle === 0 && "bg-red-600 text-white" list?.totalArticle === 0 && "bg-red-600 text-white"
}`} }`}
>
<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} {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 || ""
}` }`
); );