import { EventsHandler, IEventHandler } from '@nestjs/cqrs';

import { LogUserLoginEvent } from '../entities/log-user-login.event';
import { LogUserLoginService } from '../../data/services/log-user-login.service';

@EventsHandler(LogUserLoginEvent)
export class LogUserLoginHandler implements IEventHandler<LogUserLoginEvent> {
  constructor(private service: LogUserLoginService) {}

  async handle(event: LogUserLoginEvent) {
    const data = event.data.data;
    await this.service.saveData(data);
  }
}
