Skip to content

Commit

Permalink
VKT(Frontend & Backend): enrollment appointment continues
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Oct 1, 2024
1 parent 4bb8098 commit b36b02f
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 36 deletions.
11 changes: 11 additions & 0 deletions backend/vkt/db/4_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,14 @@ SELECT exam_event_id, (SELECT max(person_id) FROM person),
'CANCELED', true,
'[email protected]', '0404040404', null, null, null, null
FROM exam_event;

-- Insert enrollment appointment
INSERT INTO enrollment_appointment(person_id,
skill_oral, skill_textual, skill_understanding,
partial_exam_speaking, partial_exam_speech_comprehension, partial_exam_writing, partial_exam_reading_comprehension,
status, digital_certificate_consent, email, phone_number, street, postal_code, town, country)
VALUES (SELECT max(person_id) FROM person),
true, true, true,
true, true, true, true,
'COMPLETED', true,
'[email protected]', '0404040404', null, null, null, null;
11 changes: 11 additions & 0 deletions backend/vkt/src/main/java/fi/oph/vkt/api/PublicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import fi.oph.vkt.api.dto.PublicEducationDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentAppointmentDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentCreateDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentInitialisationDTO;
Expand Down Expand Up @@ -149,6 +150,16 @@ public PublicExamEventDTO getExamEventInfo(@PathVariable final long examEventId)
return publicExamEventService.getExamEvent(examEventId);
}

@GetMapping(path = "/enrollment/appointment/{enrollmentAppointmentId:\\d+}")
public PublicEnrollmentAppointmentDTO getEnrollmentAppointment(
@PathVariable final long enrollmentAppointmentId,
final HttpSession session
) {
final Person person = publicAuthService.getPersonFromSession(session);

return publicEnrollmentService.getEnrollmentAppointment(enrollmentAppointmentId, person);
}

