diff --git a/app/layout.tsx b/app/layout.tsx index 9777007..ef41878 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -9,6 +9,7 @@ import { Metadata } from "next"; import { Providers } from "./providers"; import LoadScript from "@/utils/global"; import { type ReactNode } from "react"; +import LoadTawk from "@/components/ui/tawkto/load-tawk"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { @@ -56,6 +57,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
{children}
+ ); diff --git a/components/main/dashboard/dashboard-container.tsx b/components/main/dashboard/dashboard-container.tsx index f51ffbe..7cf43fc 100644 --- a/components/main/dashboard/dashboard-container.tsx +++ b/components/main/dashboard/dashboard-container.tsx @@ -15,7 +15,12 @@ import { Calendar, Checkbox, CheckboxGroup, + CheckboxIcon, Image, + Modal, + ModalBody, + ModalContent, + ModalHeader, Pagination, Popover, PopoverContent, @@ -24,13 +29,14 @@ import { SelectItem, SelectSection, Skeleton, + useDisclosure, } from "@heroui/react"; 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 { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; import { getListArticle, getListArticleAdminPage, @@ -46,6 +52,7 @@ import { textEllipsis, } from "@/utils/global"; import { parseDate, getLocalTimeZone } from "@internationalized/date"; +import { Input } from "@heroui/input"; type ArticleData = Article & { no: number; @@ -67,6 +74,8 @@ interface PostCount { } export default function DashboardContainer() { + const { isOpen, onOpen, onOpenChange } = useDisclosure(); + const username = Cookies.get("username"); const fullname = Cookies.get("ufne"); const [page, setPage] = useState(1); @@ -74,6 +83,7 @@ export default function DashboardContainer() { const [topPagespage, setTopPagesPage] = useState(1); const [topPagesTotalPage, setTopPagesTotalPage] = useState(1); const [article, setArticle] = useState([]); + const [selectedCategory, setSelectedCategory] = useState("polda"); const [analyticsView, setAnalyticView] = useState([ "comment", "view", @@ -108,7 +118,9 @@ export default function DashboardContainer() { const [postCount, setPostCount] = useState([]); const [polresData, setPolresData] = useState({}); const [selectedAccordion, setSelectedAccordion] = useState(new Set([])); - + const [recapArticleList, setRecapArticleList] = useState([]); + const [timeValue, setTimeValue] = useState("--:--"); + const [selectedUnit, setSelectedUnit] = useState(""); const roleId = Cookies.get("urie"); useEffect(() => { @@ -281,6 +293,21 @@ export default function DashboardContainer() { } }; + 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(); + }; + return (
@@ -342,7 +369,7 @@ export default function DashboardContainer() {

Rekapitulasi Post Berita Polda/Polres Pada Website

-
+
+ + + + } + classNames={{ + inputWrapper: [ + "border-none rounded-lg !h-[30px] lg:h-[40px]", + "dark:group-data-[focused=false]:bg-transparent border-none", + ], + }} + />
-
+
NO
-
POLDA/POLRES
+
+ {Number(roleId) < 3 ? ( + + ) : ( + "POLDA/POLRES" + )} +
JUMLAH POST BERITA
@@ -417,9 +487,9 @@ export default function DashboardContainer() {
{list?.no}
{list?.userLevelName}
{list?.totalArticle} @@ -443,14 +513,20 @@ export default function DashboardContainer() {
{child?.userLevelName}
-
{ + if (list?.totalArticle !== 0) { + setSelectedUnit(child?.userLevelName); + openModalArticle(list?.totalArticle); + } + }} + className={`w-[10%] text-start cursor-pointer ${ list?.totalArticle === 0 && - "bg-red-600 text-white" + "bg-red-600 text-white cursor-default" }`} > {child?.totalArticle} -
+
) ) @@ -705,6 +781,44 @@ export default function DashboardContainer() {
+ + + {(onClose) => ( + <> + + {selectedUnit} List Content + + +
+
No
+
Judul
+
Dibuat
+
+ {recapArticleList?.length > 0 && + recapArticleList?.map((list: any) => ( + +
{list.no}
+
+ + {textEllipsis(list.title, 80)} + +
+
+ {convertDateFormat(list?.createdAt)} +
+
+ ))} +
+
+
+ + )} +
+
); } diff --git a/components/page/detail-news.tsx b/components/page/detail-news.tsx index 9b98ec8..2856950 100644 --- a/components/page/detail-news.tsx +++ b/components/page/detail-news.tsx @@ -153,29 +153,33 @@ export default function DetailNews(props: { data: any; listArticle: any }) {

- {data.files[0].file_name.split(".")[1].includes("doc") || - data.files[0].file_name.split(".")[1].includes("pdf") ? ( - Main Image - ) : ( - data?.files?.length > 0 && ( + {data?.files ? ( + data?.files[0]?.file_name.split(".")[1].includes("doc") || + data?.files[0]?.file_name.split(".")[1].includes("pdf") ? ( Main Image + ) : ( + data?.files?.length > 0 && ( + Main Image + ) ) + ) : ( + "" )}
{data?.files?.length > 0 && diff --git a/components/ui/tawkto/load-tawk.tsx b/components/ui/tawkto/load-tawk.tsx new file mode 100644 index 0000000..c8031ba --- /dev/null +++ b/components/ui/tawkto/load-tawk.tsx @@ -0,0 +1,22 @@ +"use client"; +import { useEffect } from "react"; + +const LoadTawk = () => { + useEffect(() => { + const script = document.createElement("script"); + script.src = "https://embed.tawk.to/5d43069be5ae967ef80df561/default"; + script.async = true; + script.charset = "UTF-8"; + script.setAttribute("crossorigin", "*"); + + document.body.appendChild(script); + + return () => { + document.body.removeChild(script); + }; + }, []); + + return null; +}; + +export default LoadTawk;