Skip to content

Commit

Permalink
VKT(Frontend & Backend): Check that exams are selected before sending…
Browse files Browse the repository at this point in the history
… auth link

Also reset react state on unmount on examiner home page
  • Loading branch information
jrkkp committed Dec 20, 2024
1 parent ef3fb82 commit f49d7af
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
6 changes: 3 additions & 3 deletions backend/vkt/db/4_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ INSERT INTO enrollment_appointment(person_id, examiner_id,
first_name, last_name, message, previous_enrollment,
auth_hash, auth_hash_expires, auth_hash_sent)
VALUES (null, 1,
true, true, true,
true, true, true, true,
false, false, false,
false, false, false, false,
'CONTACT_CREATED', false,
'[email protected]', '0404040404', null, null, null, null,
'Teppo', 'Testaaja', 'Tämä on viesti', 'Edellinen ilmoittautuminen vuonna 1999',
Expand All @@ -490,7 +490,7 @@ VALUES (null, 1, 1,
true, true, true, true,
'WAITING_AUTHENTICATION', false,
'[email protected]', '0404040404', null, null, null, null,
'Teppo', 'Testinen',
'Ilpo', 'Ilmoittautuja',
'922c2089-83a8-4163-8180-d8b675ff5337', NOW() + INTERVAL '3 days', NOW());

-- Insert multiple enrollment appointments for person 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Optional<EnrollmentAppointment> findByIdAndPaymentLinkHashAndDeletedAtIsNull(
"SELECT e" +
" FROM EnrollmentAppointment e" +
" WHERE e.examiner = ?1" +
" AND e.status IN (fi.oph.vkt.model.type.EnrollmentAppointmentStatus.CONTACT_CREATED, fi.oph.vkt.model.type.EnrollmentAppointmentStatus.WAITING_AUTHENTICATION)" +
" AND e.status = fi.oph.vkt.model.type.EnrollmentAppointmentStatus.CONTACT_CREATED" +
" AND e.deletedAt IS NULL" +
" ORDER BY e.createdAt DESC"
)
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/vkt/public/i18n/fi-FI/examiner.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
}
},
"authLinkErrorDialog": {
"description": "Ilmoittautuja täytyy liittää tutkintoon ennen ilmoittautumislinkin lähetystä.",
"header": "Valitse tutkinto"
"description": "Varmista, että ilmoittautuja on liitetty tutkintotilaisuuteen ja suoritettavat tutkinnot sekä osakokeet on valittu.",
"header": "Täytä tarvittavat tiedot"
},
"authLinkSuccessDialog": {
"description": "Asiakkaalle on lähetetty ilmoittautumislinkki sähköpostiin. Ilmoittautumislinkki on voimassa kolme (3) vuorokautta. Voit tarpeen vaatiessa lähettää ilmoittautumislinkin uudestaan.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { PartialExamsAndSkills } from 'interfaces/common/enrollment';
import { sendClerkEnrollmentAppointmentAuthLink } from 'redux/reducers/clerkEnrollmentAppointment';
import { clerkEnrollmentAppointmentSelector } from 'redux/selectors/clerkEnrollmentAppointment';
import { DateTimeUtils } from 'utils/dateTime';
import { EnrollmentUtils } from 'utils/enrollment';

const CheckboxField = ({
enrollment,
Expand Down Expand Up @@ -491,7 +492,10 @@ const EnrollmentStatus = ({
}, [showDialog, translateCommon, t, sendLinkStatus]);

const onSendAuthLink = () => {
if (!enrollment.examEvent) {
if (
!enrollment.examEvent ||
!EnrollmentUtils.isValidPartialExamsAndSkills(enrollment)
) {
showDialog({
title: t('authLinkErrorDialog.header'),
severity: Severity.Error,
Expand Down
13 changes: 12 additions & 1 deletion frontend/packages/vkt/src/pages/examiner/ExaminerHomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
} from 'configs/i18n';
import { useAppDispatch, useAppSelector } from 'configs/redux';
import { AppRoutes } from 'enums/app';
import { loadExaminerDetails } from 'redux/reducers/examinerDetails';
import {
loadExaminerDetails,
resetExaminerDetailsToInitialState,
} from 'redux/reducers/examinerDetails';
import { clerkUserSelector } from 'redux/selectors/clerkUser';
import { examinerDetailsSelector } from 'redux/selectors/examinerDetails';
import { ExaminerUtils } from 'utils/examiner';
Expand Down Expand Up @@ -128,6 +131,14 @@ export const ExaminerHomePage: FC = () => {
}
}, [initialized, navigate, clerkUser.isExaminer, oid]);

// Clean up on unmount
useEffect(
() => () => {
dispatch(resetExaminerDetailsToInitialState());
},
[dispatch],
);

return (
<Box className="examiner-homepage">
<Grid
Expand Down

0 comments on commit f49d7af

Please sign in to comment.