import { z } from "zod"

/**
 * 校验通知偏好更新表单（8 个布尔字段 + 免打扰时段，来自 checkbox/FormData）
 *
 * V3-P1-3: 从 messaging/schema.ts 迁移至 notifications/schema.ts，
 * 使通知偏好校验逻辑与其消费方（notifications 模块）位于同一模块。
 */
export const UpdateNotificationPreferencesSchema = z.object({
  emailEnabled: z.boolean(),
  smsEnabled: z.boolean(),
  pushEnabled: z.boolean(),
  homeworkNotifications: z.boolean(),
  gradeNotifications: z.boolean(),
  announcementNotifications: z.boolean(),
  messageNotifications: z.boolean(),
  attendanceNotifications: z.boolean(),
  quietHoursEnabled: z.boolean(),
  quietHoursStart: z.string().trim().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "Invalid time format").nullable().optional(),
  quietHoursEnd: z.string().trim().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "Invalid time format").nullable().optional(),
})

export type UpdateNotificationPreferencesFormInput = z.infer<
  typeof UpdateNotificationPreferencesSchema
>
