"use client";
import React, { useEffect, useState } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Icon } from "@iconify/react/dist/iconify.js";
import { formatDateToIndonesian, getOnlyDate, getOnlyMonthAndYear } from "@/utils/globals";
import { useParams, usePathname, useSearchParams } from "next/navigation";
import { getListContent, getUserLevelListByParent, listCategory, listData, listDataRegional } from "@/service/landing/landing";
import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
import LandingPagination from "@/components/landing-page/pagination";
import { Reveal } from "@/components/landing-page/Reveal";
import { Link, useRouter } from "@/i18n/routing";
import { Input } from "@/components/ui/input";
import ReactDatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { close, loading } from "@/config/swal";
import { useTranslations } from "next-intl";

const columns: ColumnDef<any>[] = [
  {
    accessorKey: "no",
    header: "No",
    cell: ({ row }) => <span>{row.getValue("no")}</span>,
  },
];

const FilterPage = () => {
  const router = useRouter();
  const asPath = usePathname();
  const params = useParams();
  const searchParams = useSearchParams();
  const locale = params?.locale;
  const [documentData, setDocumentData] = useState<any>();
  const [totalData, setTotalData] = React.useState<number>(1);
  const [totalPage, setTotalPage] = React.useState<number>(1);
  const [sorting, setSorting] = React.useState<SortingState>([]);
  const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>([]);
  const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({});
  const [rowSelection, setRowSelection] = React.useState({});
  const [pagination, setPagination] = React.useState<PaginationState>({
    pageIndex: 0,
    pageSize: 10,
  });
  const [page, setPage] = useState(1);
  const [totalContent, setTotalContent] = useState();
  const [change, setChange] = useState(false);
  const sortBy = searchParams?.get("sortBy");
  const title = searchParams?.get("title");
  const categorie = searchParams?.get("category");
  const group = searchParams?.get("group");
  const [, setGetTotalPage] = useState();
  const t = useTranslations("FilterPage");
  let typingTimer: any;
  const doneTypingInterval = 1500;
  const [contentDocument, setContentDocument] = useState([]);
  const [categoryFilter, setCategoryFilter] = useState<any>([]);
  const [monthYearFilter, setMonthYearFilter] = useState<any>();
  const [searchTitle, setSearchTitle] = useState<string>("");
  const [sortByOpt, setSortByOpt] = useState<any>(sortBy === "popular" ? "clickCount" : "createdAt");
  const isRegional = asPath?.includes("regional");
  const isSatker = asPath?.includes("satker");
  const [formatFilter, setFormatFilter] = useState<any>([]);
  const pages = page ? page - 1 : 0;
  const [startDateString, setStartDateString] = useState<any>();
  const [endDateString, setEndDateString] = useState<any>();
  const [dateRange, setDateRange] = useState<any>([null, null]);
  const [calenderState, setCalenderState] = useState(false);
  const [handleClose, setHandleClose] = useState(false);
  const [categories, setCategories] = useState([]);
  const [userLevels, setUserLevels] = useState([]);
  const poldaName = params?.polda_name;
  let prefixPath = poldaName ? `/polda/${poldaName}` : "/";

  // const [startDate, endDate] = dateRange;

  React.useEffect(() => {
    const pageFromUrl = searchParams?.get("page");
    if (pageFromUrl) {
      setPage(Number(pageFromUrl));
    }
  }, [searchParams]);

  useEffect(() => {
    async function initState() {
      getCategories();
      // getSelectedCategory();
      if (isSatker) {
        getUserLevels();
      }
    }

    initState();
  }, []);

  useEffect(() => {
    if (categorie) {
      setCategoryFilter(categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]);
      console.log("Kategori", categorie, categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]);
    }
  }, [categorie]);

  // useEffect(() => {
  //   fetchData();
  // }, [page, sortBy, sortByOpt, title]);

  useEffect(() => {
    async function initState() {
      if (isRegional) {
        getDataRegional();
      } else {
        getDataAll();
      }
    }
    console.log(monthYearFilter, "monthFilter");
    initState();
  }, [change, asPath, monthYearFilter, page, sortBy, sortByOpt, title, startDateString, endDateString, categorie, formatFilter]);

  async function getCategories() {
    const category = await listCategory("3");
    const resCategory = category?.data?.data?.content;
    setCategories(resCategory);
  }

  useEffect(() => {
    function initState() {
      if (dateRange[0] != null && dateRange[1] != null) {
        setStartDateString(getOnlyDate(dateRange[0]));
        setEndDateString(getOnlyDate(dateRange[1]));
        setHandleClose(true);
        console.log("date range", dateRange, getOnlyDate(dateRange[0]));
      }
    }
    initState();
  }, [calenderState]);

  async function getDataAll() {
    if (poldaName && String(poldaName)?.length > 1) {
      const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || "";

      const name = title == undefined ? "" : title;
      const format = formatFilter == undefined ? "" : formatFilter?.join(",");
      const filterGroup = String(poldaName);
      loading();
      const response = await listData(
        "3",
        name,
        filter,
        12,
        pages,
        sortByOpt,
        format,
        "",
        filterGroup,
        startDateString,
        endDateString,
        monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "",
        monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : ""
      );
      close();
      // setGetTotalPage(response?.data?.data?.totalPages);
      // setContentImage(response?.data?.data?.content);
      // setTotalContent(response?.data?.data?.totalElements);
      const data = response?.data?.data;
      const contentData = data?.content;
      setDocumentData(contentData);
      setTotalData(data?.totalElements);
      setTotalPage(data?.totalPages);
      setTotalContent(response?.data?.data?.totalElements);
    } else {
      const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || "";

      const name = title == undefined ? "" : title;
      const format = formatFilter == undefined ? "" : formatFilter?.join(",");
      loading();
      const response = await listData(
        "3",
        name,
        filter,
        12,
        pages,
        sortByOpt,
        format,
        "",
        "",
        startDateString,
        endDateString,
        monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "",
        monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : ""
      );
      close();
      // setGetTotalPage(response?.data?.data?.totalPages);
      // setContentImage(response?.data?.data?.content);
      // setTotalContent(response?.data?.data?.totalElements);
      const data = response?.data?.data;
      const contentData = data?.content;
      setDocumentData(contentData);
      setTotalData(data?.totalElements);
      setTotalPage(data?.totalPages);
      setTotalContent(response?.data?.data?.totalElements);
    }
  }

  const handleCategoryFilter = (e: boolean, id: string) => {
    let filter = [...categoryFilter];

    if (e) {
      filter = [...categoryFilter, String(id)];
    } else {
      filter.splice(categoryFilter.indexOf(id), 1);
    }
    console.log("checkbox filter", filter);
    setCategoryFilter(filter);
    router.push(`?category=${filter.join("&")}`);
  };

  const handleFormatFilter = (e: boolean, id: string) => {
    let filter = [...formatFilter];

    if (e) {
      filter = [...formatFilter, id];
    } else {
      filter.splice(formatFilter.indexOf(id), 1);
    }
    console.log("Format filter", filter);
    setFormatFilter(filter);
  };

  const cleanCheckbox = () => {
    setCategoryFilter([]);
    setFormatFilter([]);
    router.push(`?category=&title=`);
    setDateRange([null, null]);
    setMonthYearFilter(null);
    setChange(!change);
  };

  async function getDataRegional() {
    const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || "";

    const name = title == undefined ? "" : title;
    const format = formatFilter == undefined ? "" : formatFilter?.join(",");
    loading();
    const response = await listDataRegional(
      "3",
      name,
      filter,
      format,
      "",
      startDateString,
      endDateString,
      monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "",
      monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "",
      12,
      pages,
      sortByOpt
    );
    close();

    setGetTotalPage(response?.data?.data?.totalPages);
    setContentDocument(response?.data?.data?.content);
    setTotalContent(response?.data?.data?.totalElements);
  }

  const table = useReactTable({
    data: documentData,
    columns: columns,
    onSortingChange: setSorting,
    onColumnFiltersChange: setColumnFilters,
    getCoreRowModel: getCoreRowModel(),
    getPaginationRowModel: getPaginationRowModel(),
    getSortedRowModel: getSortedRowModel(),
    getFilteredRowModel: getFilteredRowModel(),
    onColumnVisibilityChange: setColumnVisibility,
    onRowSelectionChange: setRowSelection,
    onPaginationChange: setPagination,
    state: {
      sorting,
      columnFilters,
      columnVisibility,
      rowSelection,
      pagination,
    },
  });

  useEffect(() => {
    initFetch();
  }, [page]);
  const initFetch = async () => {
    const response = await getListContent({ page: page - 1, size: 6, sortBy: "createdAt", contentTypeId: "3" });
    console.log(response);
    setDocumentData(response?.data?.data?.content);
    const data = response?.data?.data;
    const contentData = data?.content;
    setDocumentData(contentData);
    setTotalData(data?.totalElements);
    setTotalPage(data?.totalPages);
  };

  function getSelectedCategory() {
    const filter = [];

    if (categorie) {
      const categoryArr = categorie.split(",");

      for (const element of categoryArr) {
        filter.push(Number(element));
      }

      setCategoryFilter(filter);
    }
  }

  const handleDeleteDate = () => {
    setDateRange([null, null]);
    setStartDateString("");
    setEndDateString("");
    setHandleClose(false);
  };

  const handleSorting = (e: any) => {
    console.log(e.target.value);
    if (e.target.value == "terbaru") {
      setSortByOpt("createdAt");
    } else {
      setSortByOpt("clickCount");
    }

    setChange(!change);
  };

  async function getUserLevels() {
    const res = await getUserLevelListByParent(761);
    const userLevelList = res?.data?.data;

    if (userLevelList !== null) {
      let optionArr: any = [];

      userLevelList?.map((option: any) => {
        let optionData = {
          id: option.id,
          label: option.name,
          value: option.id,
        };

        optionArr.push(optionData);
      });

      setUserLevels(optionArr);
    }
  }

  const handleKeyUp = () => {
    clearTimeout(typingTimer);
    typingTimer = setTimeout(doneTyping, doneTypingInterval);
  };

  async function doneTyping() {
    if (searchTitle == "" || searchTitle == undefined) {
      router.push("?title=");
    } else {
      router.push(`?title=${searchTitle}`);
    }
  }

  const handleKeyDown = () => {
    clearTimeout(typingTimer);
  };

  return (
    <div className="flex flex-col">
      {/* Header */}

      <div className="flex flex-col md:flex-row items-start gap-5 p-10 bg-[#f7f7f7] dark:bg-black">
        <p>
          {" "}
          {t("text")} {">"} <span className="font-bold">{t("allText")}</span>
        </p>
        <p className="font-bold">|</p>
        <p>{`${t("thereIs")} ${totalContent} ${t("downloadableText")}`}</p>
      </div>

      {/* Left */}
      <div className="flex flex-col lg:flex-row gap-6 p-4">
        <div className="lg:w-[25%] w-full bg-[#f7f7f7] dark:bg-black p-4 rounded-lg shadow-md">
          <h2 className="text-lg font-semibold mb-4 flex items-center gap-1">
            <Icon icon="stash:filter-light" fontSize={30} />
            Filter
          </h2>
          <div className="border-t border-black my-4 dark:border-white"></div>
          <div className="space-y-6">
            <div>
              <label htmlFor="search" className="block text-sm font-medium text-gray-700 dark:text-white">
                {t("search")}
              </label>
              <Input
                value={searchTitle}
                onChange={(e) => setSearchTitle(e.target.value)}
                onKeyUp={handleKeyUp}
                onKeyDown={handleKeyDown}
                type="text"
                id="search"
                placeholder={t("searchTitle")}
                className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
              />
            </div>

            <div>
              <label className="block text-sm font-medium text-gray-700 dark:text-white">{t("monthYear")}</label>
              <ReactDatePicker
                selected={monthYearFilter}
                className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
                onChange={(date) => setMonthYearFilter(date)}
                dateFormat="MM | yyyy"
                placeholderText={t("selectYear")}
                showMonthYearPicker
              />
            </div>

            <div>
              <label className="block text-sm font-medium text-gray-700 dark:text-white">{t("date")}</label>
              <div className="flex flex-row justify justify-between gap-2">
                <ReactDatePicker
                  selectsRange
                  className="mt-1 w-full border text-sm rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
                  startDate={dateRange[0]}
                  endDate={dateRange[1]}
                  onChange={(update) => {
                    setDateRange(update);
                  }}
                  placeholderText={t("selectDate")}
                  onCalendarClose={() => setCalenderState(!calenderState)}
                />
                <div className="flex items-center">{handleClose ? <Icon icon="carbon:close-filled" onClick={handleDeleteDate} width="20" inline color="#216ba5" /> : ""}</div>
              </div>
            </div>

            <div>
              <h3 className="text-sm font-medium text-gray-700 dark:text-white">{t("categories")}</h3>
              <ul className="mt-2 space-y-2">
                {categories.map((category: any) => (
                  <li key={category?.id}>
                    <label className="inline-flex items-center" htmlFor={`${category.id}`}>
                      <Checkbox id={`${category.id}`} value={category.id} checked={categoryFilter.includes(String(category.id))} onCheckedChange={(e) => handleCategoryFilter(Boolean(e), category.id)} />
                      <span className="ml-2 text-gray-700 dark:text-white">{category?.name}</span>
                    </label>
                  </li>
                ))}
              </ul>
            </div>
            {/* Garis */}
            <div className="border-t border-black my-4 dark:border-white"></div>
            {/* Garis */}
            <div>
              <h3 className="text-sm font-medium text-gray-700 dark:text-white">Format</h3>
              <ul className="mt-2 space-y-2">
                <li>
                  <label className="inline-flex items-center">
                    <Checkbox id="doc" value="doc" checked={formatFilter.includes("doc")} onCheckedChange={(e) => handleFormatFilter(Boolean(e), "doc")} />
                    <span className="ml-2 text-gray-700 dark:text-white">DOC</span>
                  </label>
                </li>
                <li>
                  <label className="inline-flex items-center">
                    <Checkbox id="docx" value="docx" checked={formatFilter.includes("docx")} onCheckedChange={(e) => handleFormatFilter(Boolean(e), "docx")} />
                    <span className="ml-2 text-gray-700 dark:text-white">DOCX</span>
                  </label>
                </li>
                <li>
                  <label className="inline-flex items-center">
                    <Checkbox id="pdf" value="pdf" checked={formatFilter.includes("pdf")} onCheckedChange={(e) => handleFormatFilter(Boolean(e), "pdf")} />
                    <span className="ml-2 text-gray-700 dark:text-white">PDF</span>
                  </label>
                </li>
                <li>
                  <label className="inline-flex items-center">
                    <Checkbox id="ppt" value="ppt" checked={formatFilter.includes("ppt")} onCheckedChange={(e) => handleFormatFilter(Boolean(e), "ppt")} />
                    <span className="ml-2 text-gray-700 dark:text-white">PPT</span>
                  </label>
                </li>
                <li>
                  <label className="inline-flex items-center">
                    <Checkbox id="pptx" value="pptx" checked={formatFilter.includes("pptx")} onCheckedChange={(e) => handleFormatFilter(Boolean(e), "pptx")} />
                    <span className="ml-2 text-gray-700 dark:text-white">PPTX</span>
                  </label>
                </li>
              </ul>
            </div>
            <div className="border-t border-black dark:border-white my-4"></div>
            <div className="text-center">
              <a onClick={cleanCheckbox} className="text-[#bb3523] cursor-pointer">
                <b>Reset Filter</b>
              </a>
            </div>
          </div>
        </div>

        {/* Konten Kanan */}
        <Reveal>
          <div className="flex-1">
            <div className="flex flex-col items-end mb-4">
              <h2 className="text-lg font-semibold">{t("sortBy")}</h2>
              <select defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"} onChange={(e) => handleSorting(e)} className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500">
                <option value="latest">{t("latest")}</option>
                <option value="popular">{t("mostPopular")}</option>
              </select>
            </div>

            {documentData?.length > 0 ? (
              <div className=" grid grid-cols-1 md:grid-cols-2 gap-6">
                {documentData?.map((document: any) => (
                  <Link href={`${prefixPath}/document/detail/${document?.slug}`} key={document?.id} className="flex flex-col bg-yellow-500 sm:flex-row items-center dark:bg-gray-800 cursor-pointer shadow-md rounded-lg p-4 gap-4 w-full">
                    <div className="flex items-center justify-center rounded-lg w-16 h-16">
                      <svg width="28" height="34" viewBox="0 0 28 34" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path
                          d="M5.6665 17.4167C5.6665 17.0851 5.7982 16.7672 6.03262 16.5328C6.26704 16.2984 6.58498 16.1667 6.9165 16.1667C7.24802 16.1667 7.56597 16.2984 7.80039 16.5328C8.03481 16.7672 8.1665 17.0851 8.1665 17.4167C8.1665 17.7482 8.03481 18.0661 7.80039 18.3005C7.56597 18.535 7.24802 18.6667 6.9165 18.6667C6.58498 18.6667 6.26704 18.535 6.03262 18.3005C5.7982 18.0661 5.6665 17.7482 5.6665 17.4167ZM6.9165 21.1667C6.58498 21.1667 6.26704 21.2984 6.03262 21.5328C5.7982 21.7672 5.6665 22.0851 5.6665 22.4167C5.6665 22.7482 5.7982 23.0661 6.03262 23.3005C6.26704 23.535 6.58498 23.6667 6.9165 23.6667C7.24802 23.6667 7.56597 23.535 7.80039 23.3005C8.03481 23.0661 8.1665 22.7482 8.1665 22.4167C8.1665 22.0851 8.03481 21.7672 7.80039 21.5328C7.56597 21.2984 7.24802 21.1667 6.9165 21.1667ZM5.6665 27.4167C5.6665 27.0851 5.7982 26.7672 6.03262 26.5328C6.26704 26.2984 6.58498 26.1667 6.9165 26.1667C7.24802 26.1667 7.56597 26.2984 7.80039 26.5328C8.03481 26.7672 8.1665 27.0851 8.1665 27.4167C8.1665 27.7482 8.03481 28.0661 7.80039 28.3005C7.56597 28.535 7.24802 28.6667 6.9165 28.6667C6.58498 28.6667 6.26704 28.535 6.03262 28.3005C5.7982 28.0661 5.6665 27.7482 5.6665 27.4167ZM11.9165 16.1667C11.585 16.1667 11.267 16.2984 11.0326 16.5328C10.7982 16.7672 10.6665 17.0851 10.6665 17.4167C10.6665 17.7482 10.7982 18.0661 11.0326 18.3005C11.267 18.535 11.585 18.6667 11.9165 18.6667H21.0832C21.4147 18.6667 21.7326 18.535 21.9671 18.3005C22.2015 18.0661 22.3332 17.7482 22.3332 17.4167C22.3332 17.0851 22.2015 16.7672 21.9671 16.5328C21.7326 16.2984 21.4147 16.1667 21.0832 16.1667H11.9165ZM10.6665 22.4167C10.6665 22.0851 10.7982 21.7672 11.0326 21.5328C11.267 21.2984 11.585 21.1667 11.9165 21.1667H21.0832C21.4147 21.1667 21.7326 21.2984 21.9671 21.5328C22.2015 21.7672 22.3332 22.0851 22.3332 22.4167C22.3332 22.7482 22.2015 23.0661 21.9671 23.3005C21.7326 23.535 21.4147 23.6667 21.0832 23.6667H11.9165C11.585 23.6667 11.267 23.535 11.0326 23.3005C10.7982 23.0661 10.6665 22.7482 10.6665 22.4167ZM11.9165 26.1667C11.585 26.1667 11.267 26.2984 11.0326 26.5328C10.7982 26.7672 10.6665 27.0851 10.6665 27.4167C10.6665 27.7482 10.7982 28.0661 11.0326 28.3005C11.267 28.535 11.585 28.6667 11.9165 28.6667H21.0832C21.4147 28.6667 21.7326 28.535 21.9671 28.3005C22.2015 28.0661 22.3332 27.7482 22.3332 27.4167C22.3332 27.0851 22.2015 26.7672 21.9671 26.5328C21.7326 26.2984 21.4147 26.1667 21.0832 26.1667H11.9165ZM26.3565 11.0233L16.6415 1.31C16.6157 1.28605 16.5885 1.26378 16.5598 1.24333C16.5392 1.22742 16.5192 1.21074 16.4998 1.19333C16.3852 1.08512 16.2632 0.984882 16.1348 0.893332C16.0922 0.865802 16.0476 0.841298 16.0015 0.819999L15.9215 0.779999L15.8382 0.731666C15.7482 0.679999 15.6565 0.626665 15.5615 0.586665C15.2296 0.454104 14.8783 0.376423 14.5215 0.356665C14.4885 0.354519 14.4557 0.350625 14.4232 0.344999C14.3779 0.338012 14.3323 0.334114 14.2865 0.333332H3.99984C3.11578 0.333332 2.26794 0.684521 1.64281 1.30964C1.01769 1.93476 0.666504 2.78261 0.666504 3.66667V30.3333C0.666504 31.2174 1.01769 32.0652 1.64281 32.6904C2.26794 33.3155 3.11578 33.6667 3.99984 33.6667H23.9998C24.8839 33.6667 25.7317 33.3155 26.3569 32.6904C26.982 32.0652 27.3332 31.2174 27.3332 30.3333V13.38C27.333 12.496 26.9817 11.6483 26.3565 11.0233ZM24.8332 30.3333C24.8332 30.5543 24.7454 30.7663 24.5891 30.9226C24.4328 31.0789 24.2208 31.1667 23.9998 31.1667H3.99984C3.77882 31.1667 3.56686 31.0789 3.41058 30.9226C3.2543 30.7663 3.1665 30.5543 3.1665 30.3333V3.66667C3.1665 3.44565 3.2543 3.23369 3.41058 3.07741C3.56686 2.92113 3.77882 2.83333 3.99984 2.83333H13.9998V10.3333C13.9998 11.2174 14.351 12.0652 14.9761 12.6904C15.6013 13.3155 16.4491 13.6667 17.3332 13.6667H24.8332V30.3333ZM16.4998 4.70166L22.9632 11.1667H17.3332C17.1122 11.1667 16.9002 11.0789 16.7439 10.9226C16.5876 10.7663 16.4998 10.5543 16.4998 10.3333V4.70166Z"
                          fill="black"
                        />
                      </svg>
                    </div>
                    <div className="flex flex-col flex-1 gap-2">
                      <div className="text-gray-500 dark:text-gray-400 flex flex-row items-center gap-2 text-xs">
                        {formatDateToIndonesian(new Date(document?.createdAt))} {document?.timezone ? document?.timezone : "WIB"} | <Icon icon="formkit:eye" width="15" height="15" /> 518
                      </div>
                      <div className="font-semibold text-gray-900 dark:text-white mt-1 text-sm">{document?.title}</div>
                      <div className="flex gap-2 items-center text-xs text-red-500 dark:text-red-500">
                        <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 512 512">
                          <path fill="#f00" d="M224 30v256h-64l96 128l96-128h-64V30zM32 434v48h448v-48z" />
                        </svg>
                        Download Dokumen
                      </div>
                    </div>
                  </Link>
                ))}
              </div>
            ) : (
              <p className="flex items-center justify-center">
                <img src="/assets/empty-data.png" alt="empty" className="h-60 w-60 my-4" />
              </p>
            )}

            <LandingPagination table={table} totalData={totalData} totalPage={totalPage} />
          </div>
        </Reveal>
      </div>
    </div>
  );
};

export default FilterPage;
