import { CategoryDatasourceInf } from "../datasource/category_datasource";
import {
  Category,
  CategoryFormValues,
} from "../datasource/api/entities/category";
import { CategoryRepositoryInf } from "../../domain/repository/category_repository";

/**
 * Implementation of the CategoryRepository interface for production.
 */
export class CategoryRepositoryProd implements CategoryRepositoryInf {
  constructor(private datasource: CategoryDatasourceInf) {}

  /**
   * Registers a new category.
   * @param form - The category data to register.
   * @returns A promise that resolves when the category is registered.
   */
  async registerCategory(form: CategoryFormValues): Promise<void> {
    return this.datasource.registerCategory(form);
  }

  /**
   * Retrieves all categories.
   * @returns A promise that resolves to an array of Category objects.
   */
  async getCategories(): Promise<Category[]> {
    return this.datasource.getCategories();
  }

  /**
   * Deletes an existing category.
   * @param category - The category to delete.
   * @returns A promise that resolves when the category is deleted.
   */
  async deleteCategory(category: Category): Promise<void> {
    return this.datasource.deleteCategory(category);
  }
}
