/**
 * Mock 通知数据（push-gateway + msg 域）
 *
 * 维护者：ai13（teacher-portal）
 * 关联：02-architecture-design.md §5 实时推送
 */

import type { NotificationItem } from "@/lib/graphql-p5";

const now = Date.now();
const minute = 60 * 1000;
const hour = 60 * minute;
const day = 24 * hour;

export const mockNotifications: NotificationItem[] = [
  {
    id: "ntf-001",
    type: "HOMEWORK_SUBMITTED",
    title: "新作业提交",
    message: "高三(1)班 李明 提交了《函数与导数练习》",
    read: false,
    createdAt: new Date(now - 5 * minute).toISOString(),
  },
  {
    id: "ntf-002",
    type: "EXAM_GRADED",
    title: "考试已评分",
    message: "高三(2)班《2026 春季期中考试》成绩已发布，平均分 112.5",
    read: false,
    createdAt: new Date(now - 35 * minute).toISOString(),
  },
  {
    id: "ntf-003",
    type: "BROADCAST",
    title: "学校公告",
    message: "本周五下午 14:00 召开教研组会议，请准时参加",
    read: false,
    createdAt: new Date(now - 2 * hour).toISOString(),
  },
  {
    id: "ntf-004",
    type: "HOMEWORK_SUBMITTED",
    title: "新作业提交",
    message: "高三(1)班 王芳 提交了《三角函数复习》",
    read: true,
    createdAt: new Date(now - 5 * hour).toISOString(),
  },
  {
    id: "ntf-005",
    type: "ROLE_CHANGED",
    title: "角色变更",
    message: "您的角色已更新为：年级组长（GRADE 数据范围）",
    read: true,
    createdAt: new Date(now - 1 * day).toISOString(),
  },
  {
    id: "ntf-006",
    type: "EXAM_GRADED",
    title: "考试已评分",
    message: "高三(3)班《月考 - 数学综合》成绩已发布，平均分 98.2",
    read: false,
    createdAt: new Date(now - 1 * day - 3 * hour).toISOString(),
  },
  {
    id: "ntf-007",
    type: "BROADCAST",
    title: "系统通知",
    message: "成绩录入截止日期为本周日 23:59，请及时完成",
    read: true,
    createdAt: new Date(now - 2 * day).toISOString(),
  },
];

/** 按 id 查找 mock 通知 */
export function findNotification(id: string): NotificationItem | null {
  return mockNotifications.find((n) => n.id === id) ?? null;
}
