import { BaseService } from '../BaseService'
import type {
  BaseResponse,
  NotificationItem,
  NotificationListResponse,
  NotificationQueryParams,
  NotificationSummary,
  NotificationTarget
} from '@/types/api'

export class NotificationService extends BaseService {
  static getUnreadCount(): Promise<
    BaseResponse<number | { count?: number; unread_count?: number }>
  > {
    return this.get<BaseResponse<number | { count?: number; unread_count?: number }>>(
      '/api/admin/notifications/unread-count'
    )
  }

  static getUnreadSummary(): Promise<BaseResponse<NotificationSummary>> {
    return this.get<BaseResponse<NotificationSummary>>('/api/admin/notifications/unread-summary')
  }

  static getNotifications(
    params?: NotificationQueryParams
  ): Promise<BaseResponse<NotificationListResponse>> {
    return this.get<BaseResponse<NotificationListResponse>>('/api/admin/notifications', params)
  }

  static markRead(id: number | string): Promise<BaseResponse<NotificationItem>> {
    return this.put<BaseResponse<NotificationItem>>(`/api/admin/notifications/${id}/read`, {})
  }

  static markAllRead(): Promise<BaseResponse> {
    return this.put<BaseResponse>('/api/admin/notifications/read-all', {})
  }

  static getTarget(id: number | string): Promise<BaseResponse<NotificationTarget>> {
    return this.get<BaseResponse<NotificationTarget>>(`/api/admin/notifications/${id}/target`)
  }
}
