import { Injectable } from '@nestjs/common';
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
import { ItemEntity } from '../../entities/item.entity';
import {
  EventTopics,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { ItemModel } from '../../../data/models/item.model';
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
import { validateRelation } from './helpers/validasi-relation.helper';

@Injectable()
export class InactiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
  getResult(): string {
    return `Success inactive data ${this.result.name}`;
  }

  async validateProcess(): Promise<void> {
    await validateRelation(this.dataService, this.dataId);
    return;
  }

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

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

  get validateRelations(): validateRelations[] {
    return [];
  }

  get entityTarget(): any {
    return ItemModel;
  }

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