"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 { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import "react-datepicker/dist/react-datepicker.css"; import { Checkbox } from "@/components/ui/checkbox"; import { Label } from "@/components/ui/label"; import { Calendar } from "@/components/ui/calendar"; import ApexChartColumn from "@/components/main/dashboard/chart/column-chart"; import CustomPagination from "@/components/layout/custom-pagination"; import { motion } from "framer-motion"; import { Input } from "@/components/ui/input"; import { SelectTrigger, SelectValue, SelectContent, SelectItem, Select, } from "@/components/ui/select"; import { Badge } from "lucide-react"; 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 [levelName, setLevelName] = useState(); useEffect(() => { const levelId = Cookies.get("ulne"); setLevelName(levelId); }, []); const username = Cookies.get("username"); 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; }; if (!levelName) return null; const AdminDashboard = () => { const tasks = [ { id: "1", title: "MediaHUB Content Aggregator", author: "John Kontributor", category: "Product", date: "2026-02-13", status: "OPEN", }, { id: "2", title: "Mudik Nyaman Bersama Pertamina: Layanan 24 Jam, Motoris, dan Fasilitas Lengkap", author: "Jane Kontributor", category: "Service", date: "2026-02-13", status: "OPEN", }, { id: "3", title: "Artifintel Services Update", author: "Alex Approver", category: "Event", date: "2026-02-13", status: "CLOSED", }, ]; return (
{/* HEADER */}

Admin Dashboard

Review and manage content submissions

{/* STAT CARDS */}
{[ { title: "Open Tasks", value: 2, color: "bg-yellow-500" }, { title: "Closed Tasks", value: 2, color: "bg-green-600" }, { title: "Total Submissions", value: 4, color: "bg-blue-600" }, { title: "Rejected", value: 7, color: "bg-red-600" }, ].map((card, i) => (

{card.title}

{card.value}

))}
{/* TASK LIST */}
{/* Title */}

Task List{" "} {tasks.length} Tasks

{/* Filters */}
{/* Accordion List */} {tasks.map((task) => (

{task.title}

{task.author} • {task.category} • {task.date}

{task.status} {/* Mini Progress */}
{/* Title */}

Document Flow Status

{/* Stepper */}
{/* Line */}
{/* STEP 1 */}

Submission

Feb 13, 2026 09:00

{/* STEP 2 */}

Technical Review

Feb 13, 2026 11:00

{/* STEP 3 */}

Admin Verification

Waiting

{/* STEP 4 */}

Final Approval

Waiting

))}
); }; const ContributorDashboard = () => { const stats = [ { title: "Total Content", value: 24, growth: "+12%", iconBg: "bg-blue-600", }, { title: "Pending Approval", value: 8, growth: "+3", iconBg: "bg-yellow-500", }, { title: "Published", value: 16, growth: "+5", iconBg: "bg-green-600", }, { title: "Rejected", value: 2, growth: "-1", iconBg: "bg-red-600", }, ]; const contents = [ { title: "MediaHUB Content Aggregator", category: "Product", time: "2 hours ago", status: "Pending", }, { title: "Mudik Nyaman Bersama Pertamina: Layanan 24 Jam, Motoris, dan Fasilitas Lengkap", category: "News", time: "5 hours ago", status: "Approved", }, { title: "Artifintel Services Update", category: "Service", time: "1 day ago", status: "Pending", }, { title: "Bharatu Mardi Hadji Gugur Saat Bertugas, Diganjar Kenaikan Pangkat Luar Biasa", category: "Pop Up", time: "1 day ago", status: "Draft", }, ]; return (
{/* Header */}

Dashboard

{/* ================= STAT CARDS ================= */}
{stats.map((card, i) => (

{card.title}

{card.value}

{card.growth}

))}
{/* ================= CONTENT + QUICK ACTIONS ================= */}
{/* LEFT - RECENT CONTENT */}

Recent Content

{contents.map((item, i) => (

{item.title}

{item.category} • {item.time}

{item.status}
))}
{/* RIGHT - QUICK ACTIONS */}

Quick Actions

); }; const ApproverDashboard = () => { const stats = [ { title: "Pending Review", value: 12, growth: "+3", color: "bg-yellow-500", }, { title: "Approved Today", value: 8, growth: "+5", color: "bg-green-600", }, { title: "Total Published", value: 156, growth: "+12%", color: "bg-blue-600", }, { title: "Rejected", value: 5, growth: "-1", color: "bg-red-600", }, ]; const pendingList = [ { title: "MediaHUB Content Aggregator", author: "John Kontributor", category: "Product", time: "2 hours ago", status: "Pending", }, { title: "Artifintel Services Update", author: "John Kontributor", category: "Service", time: "2 hours ago", status: "Pending", }, ]; const activities = [ { status: "Approved", title: "Technology Summit Event", time: "10 mins ago", }, { status: "Rejected", title: "Product Update Draft", time: "25 mins ago", }, { status: "Approved", title: "Partner Logo Update", time: "1 hour ago", }, ]; return (
{/* HEADER */}

Approver Dashboard

Review and manage content submissions

{/* ================= STAT CARDS ================= */}
{stats.map((card, i) => (

{card.title}

{card.value}

{card.growth}

))}
{/* ================= CONTENT SECTION ================= */}
{/* LEFT - Pending Review */}

Pending Review{" "} {pendingList.length} Items

{pendingList.map((item, i) => (

{item.title}

{item.author} • {item.category} • {item.time}

{item.status}
))}
{/* RIGHT - Recent Activity */}

Recent Activity

{activities.map((item, i) => (

{item.status}

{item.title}

{item.time}

))}
); }; return ( <> {levelName === "1" && } {levelName === "3" && } {levelName === "2" && } ); }