import { Controller, Get, Injectable } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Public } from 'src/core/guards';
import * as path from 'path';
import * as fs from 'fs';

@ApiTags(`email templates`)
@Controller('v1/email-templates')
@Public()
@Injectable()
export class MailTemplateController {
  getTemplate(templateName) {
    const templatePath = path.join(
      __dirname,
      '../../../../../',
      `src/modules/configuration/mail/domain/email-template/${templateName}.html`,
    );
    return fs.readFileSync(templatePath, 'utf8');
  }

  @Get('date-change')
  async getDateChange() {
    return this.getTemplate('change-date');
  }

  @Get('invoice')
  async getBookingInvoice() {
    return this.getTemplate('invoice');
  }

  @Get('payment-confirmation-bank')
  async getPaymentConfirmation() {
    return this.getTemplate('payment-confirmation-bank');
  }

  @Get('payment-confirmation-midtrans')
  async getPaymentConfirmationMidtrans() {
    return this.getTemplate('payment-confirmation-midtrans');
  }

  @Get('invoice-expired')
  async getInvoiceExpired() {
    return this.getTemplate('invoice-expired');
  }

  @Get('refund-confirmation')
  async getRefundConfirmation() {
    return this.getTemplate('refund-confirmation');
  }

  @Get('refund-request')
  async getRefundRequest() {
    return this.getTemplate('refund-request');
  }
}
