Skip to content

Commit

Permalink
VKT(Backend&Frontend): Contact request partial exam selection as free…
Browse files Browse the repository at this point in the history
… form text [deploy]
  • Loading branch information
pkoivisto committed Nov 22, 2024
1 parent e3438e7 commit 2cd1410
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,17 @@

@Builder
public record PublicEnrollmentContactCreateDTO(
@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 Boolean isFullExam,
@Size(max = 1024) String partialExamSelection,
@Size(max = 1024) String previousEnrollment,
@Size(max = 10240) String message,
@Size(max = 255) @NonNull @NotBlank String phoneNumber,
@Size(max = 255) @NonNull @NotBlank String email,
@Size(max = 255) @NonNull @NotBlank String firstName,
@Size(max = 255) @NonNull @NotBlank String lastName
)
implements EnrollmentDTOSkillFields {
) {
public PublicEnrollmentContactCreateDTO {
partialExamSelection = StringUtil.sanitize(partialExamSelection);
previousEnrollment = StringUtil.sanitize(previousEnrollment);
message = StringUtil.sanitize(message);
phoneNumber = StringUtil.sanitize(phoneNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ public record ClerkEnrollmentContactRequestDTO(
@NonNull @NotNull Long id,
@NonNull @NotNull Integer version,
@NonNull @NotNull LocalDateTime enrollmentTime,
@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,
Boolean isFullExam,
String partialExamSelection,
@NonNull @NotNull EnrollmentAppointmentStatus status,
String previousEnrollment,
@NonNull @NotBlank String phoneNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class EnrollmentAppointment extends EnrollmentCommon {
@Column(name = "last_name")
private String lastName;

@Column(name = "partial_exam_selection")
private String partialExamSelection;

@Column(name = "previous_enrollment")
private String previousEnrollment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void copyDtoFieldsToEnrollment(
final EnrollmentAppointment enrollment,
final PublicEnrollmentContactCreateDTO dto
) {
copyDtoSkillFieldsToEnrollment(enrollment, dto);
enrollment.setPartialExamSelection(dto.partialExamSelection());
enrollment.setPreviousEnrollment(dto.previousEnrollment());
enrollment.setMessage(dto.message());
enrollment.setPhoneNumber(dto.phoneNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,8 @@ public static ClerkEnrollmentContactRequestDTO createClerkEnrollmentContactDTO(
.id(enrollmentAppointment.getId())
.version(enrollmentAppointment.getVersion())
.enrollmentTime(enrollmentAppointment.getCreatedAt())
.oralSkill(enrollmentAppointment.isOralSkill())
.textualSkill(enrollmentAppointment.isTextualSkill())
.understandingSkill(enrollmentAppointment.isUnderstandingSkill())
.speakingPartialExam(enrollmentAppointment.isSpeakingPartialExam())
.speechComprehensionPartialExam(enrollmentAppointment.isSpeechComprehensionPartialExam())
.writingPartialExam(enrollmentAppointment.isWritingPartialExam())
.readingComprehensionPartialExam(enrollmentAppointment.isReadingComprehensionPartialExam())
.isFullExam(enrollmentAppointment.getPartialExamSelection() == null)
.partialExamSelection(enrollmentAppointment.getPartialExamSelection())
.status(enrollmentAppointment.getStatus())
.phoneNumber(enrollmentAppointment.getPhoneNumber())
.email(enrollmentAppointment.getEmail())
Expand Down
12 changes: 12 additions & 0 deletions backend/vkt/src/main/resources/db/changelog/db.changelog-1.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1165,4 +1165,16 @@
<column name="name" value="ENROLLMENT_APPOINTMENT_CONFIRMATION"/>
</insert>
</changeSet>
<changeSet id="2024-11-22-enrollment-contact-partial-exam-selection-changes" author="pkoivisto">
<addColumn tableName="enrollment_appointment">
<column name="partial_exam_selection" type="text" />
</addColumn>
<dropNotNullConstraint tableName="enrollment_appointment" columnName="skill_oral" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="skill_textual" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="skill_understanding" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="partial_exam_speaking" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="partial_exam_speech_comprehension" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="partial_exam_writing" />
<dropNotNullConstraint tableName="enrollment_appointment" columnName="partial_exam_reading_comprehension" />
</changeSet>
</databaseChangeLog>
2 changes: 1 addition & 1 deletion frontend/packages/vkt/public/i18n/fi-FI/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
},
"selectExams": {
"description": "Osakokeita ovat: Puhuminen, puheen ymmärtäminen, kirjoittaminen ja tekstin ymmärtäminen",
"heading": "Kerro, minkä osakokeen / mitkä osakokeet haluat suorittaa"
"heading": "Kerro, minkä osakokeen / mitkä osakokeet haluat suorittaa *"
},
"part1": "Voit suorittaa suullisen ja kirjallisen taidon tutkinnot joko samalla kertaa tai osissa eri suorituskertojen aikana.",
"part2": "Kun olet suorittanut hyväksytysti suullisen ja kirjallisen taidon tutkinnot, saat todistukseen merkinnän myös ymmärtämisen taidon tutkinnon suorittamisesta.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { Color } from 'shared/enums';
import { useCommonTranslation, usePublicTranslation } from 'configs/i18n';
import { useAppDispatch } from 'configs/redux';
import { PartialExamsAndSkills } from 'interfaces/common/enrollment';
import { PublicEnrollmentCommon } from 'interfaces/publicEnrollment';
import {
PublicEnrollment,
PublicEnrollmentAppointment,
} from 'interfaces/publicEnrollment';
import { EnrollmentUtils } from 'utils/enrollment';

enum YesNo {
Expand All @@ -32,7 +35,7 @@ const CheckboxField = ({
error,
describedBy,
}: {
enrollment: PublicEnrollmentCommon;
enrollment: PublicEnrollment | PublicEnrollmentAppointment;
fieldName: keyof PartialExamsAndSkills;
onClick: (fieldName: keyof PartialExamsAndSkills) => void;
disabled: boolean;
Expand Down Expand Up @@ -66,12 +69,12 @@ export const PartialExamsSelection = ({
showValidation,
updatePublicEnrollment,
}: {
enrollment: PublicEnrollmentCommon;
enrollment: PublicEnrollment | PublicEnrollmentAppointment;
editingDisabled: boolean;
setValid: (isValid: boolean) => void;
showValidation: boolean;
updatePublicEnrollment: (
enrollment: Partial<PublicEnrollmentCommon>,
enrollment: Partial<PublicEnrollment | PublicEnrollmentAppointment>,
) => AnyAction;
}) => {
const translateCommon = useCommonTranslation();
Expand All @@ -82,7 +85,7 @@ export const PartialExamsSelection = ({
const dispatch = useAppDispatch();
const [dirtyFullExam, setDirtyFullExam] = useState(!!enrollment.id);

const isSkillsSelected = enrollment.textualSkill || enrollment.oralSkill;
const isSkillsSelected = !!(enrollment.textualSkill || enrollment.oralSkill);

useEffect(() => {
setValid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FillContactDetails } from 'components/publicEnrollmentContact/steps/Fil
import { SelectExam } from 'components/publicEnrollmentContact/steps/SelectExam';
import { PublicEnrollmentContactFormStep } from 'enums/publicEnrollment';
import { PublicEnrollmentContact } from 'interfaces/publicEnrollment';
import { updatePublicEnrollment } from 'redux/reducers/publicEnrollmentContact';
import { updatePublicEnrollmentContact } from 'redux/reducers/publicEnrollmentContact';

export const PublicEnrollmentContactStepContents = ({
activeStep,
Expand All @@ -24,7 +24,7 @@ export const PublicEnrollmentContactStepContents = ({
isLoading={false}
setIsStepValid={setIsStepValid}
showValidation={showValidation}
updatePublicEnrollment={updatePublicEnrollment}
updatePublicEnrollment={updatePublicEnrollmentContact}
/>
);
case PublicEnrollmentContactFormStep.SelectExam:
Expand All @@ -34,7 +34,7 @@ export const PublicEnrollmentContactStepContents = ({
isLoading={false}
setIsStepValid={setIsStepValid}
showValidation={showValidation}
updatePublicEnrollment={updatePublicEnrollment}
updatePublicEnrollment={updatePublicEnrollmentContact}
/>
);
case PublicEnrollmentContactFormStep.Done:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,26 @@ export const SelectExam = ({
useState(false);
const [isValidPartialExamsSelection, setIsValidPartialExamsSelection] =
useState(false);
const [isValidMessage, setIsValidMessage] = useState(false);

const setPreviousEnrollment = (isValid: boolean) =>
setIsValidPreviousEnrollment(isValid);
const setPartialExamsSelection = (isValid: boolean) =>
setIsValidPartialExamsSelection(isValid);
const setMessage = (isValid: boolean) => setIsValidMessage(isValid);

useEffect(() => {
setIsStepValid(isValidPreviousEnrollment && isValidPartialExamsSelection);
}, [setIsStepValid, isValidPreviousEnrollment, isValidPartialExamsSelection]);
setIsStepValid(
isValidPreviousEnrollment &&
isValidPartialExamsSelection &&
isValidMessage,
);
}, [
setIsStepValid,
isValidPreviousEnrollment,
isValidPartialExamsSelection,
isValidMessage,
]);

return (
<div className="rows gapped">
Expand All @@ -60,7 +71,7 @@ export const SelectExam = ({
<Message
enrollment={enrollment}
editingDisabled={isLoading}
setValid={setPreviousEnrollment}
setValid={setMessage}
showValidation={showValidation}
updatePublicEnrollment={updatePublicEnrollment}
/>
Expand Down
Loading

0 comments on commit 2cd1410

Please sign in to comment.