diff --git a/notification/src/main/java/cz/muni/pa165/service/NotificationService.java b/notification/src/main/java/cz/muni/pa165/service/NotificationService.java index 5ae703c5a051d95bc7b94cb1dfcfc5bd15aa4788..542f03d03dcd5ff878e342173559e33ad8d731b9 100644 --- a/notification/src/main/java/cz/muni/pa165/service/NotificationService.java +++ b/notification/src/main/java/cz/muni/pa165/service/NotificationService.java @@ -38,12 +38,16 @@ public class NotificationService { public ConfirmationDto notifyNewComponent(CarComponentNotificationDto carComponentNotificationDto) { var c = carComponentNotificationDto.getCarComponent(); var subject = "New component: " + c.getInformation(); - var text = "New component was added to Formula team management core.\n" - + "\nType: " + c.getComponentType() - + "\nInformation: " + c.getInformation() - + "\nWeight: " + c.getWeight(); - return sendEmail(subject, text, carComponentNotificationDto.getReceivers()); + Context ctx = new Context(); + ctx.setVariable("id", c.getId()); + ctx.setVariable("type", c.getComponentType()); + ctx.setVariable("info", c.getInformation()); + ctx.setVariable("weight", c.getWeight()); + + var htmlContent = templateEngine.process("new-component-email", ctx); + + return sendEmail(subject, htmlContent, carComponentNotificationDto.getReceivers()); } public ConfirmationDto notifyNewApplication(ApplicationNotificationDto applicationNotificationDto) { diff --git a/notification/src/main/resources/templates/new-component-email.html b/notification/src/main/resources/templates/new-component-email.html new file mode 100644 index 0000000000000000000000000000000000000000..cb066f1567c990e3f5883263a8fecbc0426b8c51 --- /dev/null +++ b/notification/src/main/resources/templates/new-component-email.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org" lang="en"> +<head> + <meta charset="utf-8"> + <title>Application for Formula Driver Position</title> + <style> + body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f6f6f6; + } + + .container { + max-width: 625px; + margin: 0 auto; + background-color: #fff; + padding: 20px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + position: relative; + } + + h1 { + font-size: 24px; + font-weight: bold; + margin: 0; + text-align: left; + } + + p { + font-size: 16px; + line-height: 1.5; + margin: 20px 0; + text-align: justify; + } + </style> +</head> +<body> +<div class="container"> + <h1>New component was added to Formula team management core</h1> + <table> + <tr> + <td>Id:</td> + <td th:text="${id}"></td> + </tr> + <tr> + <td>Component type:</td> + <td th:text="${type}"></td> + </tr> + <tr> + <td>Information:</td> + <td th:text="${info}"></td> + </tr> + <tr> + <td>Weight:</td> + <td th:text="${weight} + 'kg'"></td> + </tr> + </table> +</div> +</body> +</html> \ No newline at end of file