import { AxiosResponse } from "axios";
import performanceInstance from "@/shared/services/performanceInstance";
import { withHeaders } from "@/record-management/services/api/withHeaders";

export interface ServiceCategory {
  id: string;
  slug: string;
  name: {
    am: string;
    en: string;
  };
  description: {
    am: string;
    en: string;
  };
  organizationId: string;
  createdAt: string;
  updatedAt?: string;
}

export interface CreateServiceCategoryRequest {
  slug: string;
  name: {
    am: string;
    en: string;
  };
  description: {
    am: string;
    en: string;
  };
  organizationId: string;
}

export const serviceCategoryService = {
  create: async (
    data: CreateServiceCategoryRequest
  ): Promise<AxiosResponse> => {
    return performanceInstance.post("/service-categories", data, {
      headers: withHeaders(),
    });
  },

  getList: async (organizationId: string): Promise<AxiosResponse> => {
    return performanceInstance.get(
      `/service-categories/list/${organizationId}`,
      {
        headers: withHeaders(),
      }
    );
  },

  update: async (
    id: string,
    data: CreateServiceCategoryRequest
  ): Promise<AxiosResponse> => {
    return performanceInstance.put(`/service-categories/${id}`, data, {
      headers: withHeaders(),
    });
  },

  delete: async (id: string): Promise<AxiosResponse> => {
    return performanceInstance.delete(`/service-categories/${id}`, {
      headers: withHeaders(),
    });
  },
};
