import React, { useState } from "react"; import { useSelector } from "react-redux"; import TimeDifference from "../Helpers/TimeDifference"; import { handlePagingFunc } from "../Pagination/HandlePagination"; import PaginatedList from "../Pagination/PaginatedList"; import Layout from "../Partials/Layout"; const tabs = [ { id: 1, date: "today", title: "Today's", }, { id: 1, date: "days", title: "7 days", }, { id: 1, date: "all", title: "All", }, ]; export default function Notification() { const [selectTab, setValue] = useState(tabs ? tabs[0].title : ""); const { notifications } = useSelector((state) => state?.notifications); const [currentPage, setCurrentPage] = useState(0); const indexOfFirstItem = Number(currentPage); const indexOfLastItem = Number(indexOfFirstItem) + 6; const currentNotifications = notifications?.data?.raw?.slice( indexOfFirstItem, indexOfLastItem ); console.log(currentNotifications); const filterHandler = (value) => { setValue(value); }; const handlePagination = (e) => { handlePagingFunc(e, setCurrentPage); }; return (
{/* heading */}

{selectTab + " "} Notifications

{tabs.map(({ id, title, date }) => (
filterHandler(title)} className="relative"> {title} {date === "today" && ( {notifications?.data?.raw?.length} )}
))}
{/* Body */}
    {currentNotifications?.length > 0 ? ( <> {currentNotifications?.map(({ date, icon, title }, idx) => { return ( ); })} ) : ( "No Notifications Available" )}
{/* PAGINATION BUTTON */} = currentNotifications?.length ? true : false } data={currentNotifications} start={indexOfFirstItem} stop={indexOfLastItem} />
); } const NotificationItem = ({ date, icon, title, length }, idx) => { return (
  • icon

    {title}

  • ); };