import axios from 'axios';
import { Artist, Epoch, Country, Subscription, User } from '../types';

const api = axios.create({
    baseURL: 'http://localhost:3001',
});

export const getArtists = () => api.get<Artist[]>('/artists');
export const createArtist = (artist: Omit<Artist, 'id'>) => api.post<Artist>('/artists', artist);
export const updateArtist = (id: string, artist: Partial<Artist>) => api.put<Artist>(`/artists/${id}`, artist);
export const deleteArtist = (id: string) => api.delete(`/artists/${id}`);

export const getEpochs = () => api.get<Epoch[]>('/epochs');
export const getCountries = () => api.get<Country[]>('/countries');

export const getSubscriptions = () => api.get<Subscription[]>('/subscriptions');
export const createSubscription = (subscription: Omit<Subscription, 'id'>) => api.post<Subscription>('/subscriptions', subscription);
export const updateSubscription = (id: number, subscription: Partial<Subscription>) => api.put<Subscription>(`/subscriptions/${id}`, subscription);
export const deleteSubscription = (id: number) => api.delete(`/subscriptions/${id}`);

export const getUsers = () => api.get<User[]>('/users');