fix assessment link
This commit is contained in:
parent
d93fc9b139
commit
162b0e7744
@ -6,12 +6,10 @@ import jakarta.persistence.EntityManager;
|
|||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.checkerframework.checker.units.qual.A;
|
|
||||||
import org.springframework.mail.SimpleMailMessage;
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.swing.text.html.Option;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -39,6 +37,7 @@ public class AssessmentService {
|
|||||||
final String evaluationLink = String.format("https://careers.primefactorsolutions.com/evaluation/%s", assessment.getId());
|
final String evaluationLink = String.format("https://careers.primefactorsolutions.com/evaluation/%s", assessment.getId());
|
||||||
final SimpleMailMessage message = new SimpleMailMessage();
|
final SimpleMailMessage message = new SimpleMailMessage();
|
||||||
message.setFrom("no-reply@primefactorsolutions.com");
|
message.setFrom("no-reply@primefactorsolutions.com");
|
||||||
|
message.setBcc("no-reply@primefactorsolutions.com");
|
||||||
message.setTo(assessment.getAppUser().getEmail());
|
message.setTo(assessment.getAppUser().getEmail());
|
||||||
message.setSubject("PFS - Evaluacion Tecnica");
|
message.setSubject("PFS - Evaluacion Tecnica");
|
||||||
message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del proceso de seleccion, usted debe completar "
|
message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del proceso de seleccion, usted debe completar "
|
||||||
@ -48,8 +47,9 @@ public class AssessmentService {
|
|||||||
+ "Exito!"));
|
+ "Exito!"));
|
||||||
|
|
||||||
emailSender.send(message);
|
emailSender.send(message);
|
||||||
|
log.info("Sent email to {}", assessment.getAppUser().getEmail());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error sending email", e);
|
log.error("Error sending email to {}", assessment.getAppUser().getEmail(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package com.primefactorsolutions.views;
|
|||||||
import com.primefactorsolutions.model.Assessment;
|
import com.primefactorsolutions.model.Assessment;
|
||||||
import com.primefactorsolutions.service.AssessmentService;
|
import com.primefactorsolutions.service.AssessmentService;
|
||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
|
import com.vaadin.flow.component.ComponentEventListener;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
import com.vaadin.flow.data.provider.DataProvider;
|
import com.vaadin.flow.data.provider.DataProvider;
|
||||||
@ -31,15 +33,27 @@ public class AssessmentsListView extends Main {
|
|||||||
public AssessmentsListView(final AssessmentService assessmentService) {
|
public AssessmentsListView(final AssessmentService assessmentService) {
|
||||||
final VGrid<Assessment> grid = new VGrid<>(Assessment.class);
|
final VGrid<Assessment> grid = new VGrid<>(Assessment.class);
|
||||||
grid.setColumns("id", "appUser.email");
|
grid.setColumns("id", "appUser.email");
|
||||||
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> new Button("Copy", event ->
|
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> new Button("Copy Link", event ->
|
||||||
ClientsideClipboard.writeToClipboard(String.format("https://localhost:8080/evaluation/%s", assessment.getId()))
|
ClientsideClipboard.writeToClipboard(
|
||||||
|
String.format("email: %s link: https://careers.primefactorsolutions.com/evaluation/%s",
|
||||||
|
assessment.getAppUser().getEmail(),
|
||||||
|
assessment.getId()))
|
||||||
));
|
));
|
||||||
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> new Button("Send", event -> {
|
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> new Button("Send Email", event -> {
|
||||||
|
ConfirmDialog dialog = new ConfirmDialog();
|
||||||
|
dialog.setHeader("Send Link Email");
|
||||||
|
dialog.setText(String.format("Enviar link por email al candidato %s?", assessment.getAppUser().getEmail()));
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
dialog.setConfirmText("Enviar");
|
||||||
|
dialog.setConfirmButtonTheme("primary");
|
||||||
|
dialog.addConfirmListener((ComponentEventListener<ConfirmDialog.ConfirmEvent>) confirmEvent -> {
|
||||||
try {
|
try {
|
||||||
assessmentService.sendEmail(assessment);
|
assessmentService.sendEmail(assessment);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Notification.show("Error sending email: " + e.getMessage(), 10_000, Notification.Position.TOP_CENTER);
|
Notification.show("Error sending email: " + e.getMessage(), 10_000, Notification.Position.TOP_CENTER);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
dialog.open();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
grid.setDataProvider(new DataProvider<>() {
|
grid.setDataProvider(new DataProvider<>() {
|
||||||
|
Loading…
Reference in New Issue
Block a user