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 { STATUS } from 'src/core/strings/constants/base.constants';

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

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

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

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

  get validateRelations(): validateRelations[] {
    return [
      {
        relation: 'tenant',
        singleQuery: ['status', '!=', STATUS.ACTIVE],
        message: `Gagal! tenant tidak aktif`,
      },
      {
        relation: 'bundling_items',
        singleQuery: ['status', '!=', STATUS.ACTIVE],
        message: `Gagal! Terdapat item yang belum aktif`,
      },
    ];
  }

  get entityTarget(): any {
    return ItemModel;
  }

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