This commit is contained in:
aditya.siregar 2025-03-16 23:42:42 +07:00
parent 2554533e09
commit 214a80e5f9
3 changed files with 8 additions and 4 deletions

View File

@ -3,7 +3,9 @@ package brevo
import (
"bytes"
"context"
"enaklo-pos-be/internal/common/logger"
"enaklo-pos-be/internal/entity"
"go.uber.org/zap"
"html/template"
"io/ioutil"
"log"
@ -22,7 +24,7 @@ type ServiceImpl struct {
func (s ServiceImpl) SendEmailTransactional(ctx context.Context, param entity.SendEmailNotificationParam) error {
templateFile, err := ioutil.ReadFile(param.TemplatePath)
if err != nil {
log.Println(err)
logger.ContextLogger(ctx).Error("error when reading file template", zap.Error(err))
return err
}
@ -91,9 +93,11 @@ func (s ServiceImpl) sendEmail(ctx context.Context, tmpl *template.Template, par
_, _, err = s.brevoConn.TransactionalEmailsApi.SendTransacEmail(ctx, payload)
if err != nil {
logger.ContextLogger(ctx).Error("error when sending email", zap.Error(err))
return err
}
logger.ContextLogger(ctx).Info("sending email success")
return nil
}

View File

@ -211,7 +211,7 @@ func (s *memberSvc) sendRegistrationOTP(
Recipient: registration.Email,
Subject: "Enaklo - Registration Verification Code",
TemplateName: "member_registration_otp",
TemplatePath: "templates/member_registration_otp.html",
TemplatePath: "/templates/member_registration_otp.html",
Data: emailData,
})
@ -246,7 +246,7 @@ func (s *memberSvc) sendWelcomeEmail(
Recipient: customer.Email,
Subject: "Welcome to Enaklo Membership Program",
TemplateName: "welcome_member",
TemplatePath: "templates/welcome_member.html",
TemplatePath: "/templates/welcome_member.html",
Data: welcomeData,
})
}

View File

@ -155,7 +155,7 @@ func (s *orderSvc) sendTransactionReceipt(ctx mycontext.Context, order *entity.O
Recipient: customer.Email,
Subject: "Hore, kamu dapat poin!",
TemplateName: "monthly_points",
TemplatePath: "templates/monthly_points.html",
TemplatePath: "/templates/monthly_points.html",
Data: emailData,
})
}