import type { PaginatedResponse } from '../types/client';
import type { Notification, FindNotificationsParams } from '../types/notification';
import { api } from './api';

export const notificationsService = {
  async getNotifications(params?: FindNotificationsParams): Promise<PaginatedResponse<Notification>> {
    return api.get<PaginatedResponse<Notification>>('/notifications', {
      params: {
        cursor: params?.cursor,
        limit: params?.limit,
        isRead: params?.isRead,
      },
    });
  },

  async getUnreadCount(): Promise<{ count: number }> {
    return api.get<{ count: number }>('/notifications/unread-count');
  },

  async markAsRead(id: string): Promise<void> {
    await api.patch(`/notifications/${id}/read`);
  },

  async markAllAsRead(): Promise<void> {
    await api.patch('/notifications/read-all');
  },
};
