import axios from 'axios';
import { LoginCredentials, SignupData, User } from '../types/auth';

const api = axios.create({
  baseURL: '/api',
  headers: { 'Content-Type': 'application/json' }
});

export const authApi = {
  signup: async (data: SignupData): Promise<User> => {
    const response = await api.post('/signup', data);
    return response.data;
  },
  login: async (credentials: LoginCredentials): Promise<User> => {
    const response = await api.post('/login', credentials);
    return response.data;
  },
  getProfile: async (): Promise<User> => {
    const response = await api.get('/profile');
    return response.data;
  },
  updateProfile: async (data: Partial<User>): Promise<User> => {
    const response = await api.put('/profile', data);
    return response.data;
  }
};