/**
 * @copyright 2026 NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import type { ActivityFeedResponse } from '@library/shared-types';
import { ApiService } from './api.service';

@Injectable({
  providedIn: 'root'
})
export class ActivityService {
  private apiService = inject(ApiService);

  /**
   * Get activity feed with pagination.
   */
  getActivityFeed(limit = 50, offset = 0, userId?: string): Observable<ActivityFeedResponse> {
    const params = new URLSearchParams();
    params.append('limit', limit.toString());
    params.append('offset', offset.toString());
    if (userId) {
      params.append('userId', userId);
    }

    return this.apiService.get<ActivityFeedResponse>(`/activity?${params.toString()}`);
  }

  /**
   * Get activity feed for a specific user.
   */
  getUserActivityFeed(userId: string, limit = 50, offset = 0): Observable<ActivityFeedResponse> {
    const params = new URLSearchParams();
    params.append('limit', limit.toString());
    params.append('offset', offset.toString());

    return this.apiService.get<ActivityFeedResponse>(`/activity/${userId}?${params.toString()}`);
  }
}
