"use client"

import {
  createAnnouncementAction,
  updateAnnouncementAction,
  deleteAnnouncementAction,
  publishAnnouncementAction,
  archiveAnnouncementAction,
  toggleAnnouncementPinAction,
  markAnnouncementAsReadAction,
  getAnnouncementReadStatusAction,
} from "../actions"
import type { AnnouncementsService } from "../types"

/**
 * P1-3: 公告服务的默认实现。
 *
 * 直接代理到真实 Server Actions。
 * 测试或角色定制时可在 Provider 中注入其他实现以覆盖此默认行为。
 */
export const defaultAnnouncementsService: AnnouncementsService = {
  create: (prevState, formData) => createAnnouncementAction(prevState, formData),
  update: (id, prevState, formData) => updateAnnouncementAction(id, prevState, formData),
  delete: (id) => deleteAnnouncementAction(id),
  publish: (id) => publishAnnouncementAction(id),
  archive: (id) => archiveAnnouncementAction(id),
  togglePin: (id) => toggleAnnouncementPinAction(id),
  markRead: (announcementId) => markAnnouncementAsReadAction(announcementId),
  getReadStatus: (announcementIds) => getAnnouncementReadStatusAction(announcementIds),
}