@GetMapping(path = "/education")
public List<PublicEducationDTO> getEducation(final HttpSession session) throws JsonProcessingException {
final Person person = publicAuthService.getPersonFromSession(session);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fi.oph.vkt.api.dto;

import fi.oph.vkt.model.type.EnrollmentStatus;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.NonNull;

@Builder
public record PublicEnrollmentAppointmentDTO(
@NonNull @NotNull Long id,
@NonNull @NotNull Boolean oralSkill,
@NonNull @NotNull Boolean textualSkill,
@NonNull @NotNull Boolean understandingSkill,
@NonNull @NotNull Boolean speakingPartialExam,
@NonNull @NotNull Boolean speechComprehensionPartialExam,
@NonNull @NotNull Boolean writingPartialExam,
@NonNull @NotNull Boolean readingComprehensionPartialExam,
@NonNull @NotNull EnrollmentStatus status,
String previousEnrollment,
@NonNull @NotNull Boolean digitalCertificateConsent,
@NonNull @NotBlank String email,
@NonNull @NotBlank String phoneNumber,
String street,
String postalCode,
String town,
String country
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@Getter
@Setter
@Entity
@Table(name = "enrollment")
@Table(name = "enrollment_appointment")
public class EnrollmentAppointment extends BaseEntity {

@Id
Expand Down Expand Up @@ -53,6 +53,10 @@ public class EnrollmentAppointment extends BaseEntity {
@Column(name = "partial_exam_reading_comprehension")
private boolean readingComprehensionPartialExam;

@Column(name = "status", nullable = false)
@Enumerated(value = EnumType.STRING)
private EnrollmentStatus status;

@Column(name = "digital_certificate_consent")
private boolean digitalCertificateConsent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fi.oph.vkt.api.dto.FreeEnrollmentDetails;
import fi.oph.vkt.api.dto.FreeEnrollmentDetailsDTO;
import fi.oph.vkt.api.dto.PublicEducationDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentAppointmentDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentCreateDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentDTO;
import fi.oph.vkt.api.dto.PublicEnrollmentInitialisationDTO;
Expand All @@ -12,6 +13,7 @@
import fi.oph.vkt.api.dto.PublicPersonDTO;
import fi.oph.vkt.api.dto.PublicReservationDTO;
import fi.oph.vkt.model.Enrollment;
import fi.oph.vkt.model.EnrollmentAppointment;
import fi.oph.vkt.model.ExamEvent;
import fi.oph.vkt.model.FeatureFlag;
import fi.oph.vkt.model.FreeEnrollment;
Expand All @@ -21,6 +23,7 @@
import fi.oph.vkt.model.type.EnrollmentStatus;
import fi.oph.vkt.model.type.FreeEnrollmentSource;
import fi.oph.vkt.model.type.FreeEnrollmentType;
import fi.oph.vkt.repository.EnrollmentAppointmentRepository;
import fi.oph.vkt.repository.EnrollmentRepository;
import fi.oph.vkt.repository.ExamEventRepository;
import fi.oph.vkt.repository.FreeEnrollmentRepository;
Expand All @@ -34,7 +37,6 @@
import fi.oph.vkt.util.exception.APIException;
import fi.oph.vkt.util.exception.APIExceptionType;
import fi.oph.vkt.util.exception.NotFoundException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
Expand All @@ -50,6 +52,7 @@
public class PublicEnrollmentService extends AbstractEnrollmentService {

private final EnrollmentRepository enrollmentRepository;
private final EnrollmentAppointmentRepository enrollmentAppointmentRepository;
private final ExamEventRepository examEventRepository;
private final PublicEnrollmentEmailService publicEnrollmentEmailService;
private final PublicReservationService publicReservationService;
Expand Down Expand Up @@ -583,4 +586,44 @@ public Map<String, String> getPresignedPostRequest(

return s3Service.getPresignedPostRequest(key, extension);
}

private PublicEnrollmentAppointmentDTO createEnrollmentAppointmentDTO(
final EnrollmentAppointment enrollmentAppointment
) {
return PublicEnrollmentAppointmentDTO
.builder()
.id(enrollmentAppointment.getId())
.oralSkill(enrollmentAppointment.isOralSkill())
.textualSkill(enrollmentAppointment.isTextualSkill())
.understandingSkill(enrollmentAppointment.isUnderstandingSkill())
.speakingPartialExam(enrollmentAppointment.isSpeakingPartialExam())
.speechComprehensionPartialExam(enrollmentAppointment.isSpeechComprehensionPartialExam())
.writingPartialExam(enrollmentAppointment.isWritingPartialExam())
.readingComprehensionPartialExam(enrollmentAppointment.isReadingComprehensionPartialExam())
.digitalCertificateConsent(enrollmentAppointment.isDigitalCertificateConsent())
.email(enrollmentAppointment.getEmail())
.phoneNumber(enrollmentAppointment.getPhoneNumber())
.street(enrollmentAppointment.getStreet())
.postalCode(enrollmentAppointment.getPostalCode())
.town(enrollmentAppointment.getTown())
.country(enrollmentAppointment.getCountry())
.status(enrollmentAppointment.getStatus())
.build();
}

@Transactional(readOnly = true)
public PublicEnrollmentAppointmentDTO getEnrollmentAppointment(
final long enrollmentAppointmentId,
final Person person
) {
final EnrollmentAppointment enrollmentAppointment = enrollmentAppointmentRepository.getReferenceById(
enrollmentAppointmentId
);

if (person.getId() != enrollmentAppointment.getPerson().getId()) {
throw new APIException(APIExceptionType.RESERVATION_PERSON_SESSION_MISMATCH);
}

return createEnrollmentAppointmentDTO(enrollmentAppointment);
}
}
2 changes: 1 addition & 1 deletion backend/vkt/src/main/java/fi/oph/vkt/util/UIRouteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ private String getPublicBaseUrl() {
}

public String getEnrollmentAppointmentUrl(final long enrollmentAppointmentId) {
return String.format("%s/ota-yhteytta/%s/tunnistaudu", getPublicBaseUrl(), enrollmentAppointmentId);
return String.format("%s/markkinapaikka/%s/tiedot", getPublicBaseUrl(), enrollmentAppointmentId);
}
}
33 changes: 32 additions & 1 deletion backend/vkt/src/main/resources/db/changelog/db.changelog-1.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,9 @@
<column autoIncrement="true" name="enrollment_appointment_id" type="BIGSERIAL">
<constraints primaryKey="true" primaryKeyName="enrollment_appointment_pkey" />
</column>
<column name="version" type="INT" defaultValueNumeric="0">
<constraints nullable="false"/>
</column>
<column name="created_by" type="TEXT"/>
<column name="modified_by" type="TEXT"/>
<column name="deleted_by" type="TEXT"/>
Expand All @@ -874,9 +877,37 @@
<constraints nullable="false"/>
</column>
<column name="deleted_at" type="TIMESTAMP WITH TIME ZONE"/>
<column name="skill_oral" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="skill_textual" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="skill_understanding" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="partial_exam_speaking" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="partial_exam_speech_comprehension" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="partial_exam_writing" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="partial_exam_reading_comprehension" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="status" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="previous_enrollment_date" type="DATE"/>
<column name="digital_certificate_consent" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="auth_hash" type="TEXT" />
<column name="email" type="TEXT" />
<column name="phone" type="TEXT" />
<column name="phone_number" type="TEXT" />
<column name="street" type="TEXT"/>
<column name="postal_code" type="TEXT"/>
<column name="town" type="TEXT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ import { useDialog } from 'shared/hooks';

import { useCommonTranslation, usePublicTranslation } from 'configs/i18n';
import { useAppDispatch } from 'configs/redux';
import { PublicEnrollmentFormStep } from 'enums/publicEnrollment';
import { PublicEnrollmentAppointmentFormStep } from 'enums/publicEnrollment';
import { RouteUtils } from 'utils/routes';

export const PublicEnrollmentAppointmentControlButtons = ({
activeStep,
enrollment,
isStepValid,
setShowValidation,
}: {
activeStep: PublicEnrollmentFormStep;
activeStep: PublicEnrollmentAppointmentFormStep;
enrollment: PublicEnrollmentAppointment;
isStepValid: boolean;
setShowValidation: (showValidation: boolean) => void;
}) => {
const { t } = usePublicTranslation({
keyPrefix: 'vkt.component.publicEnrollment.controlButtons',
Expand Down Expand Up @@ -54,15 +58,15 @@ export const PublicEnrollmentAppointmentControlButtons = ({
}, [submitStatus, enrollment.id, dispatch]);

const handleBackBtnClick = () => {
const nextStep: PublicEnrollmentFormStep = activeStep - 1;
navigate(RouteUtils.stepToRoute(nextStep, examEventId));
const nextStep: PublicEnrollmentAppointmentFormStep = activeStep - 1;
navigate(RouteUtils.appointmentStepToRoute(nextStep, enrollment.id));
};

const handleNextBtnClick = () => {
if (isStepValid) {
setShowValidation(false);
const nextStep: PublicEnrollmentFormStep = activeStep + 1;
navigate(RouteUtils.stepToRoute(nextStep, examEventId));
const nextStep: PublicEnrollmentAppointmentFormStep = activeStep + 1;
navigate(RouteUtils.appointmentStepToRoute(nextStep, enrollment.id));
} else {
setShowValidation(true);
}
Expand Down Expand Up @@ -105,7 +109,7 @@ export const PublicEnrollmentAppointmentControlButtons = ({
data-testid="public-enrollment__controlButtons__back"
startIcon={<ArrowBackIcon />}
disabled={
activeStep == PublicEnrollmentFormStep.FillContactDetails ||
activeStep == PublicEnrollmentAppointmentFormStep.FillContactDetails ||
isPaymentLoading
}
>
Expand All @@ -129,7 +133,7 @@ export const PublicEnrollmentAppointmentControlButtons = ({
const SubmitButton = () => (
<LoadingProgressIndicator
translateCommon={translateCommon}
isLoading={isEnrollmentSubmitLoading || isPaymentLoading}
isLoading={false}
>
<CustomButton
variant={Variant.Contained}
Expand All @@ -144,14 +148,8 @@ export const PublicEnrollmentAppointmentControlButtons = ({
);

const renderBack = true;

const renderNext = [
PublicEnrollmentFormStep.FillContactDetails,
PublicEnrollmentFormStep.EducationDetails,
PublicEnrollmentFormStep.SelectExam,
].includes(activeStep);

const renderSubmit = activeStep === PublicEnrollmentFormStep.Preview;
const renderNext = activeStep === PublicEnrollmentAppointmentFormStep.FillContactDetails;
const renderSubmit = activeStep === PublicEnrollmentAppointmentFormStep.Preview;

return (
<div className="columns flex-end gapped margin-top-lg">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ import { PublicEnrollmentAppointment } from 'interfaces/publicEnrollment';
export const PublicEnrollmentAppointmentDesktopGrid = ({
activeStep,
enrollment,
isStepValid,
showValidation,
setIsStepValid,
setShowValidation,
}: {
activeStep: PublicEnrollmentFormStep;
isStepValid: boolean;
enrollment: PublicEnrollmentAppointment;
showValidation: boolean;
setIsStepValid: (isValid: boolean) => void;
setShowValidation: (showValidation: boolean) => void;
}) => {
const translateCommon = useCommonTranslation();

Expand All @@ -34,6 +42,8 @@ export const PublicEnrollmentAppointmentDesktopGrid = ({
<PublicEnrollmentAppointmentStepContents
activeStep={activeStep}
enrollment={enrollment}
showValidation={showValidation}
setIsStepValid={setIsStepValid}
/>
{activeStep > PublicEnrollmentFormStep.Authenticate && (
<PublicEnrollmentAppointmentPaymentSum />
Expand All @@ -42,6 +52,9 @@ export const PublicEnrollmentAppointmentDesktopGrid = ({
<PublicEnrollmentAppointmentControlButtons
activeStep={activeStep}
enrollment={enrollment}
setShowValidation={setShowValidation}
isStepValid={isStepValid}
enrollment={enrollment}

Check failure on line 57 in frontend/packages/vkt/src/components/publicEnrollmentAppointment/PublicEnrollmentAppointmentDesktopGrid.tsx

View workflow job for this annotation

GitHub Actions / frontend / common-frontend (20.9.0)

No duplicate props allowed
/>
)}
</div>
Expand Down
Loading

0 comments on commit b36b02f

Please sign in to comment.