import api from './api';
import type { Track } from '../types';

export const favoritesService = {
  // GET /api/favorites -> Track[]
  async list(): Promise<Track[]> {
    const res = await api.get<Track[]>('/favorites');
    return res.data;
  },

  // POST /api/favorites/:trackId -> { status: 'added' }
  async add(trackId: string): Promise<{ status: string }> {
    const res = await api.post<{ status: string }>(`/favorites/${trackId}`);
    return res.data;
  },

  // DELETE /api/favorites/:trackId -> { status: 'removed' }
  async remove(trackId: string): Promise<{ status: string }> {
    const res = await api.delete<{ status: string }>(`/favorites/${trackId}`);
    return res.data;
  },

  // POST /api/tracks/:trackId/dislike -> { status: 'disliked' }
  async dislike(trackId: string): Promise<{ status: string }> {
    const res = await api.post<{ status: string }>(`/tracks/${trackId}/dislike`);
    return res.data;
  },
};
