import { GlobalNoticeRep } from "@/api/home";
import Tabs from "@/components/Tabs";
import { server } from "@/utils/server";
import { getTranslations } from "next-intl/server";
import Notices from "./components/Notices";

const getSystemNotifications = async () => {
    return server.request<GlobalNoticeRep[]>({
        url: "/v1/api/front/notice_list",
        method: "post",
        data: {},
    });
};
const getUserNotices = () => {
    return server.request<GlobalNoticeRep[]>({
        url: "/v1/api/front/notice_user_list",
        method: "POST",
        data: {},
    });
};
const Notification = async () => {
    const systemNotices = await getSystemNotifications();
    const userNotices = await getUserNotices();
    const t = await getTranslations("ProfilePage");
    const defaultTabs = [
        {
            id: 1,
            name: t("systemMessage"),
            content: 0,
            render: <Notices data={systemNotices.data} type={"system"} />,
        },
        {
            id: 2,
            name: t("personalMessage"),
            content: 0,
            render: <Notices data={userNotices.data} type={"user"} />,
        },
    ];
    return (
        <div className={"overflow-visible"}>
            <Tabs items={defaultTabs} />
        </div>
    );
};

export default Notification;
