"use client"; import { Link, usePathname } from "@/i18n/routing"; import { getUserNotifications } from "@/service/landing/landing"; import { getTimestamp } from "@/utils/globals"; import { Icon } from "@iconify/react/dist/iconify.js"; import { useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; const UpdateSection = () => { const pathname = usePathname(); const isUpdate = pathname.includes("update"); const searchParams = useSearchParams(); const page: any = searchParams?.get("page"); const pages = page ? page - 1 : 0; const t = useTranslations("LandingPage"); const [notifications, setNotifications] = useState([]); const [getTotalData, setGetTotalData] = useState(); const [, setGetTotalPage] = useState(); useEffect(() => { async function getNotif() { const response = await getUserNotifications(pages, 2); setNotifications(response?.data?.data?.content); setGetTotalData(response?.data?.data?.totalElements); setGetTotalPage(response?.data?.data?.totalPage); } async function getNotifUpdate() { const response = await getUserNotifications(pages, 3); setNotifications(response?.data?.data?.content); setGetTotalData(response?.data?.data?.totalElements); setGetTotalPage(response?.data?.data?.totalPage); } if (isUpdate) { getNotifUpdate(); } else { getNotif(); } }, [pages]); return (
{" "}

{t("update", { defaultValue: "Update" })}

{t("inbox", { defaultValue: "Inbox" })}
{t("update", { defaultValue: "Update" })}

{t("notifList", { defaultValue: "Notif List" })}

{notifications?.map((list: any) => ( {(() => { switch (Number(list.notificationTypeId)) { case 2: return (
{" "} {" "}
); case 3: return (
{" "} {" "}
); case 4: return (
{" "} {" "}
); case 5: return (
{" "} {" "}
); case 6: return (
{" "} {" "}
); case 7: return (
{" "} {" "}
); case 8: return (
{" "} {" "}
); default: return (
{" "} {" "}
); } })()}
{list.message} {getTimestamp(new Date(list.createdAt))}
))}
); }; export default UpdateSection;