import { Injectable } from '@nestjs/common';
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
import { ItemCategoryEntity } from '../../entities/item-category.entity';
import {
  EventTopics,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { ItemCategoryModel } from '../../../data/models/item-category.model';
import { ItemCategoryDeletedEvent } from '../../entities/event/item-category-deleted.event';

@Injectable()
export class DeleteItemCategoryManager extends BaseDeleteManager<ItemCategoryEntity> {
  getResult(): string {
    return `Success`;
  }

  async validateProcess(): Promise<void> {
    return;
  }

  async beforeProcess(): Promise<void> {
    return;
  }

  async afterProcess(): Promise<void> {
    return;
  }

  get validateRelations(): validateRelations[] {
    return [
      {
        relation: 'items',
        message:
          'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
      },
    ];
  }

  get entityTarget(): any {
    return ItemCategoryModel;
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: ItemCategoryDeletedEvent,
        data: this.data,
      },
    ];
  }
}
