import { z } from "zod";

/**
 * 通知偏好更新输入 Zod 校验（对齐 02-architecture-design.md §4.3）。
 *
 * - channels：通知渠道数组（APP/SMS/EMAIL/WECHAT），至少 1 个
 * - eventTypes：5 个布尔开关，可选更新（未传保留原值）
 */
export const NotificationChannelSchema = z.enum([
  "APP",
  "SMS",
  "EMAIL",
  "WECHAT",
]);

export const NotificationEventTypesInputSchema = z.object({
  gradeReleased: z.boolean().optional(),
  homeworkGraded: z.boolean().optional(),
  examPublished: z.boolean().optional(),
  attendanceAlert: z.boolean().optional(),
  schoolAnnouncement: z.boolean().optional(),
});

export const UpdateNotificationPreferencesSchema = z.object({
  channels: z.array(NotificationChannelSchema).min(1, "至少选择一个通知渠道"),
  eventTypes: NotificationEventTypesInputSchema,
});

export type UpdateNotificationPreferencesInput = z.infer<
  typeof UpdateNotificationPreferencesSchema
>;
