web-humas-fe/components/main/dashboard/dashboard-container.tsx

831 lines
29 KiB
TypeScript
Raw Normal View History

2024-12-23 02:25:59 +00:00
"use client";
import {
DashboardCommentIcon,
2024-12-23 02:25:59 +00:00
DashboardConnectIcon,
DashboardShareIcon,
2024-12-23 02:25:59 +00:00
DashboardSpeecIcon,
DashboardTopLeftPointIcon,
DashboardUserIcon,
} from "@/components/icons/dashboard-icon";
2024-04-19 13:26:27 +00:00
import { Submenu1Icon } from "@/components/icons/sidebar-icon";
import {
Accordion,
AccordionItem,
Button,
2025-02-17 07:21:28 +00:00
Calendar,
Checkbox,
CheckboxGroup,
CheckboxIcon,
2025-03-06 10:40:54 +00:00
Image,
Modal,
ModalBody,
ModalContent,
ModalHeader,
Pagination,
2025-02-17 07:21:28 +00:00
Popover,
PopoverContent,
PopoverTrigger,
Select,
SelectItem,
SelectSection,
Skeleton,
useDisclosure,
2025-02-13 08:25:39 +00:00
} from "@heroui/react";
2024-04-19 13:26:27 +00:00
import ApexChartColumn from "./chart/column-chart";
import ApexChartDonut from "./chart/donut-chart";
import ApexChartLineArea from "./chart/line-area-chart";
import Cookies from "js-cookie";
import Link from "next/link";
import { Fragment, useEffect, useState } from "react";
2025-02-17 07:21:28 +00:00
import {
getListArticle,
2025-05-25 09:20:56 +00:00
getListArticleAdminPage,
2025-02-17 07:21:28 +00:00
getStatisticSummary,
getTopArticles,
getUserLevelDataStat,
2025-05-04 07:14:12 +00:00
} from "@/services/article";
import { Article } from "@/types/globals";
2025-02-17 07:21:28 +00:00
import {
convertDateFormat,
convertDateFormatNoTime,
convertDateFormatNoTimeV2,
2025-05-28 06:56:41 +00:00
getUnixTimestamp,
2025-02-17 07:21:28 +00:00
textEllipsis,
} from "@/utils/global";
import { parseDate, getLocalTimeZone } from "@internationalized/date";
import { Input } from "@heroui/input";
type ArticleData = Article & {
no: number;
createdAt: string;
};
2024-04-19 13:26:27 +00:00
2025-02-06 09:49:20 +00:00
interface TopPages {
id: number;
no: number;
title: string;
2025-02-17 07:21:28 +00:00
viewCount: number;
2025-02-06 09:49:20 +00:00
}
interface PostCount {
userLevelId: number;
2025-02-06 09:49:20 +00:00
no: number;
2025-02-17 07:21:28 +00:00
userLevelName: string;
totalArticle: number;
2025-02-06 09:49:20 +00:00
}
2024-04-19 13:26:27 +00:00
export default function DashboardContainer() {
const { isOpen, onOpen, onOpenChange } = useDisclosure();
const username = Cookies.get("username");
const fullname = Cookies.get("ufne");
const [page, setPage] = useState(1);
const [totalPage, setTotalPage] = useState(1);
2025-02-06 09:49:20 +00:00
const [topPagespage, setTopPagesPage] = useState(1);
const [topPagesTotalPage, setTopPagesTotalPage] = useState(1);
const [article, setArticle] = useState<ArticleData[]>([]);
const [selectedCategory, setSelectedCategory] = useState("polda");
const [analyticsView, setAnalyticView] = useState<string[]>([
2025-02-17 07:21:28 +00:00
"comment",
"view",
"share",
]);
2025-02-17 07:21:28 +00:00
const [startDateValue, setStartDateValue] = useState(
parseDate(convertDateFormatNoTimeV2(new Date()))
);
2025-02-06 09:49:20 +00:00
const [postContentDate, setPostContentDate] = useState({
2025-02-17 07:21:28 +00:00
startDate: parseDate(
convertDateFormatNoTimeV2(
new Date(new Date().setDate(new Date().getDate() - 7))
)
),
endDate: parseDate(convertDateFormatNoTimeV2(new Date())),
2025-02-06 09:49:20 +00:00
});
const [topContentDate, setTopContentDate] = useState({
startDate: parseDate(
convertDateFormatNoTimeV2(
new Date(new Date().setDate(new Date().getDate() - 7))
)
),
endDate: parseDate(convertDateFormatNoTimeV2(new Date())),
});
const [typeDate, setTypeDate] = useState("monthly");
2025-02-17 07:21:28 +00:00
const [summary, setSummary] = useState<any>();
2025-02-06 09:49:20 +00:00
const [topPages, setTopPages] = useState<TopPages[]>([]);
const [postCount, setPostCount] = useState<PostCount[]>([]);
const [polresData, setPolresData] = useState<any>({});
const [selectedAccordion, setSelectedAccordion] = useState<any>(new Set([]));
const [recapArticleList, setRecapArticleList] = useState<any>([]);
const [timeValue, setTimeValue] = useState("--:--");
const [selectedUnit, setSelectedUnit] = useState("");
const roleId = Cookies.get("urie");
2025-02-06 09:49:20 +00:00
2025-02-17 07:21:28 +00:00
useEffect(() => {
fetchSummary();
}, []);
useEffect(() => {
initState();
}, [page]);
async function initState() {
const req = {
limit: "4",
page: page,
search: "",
2025-05-26 01:04:28 +00:00
sort: "desc",
2025-05-28 06:56:41 +00:00
timeStamp: getUnixTimestamp(),
};
2025-05-25 09:20:56 +00:00
const res = await getListArticleAdminPage(req);
setArticle(res.data?.data);
setTotalPage(res?.data?.meta?.totalPage);
}
2025-02-17 07:21:28 +00:00
async function fetchSummary() {
2025-05-28 06:56:41 +00:00
const res = await getStatisticSummary(getUnixTimestamp());
2025-02-17 07:21:28 +00:00
setSummary(res?.data?.data);
}
useEffect(() => {
fetchTopPages();
}, [topPagespage, topContentDate]);
const getDate = (data: any) => {
if (data === null) {
return "";
} else {
return `${data.year}-${data.month < 10 ? `0${data.month}` : data.month}-${
data.day < 10 ? `0${data.day}` : data.day
}`;
}
};
2025-02-17 07:21:28 +00:00
2025-02-06 09:49:20 +00:00
async function fetchTopPages() {
2025-02-17 07:21:28 +00:00
const req = {
limit: "10",
page: topPagespage,
search: "",
2025-05-26 01:04:28 +00:00
sort: "desc",
2025-05-26 02:01:35 +00:00
isPublish: true,
2025-05-28 06:56:41 +00:00
timeStamp: getUnixTimestamp(),
startDate: getDate(topContentDate.startDate),
endDate: getDate(topContentDate.endDate),
2025-02-17 07:21:28 +00:00
};
const res = await getTopArticles(req);
setTopPages(getTableNumber(10, res.data?.data));
setTopPagesTotalPage(res?.data?.meta?.totalPage);
2025-02-06 09:49:20 +00:00
}
2025-02-17 07:21:28 +00:00
useEffect(() => {
fetchPostCount();
}, [postContentDate]);
2025-02-06 09:49:20 +00:00
async function fetchPostCount() {
2025-02-17 07:21:28 +00:00
const getDate = (data: any) => {
2025-03-06 10:40:54 +00:00
return `${data.year}-${data.month < 10 ? `0${data.month}` : data.month}-${
data.day < 10 ? `0${data.day}` : data.day
}`;
2025-02-17 07:21:28 +00:00
};
const res = await getUserLevelDataStat(
getDate(postContentDate.startDate),
2025-05-28 06:56:41 +00:00
getDate(postContentDate.endDate),
getUnixTimestamp()
2025-02-17 07:21:28 +00:00
);
setPostCount(getTableNumberStats(res?.data?.data));
2025-02-06 09:49:20 +00:00
}
const getTableNumber = (limit: number, data: any) => {
if (data) {
const startIndex = limit * (topPagespage - 1);
2025-02-06 09:49:20 +00:00
let iterate = 0;
const newData = data.map((value: any) => {
iterate++;
value.no = startIndex + iterate;
return value;
});
return newData;
}
};
const getTableNumberStats = (data: any) => {
if (data) {
let iterate = 0;
2025-06-13 10:03:42 +00:00
const newData = data
.filter(
(value: any) =>
value.userLevelName !== "SATWIL" && value.userLevelName !== "SATKER"
)
.map((value: any) => {
iterate++;
value.no = iterate;
return value;
});
return newData;
}
};
2025-02-17 07:21:28 +00:00
const getMonthYear = (date: any) => {
return date.month + " " + date.year;
};
const getMonthYearName = (date: any) => {
const newDate = new Date(date);
const months = [
2025-02-17 07:21:28 +00:00
"Januari",
"Februari",
"Maret",
"April",
"Mei",
"Juni",
"Juli",
"Agustus",
"September",
"Oktober",
"November",
"Desember",
];
const year = newDate.getFullYear();
const month = months[newDate.getMonth()];
return month + " " + year;
};
useEffect(() => {
const temp = Array.from(selectedAccordion);
console.log("selecette", temp);
if (temp.length > 0) {
for (const element of temp) {
getPolresData(Number(element));
}
}
}, [postContentDate]);
const getPolresData = async (id: number) => {
const getDate = (data: any) => {
return `${data.year}-${data.month < 10 ? `0${data.month}` : data.month}-${
data.day < 10 ? `0${data.day}` : data.day
}`;
};
const res = await getUserLevelDataStat(
getDate(postContentDate.startDate),
getDate(postContentDate.endDate),
2025-06-13 10:35:07 +00:00
getUnixTimestamp(),
id
);
const polresNowData = getTableNumberStats(res?.data?.data);
setPolresData((prev: any) => ({
...prev,
[id]: polresNowData,
}));
};
const handleSelectionChange = (e: any) => {
const prev = selectedAccordion;
const current = e;
const currentArray = Array.from(current);
const added = Number(currentArray.filter((item) => !prev.has(item))[0]);
setSelectedAccordion(current);
if (added) {
getPolresData(added);
}
};
const openModalArticle = async (limit: number) => {
const req = {
limit: `${limit}`,
page: topPagespage,
search: "",
sort: "desc",
startDate: getDate(topContentDate.startDate),
endDate: getDate(topContentDate.endDate),
};
const res = await getTopArticles(req);
setRecapArticleList(getTableNumber(10, res.data?.data));
// setTopPagesTotalPage(res?.data?.meta?.totalPage);
onOpen();
};
2024-12-23 02:25:59 +00:00
return (
2025-01-30 11:34:29 +00:00
<div className="px-2 lg:p-8 flex justify-center">
2024-12-23 02:25:59 +00:00
<div className="w-full flex flex-col gap-6">
2025-01-30 11:34:29 +00:00
<div className="w-full flex flex-col lg:flex-row gap-6 justify-center">
<div className="px-4 lg:px-8 py-4 justify-between w-full lg:w-[37%] h-[160px] shadow-md bg-white dark:bg-[#18181b] flex flex-col rounded-lg">
<div className="flex justify-between w-full items-center">
<div className="flex flex-col gap-2">
<p className="font-bold text-xl ">{fullname}</p>
<p>{username}</p>
</div>
<DashboardUserIcon size={78} />
2024-12-23 02:25:59 +00:00
</div>
<div className="flex flex-row gap-5">
<p className="text-lg font-semibold">
2025-02-17 07:21:28 +00:00
{summary?.totalToday} Post{" "}
2025-02-12 05:07:28 +00:00
<span className="text-sm font-normal">Hari ini</span>
</p>
<p className="text-lg font-semibold">
2025-02-17 07:21:28 +00:00
{summary?.totalThisWeek} Post{" "}
2025-02-12 05:07:28 +00:00
<span className="text-sm font-normal">Minggu ini</span>
</p>
2024-12-23 02:25:59 +00:00
</div>
</div>
2025-01-30 11:34:29 +00:00
<div className="lg:w-[20%] h-[160px] shadow-md bg-white dark:bg-[#18181b] flex flex-col justify-center items-center rounded-lg">
2024-12-23 02:25:59 +00:00
<div className="h-1/2 flex items-center justify-center">
<DashboardSpeecIcon />
2024-12-23 02:25:59 +00:00
</div>
<div className="">Total post</div>
2025-02-17 07:21:28 +00:00
<div className="font-semibold text-lg">{summary?.totalAll}</div>
2024-12-23 02:25:59 +00:00
</div>
2025-01-30 11:34:29 +00:00
<div className="w-full lg:w-[15%] h-[160px] shadow-md bg-white dark:bg-[#18181b] flex flex-col justify-center items-center rounded-lg">
2024-12-23 02:25:59 +00:00
<div className="h-1/2 flex items-center justify-center">
<DashboardConnectIcon />
2024-12-23 02:25:59 +00:00
</div>
<div className="">Total views</div>
2025-02-17 07:21:28 +00:00
<div className="font-semibold text-lg">{summary?.totalViews}</div>
</div>
2025-01-30 11:34:29 +00:00
<div className="w-full lg:w-[15%] h-[160px] shadow-md bg-white dark:bg-[#18181b] flex flex-col justify-center items-center rounded-lg">
<div className="h-1/2 flex items-center justify-center">
<DashboardShareIcon />
</div>
<div className="">Total share</div>
2025-02-17 07:21:28 +00:00
<div className="font-semibold text-lg">{summary?.totalShares}</div>
</div>
2025-01-30 11:34:29 +00:00
<div className="w-full lg:w-[15%] h-[160px] shadow-md bg-white dark:bg-[#18181b] flex flex-col justify-center items-center rounded-lg">
<div className="h-1/2 flex items-center justify-center">
<DashboardCommentIcon size={50} />
</div>
<div className="">Total comment</div>
2025-02-17 07:21:28 +00:00
<div className="font-semibold text-lg">
{summary?.totalComments}
</div>
2024-12-23 02:25:59 +00:00
</div>
</div>
2025-02-06 09:49:20 +00:00
<div className="w-full flex flex-col lg:flex-row gap-6 justify-center ">
<div className="border-1 shadow-sm w-screen rounded-lg lg:w-[55%] p-6 flex flex-col text-xs lg:text-sm">
<div className="flex justify-between mb-4 items-center">
<p className="font-semibold">
2025-02-17 07:21:28 +00:00
Rekapitulasi Post Berita Polda/Polres Pada Website
2025-02-06 09:49:20 +00:00
</p>
<div className="w-[300px] flex flex-row gap-2 justify-between font-semibold items-center">
2025-02-17 07:21:28 +00:00
<Popover
placement="bottom"
classNames={{ content: ["!bg-transparent", "p-0"] }}
>
<PopoverTrigger>
<a className="cursor-pointer">
{convertDateFormatNoTime(postContentDate.startDate)}
</a>
</PopoverTrigger>
<PopoverContent className="bg-transparent">
<Calendar
value={postContentDate.startDate}
onChange={(e) =>
setPostContentDate({
startDate: e,
endDate: postContentDate.endDate,
})
}
maxValue={postContentDate.endDate}
/>
</PopoverContent>
</Popover>
-
<Popover
placement="bottom"
classNames={{ content: ["!bg-transparent", "p-0"] }}
>
<PopoverTrigger>
<a className="cursor-pointer ">
{convertDateFormatNoTime(postContentDate.endDate)}
</a>
</PopoverTrigger>
<PopoverContent className="bg-transparent">
<Calendar
value={postContentDate.endDate}
onChange={(e) =>
setPostContentDate({
startDate: postContentDate.startDate,
endDate: e,
})
}
minValue={postContentDate.startDate}
/>
</PopoverContent>
</Popover>
<Input
type="time"
variant="bordered"
className="w-fit "
value={timeValue}
onValueChange={setTimeValue}
endContent={
<a>
<CheckboxIcon />
</a>
}
classNames={{
inputWrapper: [
"border-none rounded-lg !h-[30px] lg:h-[40px]",
"dark:group-data-[focused=false]:bg-transparent border-none",
],
}}
/>
2025-02-06 09:49:20 +00:00
</div>
</div>
<div className="flex flex-row border-b-1 gap-1 py-1 items-center">
2025-02-06 09:49:20 +00:00
<div className="w-[5%]">NO</div>
<div className="w-[50%] lg:w-[70%]">
{Number(roleId) < 3 ? (
<Select
variant="underlined"
className="max-w-xs border-none"
label=""
selectedKeys={[selectedCategory]}
classNames={{
innerWrapper: "!border-none",
mainWrapper: "!border-none",
trigger: "border-none",
}}
onChange={(e) =>
e.target.value !== ""
? setSelectedCategory(e.target.value)
: ""
}
>
<SelectItem key="polda">POLDA</SelectItem>
<SelectItem key="polres">POLRES</SelectItem>
<SelectItem key="satker">SATKER MABES</SelectItem>
</Select>
) : (
"POLDA/POLRES"
)}
</div>
2025-02-06 09:49:20 +00:00
<div className="w-[45%] lg:w-[25%] text-right">
JUMLAH POST BERITA
</div>
</div>
<div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto">
{roleId && Number(roleId) < 3 ? (
<Accordion
selectedKeys={selectedAccordion}
onSelectionChange={(e) => handleSelectionChange(e)}
selectionMode="multiple"
className="w-full"
2025-02-07 03:59:22 +00:00
>
{postCount?.map((list) => (
<AccordionItem
key={list.userLevelId}
aria-label={list.userLevelName}
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
className={`w-[10%] text-center ${
list?.totalArticle === 0 &&
"bg-red-600 text-white "
}`}
>
{list?.totalArticle}
</div>
</div>
}
>
{polresData[list?.userLevelId] ? (
polresData[list?.userLevelId]?.map(
(child: any, index: number) => (
<div
key={child.userLevelId}
className={`flex flex-row gap-1 py-1 ${
index ===
polresData[list?.userLevelId].length - 1
? ""
: "border-b-1"
}`}
>
<div className="w-[5%]"></div>
<div className="w-[85%]">
{child?.userLevelName}
</div>
<a
onClick={() => {
if (list?.totalArticle !== 0) {
setSelectedUnit(child?.userLevelName);
2025-06-17 03:01:19 +00:00
// openModalArticle(list?.totalArticle);
}
}}
className={`w-[10%] text-start cursor-pointer ${
list?.totalArticle === 0 &&
"bg-red-600 text-white cursor-default"
}`}
>
{child?.totalArticle}
</a>
</div>
)
)
) : (
<Skeleton className="h-3 w-full rounded-lg" />
)}
</AccordionItem>
))}
</Accordion>
) : (
postCount?.map((list) => (
2025-02-06 09:49:20 +00:00
<div
key={list.userLevelId}
className="flex flex-row border-b-1 gap-1 py-1"
2025-02-06 09:49:20 +00:00
>
<div className="w-[5%]">{list?.no}</div>
<div className="w-[85%]">{list?.userLevelName}</div>
<div
className={`w-[10%] text-center ${
list?.totalArticle === 0 && "bg-red-600 text-white"
}`}
>
{list?.totalArticle}
</div>
2025-02-06 09:49:20 +00:00
</div>
))
)}
2025-02-06 09:49:20 +00:00
</div>
</div>
<div className="flex flex-col w-full lg:w-[45%] gap-6 shadow-md bg-white dark:bg-[#18181b] rounded-lg p-8 text-sm">
<div className="flex justify-between font-semibold">
<p>Recent Article</p>
<Link href="/admin/article/create">
2025-02-06 09:49:20 +00:00
<Button color="primary" variant="bordered">
Buat Article
</Button>
</Link>
</div>
{article?.map((list: any) => (
<div
key={list?.id}
className="flex flex-row gap-2 items-center border-b-2 py-2"
>
2025-03-06 10:40:54 +00:00
<Image
alt="thumbnail"
2025-02-06 09:49:20 +00:00
src={list?.thumbnailUrl || `/no-image.jpg`}
className="h-[70px] w-[70px] object-cover rounded-lg"
/>
<div className="flex flex-col gap-2">
<p>{textEllipsis(list?.title, 78)}</p>
<p className="text-xs">
{convertDateFormat(list?.createdAt)}
</p>
</div>
</div>
))}
<div className="my-2 w-full flex justify-center">
<Pagination
isCompact
showControls
showShadow
color="primary"
classNames={{
base: "bg-transparent",
wrapper: "bg-transparent",
2025-05-31 14:52:58 +00:00
item: "w-fit px-3",
cursor: "w-fit px-3",
2025-02-06 09:49:20 +00:00
}}
page={page}
total={totalPage}
onChange={(page) => setPage(page)}
/>
</div>
</div>
</div>
2025-01-30 11:34:29 +00:00
<div className="w-full flex flex-col lg:flex-row gap-6 justify-center ">
<div className="border-1 shadow-sm w-screen rounded-lg lg:w-[55%] p-6 flex flex-col">
2024-12-23 02:25:59 +00:00
<div className="flex justify-between mb-3">
<div className="font-semibold flex flex-col">
Analytics
<div className="font-normal text-xs text-gray-600 flex flex-row gap-2">
2025-01-30 11:34:29 +00:00
<CheckboxGroup
label=""
value={analyticsView}
orientation="vertical"
onValueChange={setAnalyticView}
className="lg:hidden"
>
2025-02-17 07:21:28 +00:00
<Checkbox size="sm" value="comment">
Comment
2025-01-30 11:34:29 +00:00
</Checkbox>
<Checkbox size="sm" value="view" color="success">
View
</Checkbox>
<Checkbox size="sm" value="share" color="warning">
Share
</Checkbox>
</CheckboxGroup>
<CheckboxGroup
label=""
value={analyticsView}
orientation="horizontal"
onValueChange={setAnalyticView}
2025-01-30 11:34:29 +00:00
className="hidden lg:block"
>
2025-02-17 07:21:28 +00:00
<Checkbox size="sm" value="comment">
Comment
</Checkbox>
<Checkbox size="sm" value="view" color="success">
View
</Checkbox>
<Checkbox size="sm" value="share" color="warning">
Share
</Checkbox>
</CheckboxGroup>
</div>
2024-12-23 02:25:59 +00:00
</div>
2025-01-30 11:34:29 +00:00
<div className="flex flex-col lg:flex-row gap-2">
<Button
color="primary"
variant={typeDate === "monthly" ? "solid" : "bordered"}
2025-03-06 10:40:54 +00:00
onPress={() => setTypeDate("monthly")}
2025-01-30 11:34:29 +00:00
className="w-[140px] text-xs lg:text-sm h-[30px] lg:h-[40px] rounded-sm lg:rounded-lg"
2024-12-23 02:25:59 +00:00
>
Bulanan
</Button>
2024-12-23 02:25:59 +00:00
<Button
color="primary"
2025-03-06 10:40:54 +00:00
onPress={() => setTypeDate("weekly")}
variant={typeDate === "weekly" ? "solid" : "bordered"}
2025-01-30 11:34:29 +00:00
className="w-[140px] text-xs lg:text-sm h-[30px] lg:h-[40px] rounded-sm lg:rounded-lg"
2024-12-23 02:25:59 +00:00
>
Mingguan
2024-12-23 02:25:59 +00:00
</Button>
2025-01-30 11:34:29 +00:00
<div className="w-[140px]">
2025-02-17 07:21:28 +00:00
<Popover
placement="bottom"
classNames={{ content: ["!bg-transparent", "p-0"] }}
>
<PopoverTrigger>
<Button className="w-full">
{getMonthYearName(startDateValue)}
</Button>
</PopoverTrigger>
<PopoverContent className="bg-transparent">
<Calendar
value={startDateValue}
onChange={setStartDateValue}
/>
</PopoverContent>
</Popover>
2024-12-23 02:25:59 +00:00
</div>
</div>
</div>
<div className="flex flex-row w-full h-full">
2025-01-30 11:34:29 +00:00
<div className="w-full h-[30vh] lg:h-full text-black">
<ApexChartColumn
type={typeDate}
2025-02-17 07:21:28 +00:00
date={`${startDateValue.month} ${startDateValue.year}`}
view={analyticsView}
/>
2024-12-23 02:25:59 +00:00
</div>
</div>
</div>
2025-02-06 09:49:20 +00:00
<div className="flex flex-col w-full lg:w-[45%] gap-6 shadow-md bg-white dark:bg-[#18181b] rounded-lg p-8 text-xs lg:text-sm">
<div className="flex justify-between font-semibold">
<p>Top Pages</p>
<div className="w-[220px] flex flex-row gap-2 justify-between font-semibold">
<Popover
placement="bottom"
classNames={{ content: ["!bg-transparent", "p-0"] }}
>
<PopoverTrigger>
<a className="cursor-pointer">
{convertDateFormatNoTime(topContentDate.startDate)}
</a>
</PopoverTrigger>
<PopoverContent className="bg-transparent">
<Calendar
value={topContentDate.startDate}
onChange={(e) =>
setTopContentDate({
startDate: e,
endDate: topContentDate.endDate,
})
}
maxValue={topContentDate.endDate}
/>
</PopoverContent>
</Popover>
-
<Popover
placement="bottom"
classNames={{ content: ["!bg-transparent", "p-0"] }}
>
<PopoverTrigger>
<a className="cursor-pointer ">
{convertDateFormatNoTime(topContentDate.endDate)}
</a>
</PopoverTrigger>
<PopoverContent className="bg-transparent">
<Calendar
value={topContentDate.endDate}
onChange={(e) =>
setTopContentDate({
startDate: topContentDate.startDate,
endDate: e,
})
}
minValue={topContentDate.startDate}
/>
</PopoverContent>
</Popover>
</div>
</div>
2025-02-06 09:49:20 +00:00
<div className="flex flex-row border-b-1">
<div className="w-[5%]">No</div>
<div className="w-[85%]">Title</div>
2025-02-17 07:21:28 +00:00
<div className="w-[10%] text-center">Visits</div>
2025-02-06 09:49:20 +00:00
</div>
{(!topPages || topPages?.length < 1) && (
<div className="flex justify-center items-center">
Tidak ada Data
</div>
)}
2025-02-06 09:49:20 +00:00
{topPages?.map((list) => (
<div key={list.id} className="flex flex-row border-b-1">
<div className="w-[5%]">{list?.no}</div>
<div className="w-[85%]">{list?.title}</div>
2025-02-17 07:21:28 +00:00
<div className="w-[10%] text-center">{list?.viewCount}</div>
2024-12-23 02:25:59 +00:00
</div>
))}
{topPages?.length > 0 && (
<div className="my-2 w-full flex justify-center">
<Pagination
isCompact
showControls
showShadow
color="primary"
classNames={{
base: "bg-transparent",
wrapper: "bg-transparent",
item: "w-fit px-3",
cursor: "w-fit px-3",
}}
page={topPagespage}
total={topPagesTotalPage}
onChange={(page) => setTopPagesPage(page)}
/>
</div>
)}
2024-12-23 02:25:59 +00:00
</div>
2024-04-19 13:26:27 +00:00
</div>
2024-12-23 02:25:59 +00:00
</div>
<Modal isOpen={isOpen} onOpenChange={onOpenChange} size="3xl">
<ModalContent>
{(onClose) => (
<>
<ModalHeader className="flex flex-col gap-1">
{selectedUnit} List Content
</ModalHeader>
<ModalBody>
<div className="grid grid-cols-12 text-xs ">
<div className="col-span-1 font-bold">No</div>
<div className="col-span-9 text-center font-bold">Judul</div>
<div className="col-span-2 font-bold ">Dibuat</div>
<div className="col-span-12 grid grid-cols-12 max-h-[480px] overflow-auto">
{recapArticleList?.length > 0 &&
recapArticleList?.map((list: any) => (
<Fragment key={list.id}>
<div className="col-span-1 my-2">{list.no}</div>
<div className="col-span-9 my-2">
<Link
href={`/news/detail/${list.id}-${list.slug}`}
target="_blank"
className="hover:underline hover:text-primary"
>
{textEllipsis(list.title, 80)}
</Link>
</div>
<div className="my-2 col-span-2">
{convertDateFormat(list?.createdAt)}
</div>
</Fragment>
))}
</div>
</div>
</ModalBody>
</>
)}
</ModalContent>
</Modal>
2024-12-23 02:25:59 +00:00
</div>
);
}