"use client"; import Cookies from "js-cookie"; import Link from "next/link"; import { useEffect, useState } from "react"; import { Article } from "@/types/globals"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import Image from "next/image"; import "react-datepicker/dist/react-datepicker.css"; import { motion } from "framer-motion"; import { DashboardCommentIcon, DashboardConnectIcon, DashboardShareIcon, DashboardSpeecIcon, DashboardUserIcon, } from "@/components/icons/dashboard-icon"; import { Checkbox } from "@/components/ui/checkbox"; import CustomPagination from "@/components/layout/custom-pagination"; import { convertDateFormat } from "@/components/utils/global"; type ArticleData = Article & { no: number; createdAt: string; }; interface TopPages { id: number; no: number; title: string; viewCount: number; } interface PostCount { userLevelId: number; no: number; userLevelName: string; totalArticle: number; } export default function DashboardContainer() { const username = Cookies.get("state"); const fullname = Cookies.get("ufne"); const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); const [topPagesTotalPage, setTopPagesTotalPage] = useState(1); const [article, setArticle] = useState([]); // const [analyticsView, setAnalyticView] = useState(["comment", "view", "share"]); // const [startDateValue, setStartDateValue] = useState(parseDate(convertDateFormatNoTimeV2(new Date()))); // const [postContentDate, setPostContentDate] = useState({ // startDate: parseDate(convertDateFormatNoTimeV2(new Date(new Date().setDate(new Date().getDate() - 7)))), // endDate: parseDate(convertDateFormatNoTimeV2(new Date())), // }); const [startDateValue, setStartDateValue] = useState(new Date()); const [analyticsView, setAnalyticView] = useState([]); const options = [ { label: "Comment", value: "comment" }, { label: "View", value: "view" }, { label: "Share", value: "share" }, ]; const handleChange = (value: string, checked: boolean) => { if (checked) { setAnalyticView([...analyticsView, value]); } else { setAnalyticView(analyticsView.filter((v) => v !== value)); } }; const [postContentDate, setPostContentDate] = useState({ startDate: new Date(new Date().setDate(new Date().getDate() - 7)), endDate: new Date(), }); const [typeDate, setTypeDate] = useState("monthly"); const [summary, setSummary] = useState(); const [topPages, setTopPages] = useState([]); const [postCount, setPostCount] = useState([]); const getTableNumber = (limit: number, data: any) => { if (data) { const startIndex = limit * (page - 1); let iterate = 0; const newData = data.map((value: any) => { iterate++; value.no = startIndex + iterate; return value; }); return newData; } }; const getMonthYear = (date: any) => { return date.month + " " + date.year; }; const getMonthYearName = (date: any) => { const newDate = new Date(date); const months = [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember", ]; const year = newDate.getFullYear(); const month = months[newDate.getMonth()]; return month + " " + year; }; return (
{/* Stats Cards */}
{/* User Profile Card */}

Welcome back,

{username}

Admin Dashboard

{/* Total Posts */}

{summary?.totalAll || 0}

Total Posts

{/* Total Views */}

{summary?.totalViews || 0}

Total Views

{/* Total Shares */}

{summary?.totalShares || 0}

Total Shares

{/* Total Comments */}

{summary?.totalComments || 0}

Total Comments

{/* Content Section */}
{/* Analytics Chart */}

Analytics Overview

{options.map((option) => ( ))}

Chart will be displayed here

{/* Recent Articles */} {/*

Recent Content

*/}
{article?.map((list: any) => ( thumbnail

{list?.title}

{convertDateFormat(list?.createdAt)}

))}
setPage(data)} />
); }