import apiClient from './client';

interface Product {
  id: string;
  name: string;
  price: number;
  stock: number;
  category: string;
  status: 'active' | 'inactive';
}

interface ProductListResponse {
  data: Product[];
  total: number;
  page: number;
  pageSize: number;
}

export const productApi = {
  getList: async (params: {
    page?: number;
    pageSize?: number;
    category?: string;
    status?: string;
  }): Promise<ProductListResponse> => {
    return apiClient.get('/products', { params });
  },
  getDetail: async (id: string): Promise<Product> => {
    return apiClient.get(`/products/${id}`);
  },
  create: async (data: Omit<Product, 'id'>): Promise<Product> => {
    return apiClient.post('/products', data);
  },
  update: async (id: string, data: Partial<Product>): Promise<Product> => {
    return apiClient.put(`/products/${id}`, data);
  },
  delete: async (id: string): Promise<void> => {
    return apiClient.delete(`/products/${id}`);
  },
};

export default productApi;