Skip to content

Commit

Permalink
VKT(Frontend): Keep track of contacted examiners
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Nov 25, 2024
1 parent 8e5c163 commit 79d3a64
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions frontend/packages/vkt/public/i18n/fi-FI/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@
"examDates": "Tutkintopäivät"
},
"row": {
"alreadyContacted": "Yhteydenotto lähetetty",
"byRequest": "Sovittavissa",
"contact": "Ota yhteyttä"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { AppRoutes, ExamLanguage } from 'enums/app';
import { PublicExaminer } from 'interfaces/publicExaminer';
import { resetPublicEnrollmentContact } from 'redux/reducers/publicEnrollmentContact';
import { setPublicExaminerLanguageFilter } from 'redux/reducers/publicExaminer';
import { publicEnrollmentContactSelector } from 'redux/selectors/publicEnrollmentContact';
import {
publicExaminerSelector,
selectFilteredPublicExaminers,
Expand Down Expand Up @@ -81,6 +82,13 @@ const DesktopExaminerRow = ({
);
};

const { contactedExaminers } = useAppSelector(
publicEnrollmentContactSelector,
);
const alreadyContacted = contactedExaminers.find(
(contacted) => id === contacted.id,
);

return (
<TableRow sx={{ verticalAlign: 'text-top' }}>
<TableCell>
Expand Down Expand Up @@ -113,13 +121,17 @@ const DesktopExaminerRow = ({
</Text>
</TableCell>
<TableCell>
<CustomButton
color={Color.Secondary}
variant={Variant.Outlined}
onClick={handleOnClick}
>
{t('row.contact')}
</CustomButton>
{alreadyContacted ? (
<Text>{t('row.alreadyContacted')}</Text>
) : (
<CustomButton
color={Color.Secondary}
variant={Variant.Outlined}
onClick={handleOnClick}
>
{t('row.contact')}
</CustomButton>
)}
</TableCell>
</TableRow>
);
Expand Down Expand Up @@ -177,7 +189,7 @@ export const PublicExaminerListing = () => {
<Paper elevation={3} className="public-examiner-listing">
<div className="columns">
<div className="grow">
<H2>Ota yhteyttä tutkinnon vastaanottajiin</H2>
<H2>Ota yhteyttä tutkintosuorituksen vastaanottajiin</H2>
</div>
</div>
<LanguageFilter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { APIResponseStatus } from 'shared/enums';
import { WithId } from 'shared/interfaces';

import { PublicEnrollmentContact } from 'interfaces/publicEnrollment';
import { PublicExaminer } from 'interfaces/publicExaminer';
Expand All @@ -11,6 +12,7 @@ export interface PublicEnrollmentContactState {
cancelStatus: APIResponseStatus;
enrollment: PublicEnrollmentContact;
examiner?: PublicExaminer;
contactedExaminers: Array<WithId>;
}

const initialState: PublicEnrollmentContactState = {
Expand All @@ -33,6 +35,7 @@ const initialState: PublicEnrollmentContactState = {
message: '',
},
examiner: undefined,
contactedExaminers: [],
};

const publicEnrollmentContactSlice = createSlice({
Expand All @@ -55,6 +58,9 @@ const publicEnrollmentContactSlice = createSlice({
) {
state.enrollment = { ...state.enrollment, ...action.payload };
},
markExaminerAsContacted(state, action: PayloadAction<WithId>) {
state.contactedExaminers = [...state.contactedExaminers, action.payload];
},
loadPublicEnrollmentSave(
state,
_action: PayloadAction<{
Expand Down Expand Up @@ -87,4 +93,5 @@ export const {
loadPublicExaminer,
updatePublicEnrollmentContact,
resetPublicEnrollmentContact,
markExaminerAsContacted,
} = publicEnrollmentContactSlice.actions;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { setAPIError } from 'redux/reducers/APIError';
import {
loadPublicEnrollmentSave,
loadPublicExaminer,
markExaminerAsContacted,
rejectPublicEnrollmentSave,
rejectPublicExaminer,
storePublicEnrollmentSave,
Expand Down Expand Up @@ -57,6 +58,7 @@ function* loadPublicEnrollmentSaveSaga(
yield call(axiosInstance.post, saveUrl, body);

yield put(storePublicEnrollmentSave());
yield put(markExaminerAsContacted({ id: examinerId }));
} catch (error) {
const errorMessage = NotifierUtils.getAPIErrorMessage(error as AxiosError);
yield put(setAPIError(errorMessage));
Expand Down

0 comments on commit 79d3a64

Please sign in to comment.