// signup.listener.ts
import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { guglu } from 'src/constants/email';
import { getConfig } from 'src/utils/siteconfig';
import { SignupEvent } from '../events/signup-event';
// import { MailService } from '../../mail/mail.service';

@Injectable()
export class SignupListener {
  // constructor(private emailsend: MailService) {}
  // @OnEvent('user.created')
  // sendWelcomeEmail(userdetail: SignupEvent) {
  //   const site = userdetail.user?.flag ? userdetail.user?.flag : guglu.sitename;
  //   const config = getConfig(site);
  //   const sendTo = userdetail.user?.email ? userdetail.user?.email : '';
  //   this.emailsend.sendEmail(
  //     config.replyTo,
  //     sendTo,
  //     `Welcome to  ${config.siteName}`,
  //     `${config.template_path}welcome.hbs`,
  //     { name: userdetail.user?.name, url: config.url },
  //     `Hi ${userdetail.user?.name}. Welcome to ${config.siteName}`,
  //   );
  // }
  // @OnEvent('user.created')
  // @OnEvent('user.resendVerifyEmail')
  // sendVerifyEmail(userdetail: SignupEvent) {
  //   const site = userdetail.user?.flag ? userdetail.user?.flag : guglu.sitename;
  //   const config = getConfig(site);
  //   const sendTo = userdetail.user?.email ? userdetail.user?.email : '';
  //   this.emailsend.sendEmail(
  //     config.replyTo,
  //     sendTo,
  //     `Email verification code!`,
  //     `${config.template_path}verify.hbs`,
  //     {
  //       name: userdetail.user?.name,
  //       url: config.url,
  //       code: userdetail.user?.email_verification_code,
  //     },
  //     `Hi ${userdetail.user?.name}. Your verification code is ${userdetail.user?.email_verification_code}`,
  //   );
  // }
  // @OnEvent('user.created')
  // sendAdminEmail(userdetail: SignupEvent) {
  //   const site = userdetail.user?.flag ? userdetail.user?.flag : guglu.sitename;
  //   const config = getConfig(site);
  //   this.emailsend.sendEmail(
  //     config.replyTo,
  //     config.adminEmail,
  //     `New User registered!`,
  //     `${config.template_path}welcomeAdmin.hbs`,
  //     {
  //       name: userdetail.user?.name,
  //       email: userdetail.user?.email,
  //       mobile: userdetail.user?.mobile,
  //       url: config.url,
  //     },
  //     `Name: ${userdetail.user?.name} \nEmail: ${userdetail.user?.email} \nMobile: ${userdetail.user?.mobile} \nSignup Url: ${config.url}`,
  //   );
  // }
}
