2025-01-10 11:29:00 +00:00
|
|
|
"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 { useRouter } from "next/navigation";
|
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
|
|
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 [notifications, setNotifications] = useState([]);
|
|
|
|
|
const [getTotalData, setGetTotalData] = useState();
|
|
|
|
|
const [, setGetTotalPage] = useState();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function getNotif() {
|
2025-01-12 07:41:04 +00:00
|
|
|
const response = await getUserNotifications(pages, 2);
|
2025-01-10 11:29:00 +00:00
|
|
|
setNotifications(response?.data?.data?.content);
|
|
|
|
|
setGetTotalData(response?.data?.data?.totalElements);
|
|
|
|
|
setGetTotalPage(response?.data?.data?.totalPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getNotifUpdate() {
|
2025-01-12 07:41:04 +00:00
|
|
|
const response = await getUserNotifications(pages, 3);
|
2025-01-10 11:29:00 +00:00
|
|
|
setNotifications(response?.data?.data?.content);
|
|
|
|
|
setGetTotalData(response?.data?.data?.totalElements);
|
|
|
|
|
setGetTotalPage(response?.data?.data?.totalPage);
|
2025-01-12 07:41:04 +00:00
|
|
|
}
|
2025-01-10 11:29:00 +00:00
|
|
|
|
|
|
|
|
if (isUpdate) {
|
|
|
|
|
getNotifUpdate();
|
|
|
|
|
} else {
|
|
|
|
|
getNotif();
|
|
|
|
|
}
|
2025-01-12 07:41:04 +00:00
|
|
|
}, [pages]);
|
2025-01-10 11:29:00 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="max-w-6xl h-screen flex flex-col mx-auto p-4 lg:p-24 gap-5">
|
|
|
|
|
<div className="flex items-center justify-center mb-6">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="60px" height="60px" viewBox="0 0 24 24">
|
|
|
|
|
<g fill="#bb3523" fill-rule="evenodd" clip-rule="evenodd">
|
|
|
|
|
<path d="M16 9a4 4 0 1 1-8 0a4 4 0 0 1 8 0m-2 0a2 2 0 1 1-4 0a2 2 0 0 1 4 0" />
|
|
|
|
|
<path d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11s11-4.925 11-11S18.075 1 12 1M3 12c0 2.09.713 4.014 1.908 5.542A8.99 8.99 0 0 1 12.065 14a8.98 8.98 0 0 1 7.092 3.458A9 9 0 1 0 3 12m9 9a8.96 8.96 0 0 1-5.672-2.012A6.99 6.99 0 0 1 12.065 16a6.99 6.99 0 0 1 5.689 2.92A8.96 8.96 0 0 1 12 21" />
|
|
|
|
|
</g>
|
|
|
|
|
</svg>{" "}
|
|
|
|
|
<h2 className="ml-4 text-[15px] lg:text-[32px] font-semibold text-gray-800">Update</h2>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-01-12 07:41:04 +00:00
|
|
|
<div className="flex flex-col items-center gap-3">
|
2025-01-10 11:29:00 +00:00
|
|
|
<div className="flex justify-center">
|
|
|
|
|
<div className="flex flex-row gap-10 items-center justify-center">
|
|
|
|
|
<div>
|
|
|
|
|
<Link href={`/inbox`}>Pesan Masuk</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-[#bb3523] py-1 px-3 rounded-full">Update</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-12 07:41:04 +00:00
|
|
|
<div className="py-10 px-8 w-[400px] mt-3 border border-black rounded-lg flex flex-col">
|
|
|
|
|
<h1 className="mb-3 text-lg font-semibold">List Notifikasi</h1>
|
|
|
|
|
<div className="hover:bg-slate-200 rounded-md">
|
|
|
|
|
{notifications?.map((list: any) => (
|
|
|
|
|
<a className="flex flex-row items-center ml-1" href={"/" + list.redirectUrl}>
|
|
|
|
|
{(() => {
|
|
|
|
|
switch (Number(list.notificationTypeId)) {
|
|
|
|
|
case 2:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:comment" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:upload" fontSize={25} />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="la:check-double" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:comments" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
return (
|
|
|
|
|
<div className="notif-icon notif-danger">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:tasks" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
return (
|
|
|
|
|
<div className="notif-icon notif-primary">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:pencil-square" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:times-circle" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<div className="text-red-500">
|
|
|
|
|
{" "}
|
|
|
|
|
<Icon icon="fa:info-circle" />{" "}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
})()}
|
|
|
|
|
<div className="ml-3">
|
|
|
|
|
<span className="block">{list.message}</span>
|
|
|
|
|
<span className="text-xs">{getTimestamp(new Date(list.createdAt))}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2025-01-10 11:29:00 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default UpdateSection;
|