import axios from 'axios'

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

api.interceptors.request.use((config) => {
  const token = localStorage.getItem('token')
  if (token) {
    config.headers.Authorization = `Bearer ${token}`
  }
  return config
})

export const signupUser = (data) => api.post('/api/user/register', data)
export const loginUser = (data) => api.post('/api/user/login', data)
export const addProduct = (data) => api.post('/api/products/insertProduct', data)
export const getAllProducts = () => api.get('/api/products')
export const addWarehouse = (data) => api.post('/api/warehouses/insertWarehouse', data)
export const getAllWarehouses = () => api.get('/api/warehouses')
export const addStock = (data) => api.post('/api/stocktransactions/insertStock', data)
export const getAllStocks = () => api.get('/api/stocktransactions/getStocks')
export const getAllProfiles = () => api.get('/api/user/profiles')
export const getReports = () => api.get('/api/reports/getReport')