/**
 * feedback.repository.impl.ts
 * Implementación en memoria del FeedbackRepository.
 */

import type {
  FeedbackItem,
  FeedbackRepository,
} from "../../domain/repositories/feedback.repository.js";

export class InMemoryFeedbackRepository implements FeedbackRepository {
  private readonly items: FeedbackItem[] = [];

  async save(item: FeedbackItem): Promise<void> {
    this.items.unshift(item);
  }

  async listForUser(userId: number): Promise<FeedbackItem[]> {
    return this.items.filter((i) => i.userId === userId);
  }

  async listAll(): Promise<FeedbackItem[]> {
    return [...this.items];
  }
}
