-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VKT(Frontend): Public examiner listing with mock data for good and sa…
…tisfactory level [deploy]
- Loading branch information
Showing
6 changed files
with
185 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { Dayjs } from "dayjs"; | ||
import { WithId } from "shared/interfaces"; | ||
import { Dayjs } from 'dayjs'; | ||
import { WithId } from 'shared/interfaces'; | ||
|
||
import { ExamLanguage } from "enums/app"; | ||
import { ExamLanguage } from 'enums/app'; | ||
import { APIResponseStatus } from 'shared/enums'; | ||
|
||
export interface PublicExaminer extends WithId { | ||
name: string; | ||
language: ExamLanguage; | ||
municipality: Array<string>; | ||
// TODO Municipality could instead be something like { fi: 'Helsinki', sv: 'Helsingfors' } ? | ||
municipalities: Array<string>; | ||
examDates: Array<Dayjs>; | ||
} | ||
} | ||
|
||
export interface PublicExaminerState { | ||
status: APIResponseStatus; | ||
examiners: Array<PublicExaminer>; | ||
languageFilter: ExamLanguage; | ||
} |
62 changes: 62 additions & 0 deletions
62
frontend/packages/vkt/src/redux/reducers/publicExaminer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import dayjs from 'dayjs'; | ||
import { APIResponseStatus } from 'shared/enums'; | ||
|
||
import { ExamLanguage } from 'enums/app'; | ||
import { PublicExaminerState } from 'interfaces/publicExaminer'; | ||
|
||
const initialState: PublicExaminerState = { | ||
status: APIResponseStatus.Success, | ||
examiners: [ | ||
{ | ||
id: 1, | ||
name: 'Eemeli Laine', | ||
language: ExamLanguage.FI, | ||
municipalities: ['Helsinki', 'Espoo', 'Vantaa', 'Kauniainen'], | ||
examDates: [], | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Kerttu Virtanen', | ||
language: ExamLanguage.SV, | ||
municipalities: ['Vaasa'], | ||
examDates: [], | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Aapo Mäkinen', | ||
language: ExamLanguage.ALL, | ||
municipalities: ['Tampere'], | ||
examDates: [dayjs('2024-10-17')], | ||
}, | ||
{ | ||
id: 4, | ||
name: 'Veera Salminen', | ||
language: ExamLanguage.FI, | ||
municipalities: ['Kajaani'], | ||
examDates: [ | ||
dayjs('2024-09-12'), | ||
dayjs('2024-09-13'), | ||
dayjs('2024-09-19'), | ||
dayjs('2024-09-20'), | ||
], | ||
}, | ||
], | ||
languageFilter: ExamLanguage.ALL, | ||
}; | ||
|
||
const publicExaminerSlice = createSlice({ | ||
name: 'publicExaminer', | ||
initialState, | ||
reducers: { | ||
setPublicExaminerLanguageFilter( | ||
state, | ||
action: PayloadAction<ExamLanguage>, | ||
) { | ||
state.languageFilter = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const publicExaminerReducer = publicExaminerSlice.reducer; | ||
export const { setPublicExaminerLanguageFilter } = publicExaminerSlice.actions; |
24 changes: 24 additions & 0 deletions
24
frontend/packages/vkt/src/redux/selectors/publicExaminer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createSelector } from '@reduxjs/toolkit'; | ||
|
||
import { RootState } from 'configs/redux'; | ||
import { ExamLanguage } from 'enums/app'; | ||
import { PublicExaminer, PublicExaminerState } from 'interfaces/publicExaminer'; | ||
|
||
export const publicExaminerSelector: ( | ||
state: RootState, | ||
) => PublicExaminerState = (state: RootState) => state.publicExaminer; | ||
|
||
export const selectFilteredPublicExaminers = createSelector( | ||
(state: RootState) => state.publicExaminer.examiners, | ||
(state: RootState) => state.publicExaminer.languageFilter, | ||
(publicExaminers: Array<PublicExaminer>, languageFilter: ExamLanguage) => { | ||
if (languageFilter === ExamLanguage.ALL) { | ||
return publicExaminers; | ||
} else { | ||
return publicExaminers.filter( | ||
({ language }) => | ||
language === ExamLanguage.ALL || language === languageFilter, | ||
); | ||
} | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters