-
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): Implement exam event listing across all examiners for …
…OPH clerk user [deploy]
- Loading branch information
Showing
11 changed files
with
329 additions
and
13 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
71 changes: 71 additions & 0 deletions
71
frontend/packages/vkt/src/components/clerkExaminer/ClerkExaminerExamEventListing.tsx
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,71 @@ | ||
import { Divider, SelectChangeEvent } from '@mui/material'; | ||
import { H2, PaginatedTable } from 'shared/components'; | ||
|
||
import { ClerkExaminerExamEventListingHeader } from 'components/clerkExaminer/ClerkExaminerExamEventListingHeader'; | ||
import { ClerkExaminerExamEventListingRow } from 'components/clerkExaminer/ClerkExaminerExamEventListingRow'; | ||
import { ClerkExaminerExamEventToggleFilters } from 'components/clerkExaminer/ClerkExaminerExamEventToggleFilters'; | ||
import { LanguageFilter } from 'components/common/LanguageFilter'; | ||
import { useClerkTranslation, useCommonTranslation } from 'configs/i18n'; | ||
import { useAppDispatch, useAppSelector } from 'configs/redux'; | ||
import { ExamLanguage } from 'enums/app'; | ||
import { ClerkExaminerExamEventListingEntry } from 'interfaces/clerkListExaminer'; | ||
import { setClerkListExaminerExamEventFilters } from 'redux/reducers/clerkListExaminer'; | ||
import { | ||
clerkListExaminerSelector, | ||
selectFilteredClerkExaminerExamEvents, | ||
} from 'redux/selectors/clerkListExaminer'; | ||
|
||
const getRowDetails = (entry: ClerkExaminerExamEventListingEntry) => { | ||
return <ClerkExaminerExamEventListingRow entry={entry} />; | ||
}; | ||
|
||
export const ClerkExaminerExamEventListing = () => { | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkExamEventListing', | ||
}); | ||
const translateCommon = useCommonTranslation(); | ||
const dispatch = useAppDispatch(); | ||
|
||
const { examLanguage } = useAppSelector(clerkListExaminerSelector).filters | ||
.examEvents; | ||
|
||
const handleLanguageFilterChange = (event: SelectChangeEvent) => { | ||
dispatch( | ||
setClerkListExaminerExamEventFilters({ | ||
examLanguage: event.target.value as ExamLanguage, | ||
}), | ||
); | ||
}; | ||
|
||
const entries = useAppSelector(selectFilteredClerkExaminerExamEvents); | ||
|
||
// TODO Table sorting not implemented yet! | ||
|
||
return ( | ||
<> | ||
<div className="columns"> | ||
<div className="clerk-homepage__grid-container__heading"> | ||
<H2>{t('title')}</H2> | ||
</div> | ||
</div> | ||
<Divider /> | ||
<ClerkExaminerExamEventToggleFilters /> | ||
<PaginatedTable | ||
headerContent={ | ||
<LanguageFilter | ||
value={examLanguage} | ||
onChange={handleLanguageFilterChange} | ||
/> | ||
} | ||
className="table-layout-auto" | ||
data={entries} | ||
header={<ClerkExaminerExamEventListingHeader />} | ||
getRowDetails={getRowDetails} | ||
initialRowsPerPage={10} | ||
rowsPerPageOptions={[10, 20, 50]} | ||
rowsPerPageLabel={translateCommon('rowsPerPageLabel')} | ||
stickyHeader | ||
/> | ||
</> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
frontend/packages/vkt/src/components/clerkExaminer/ClerkExaminerExamEventListingHeader.tsx
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,22 @@ | ||
import { TableCell, TableHead, TableRow } from '@mui/material'; | ||
|
||
import { useClerkTranslation } from 'configs/i18n'; | ||
|
||
export const ClerkExaminerExamEventListingHeader = () => { | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkExaminerExamEventListing.header', | ||
}); | ||
|
||
return ( | ||
<TableHead className="heading-text"> | ||
<TableRow> | ||
<TableCell>{t('examiner')}</TableCell> | ||
<TableCell>{t('language')}</TableCell> | ||
<TableCell>{t('municipality')}</TableCell> | ||
<TableCell>{t('examDate')}</TableCell> | ||
<TableCell>{t('isPublic')}</TableCell> | ||
<TableCell /> | ||
</TableRow> | ||
</TableHead> | ||
); | ||
}; |
77 changes: 77 additions & 0 deletions
77
frontend/packages/vkt/src/components/clerkExaminer/ClerkExaminerExamEventListingRow.tsx
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,77 @@ | ||
import { ChevronRight } from '@mui/icons-material'; | ||
import { TableCell, TableRow } from '@mui/material'; | ||
import { Link } from 'react-router-dom'; | ||
import { CustomButtonLink, Text } from 'shared/components'; | ||
import { Color, Variant } from 'shared/enums'; | ||
|
||
import { | ||
useClerkTranslation, | ||
useCommonTranslation, | ||
useKoodistoMunicipalitiesTranslation, | ||
} from 'configs/i18n'; | ||
import { AppRoutes } from 'enums/app'; | ||
import { ClerkExaminerExamEventListingEntry } from 'interfaces/clerkListExaminer'; | ||
import { DateTimeUtils } from 'utils/dateTime'; | ||
|
||
export const ClerkExaminerExamEventListingRow = ({ | ||
entry, | ||
}: { | ||
entry: ClerkExaminerExamEventListingEntry; | ||
}) => { | ||
const translateMunicipality = useKoodistoMunicipalitiesTranslation(); | ||
const translateCommon = useCommonTranslation(); | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkExaminerExamEventListing', | ||
}); | ||
const { examiner, examEvent } = entry; | ||
|
||
const examEventUrl = AppRoutes.ExaminerExamEventPage.replace( | ||
/:oid/, | ||
examiner.oid, | ||
).replace(/:examEventId$/, `${examEvent.id}`); | ||
|
||
return ( | ||
<> | ||
<TableRow | ||
className="clerk-exam-event-listing__row" | ||
data-testid={`clerk-exam-events__id-${examEvent.id}-row`} | ||
> | ||
<TableCell> | ||
<Link | ||
className="clerk-exam-event-listing__row__link" | ||
to={examEventUrl} | ||
> | ||
<Text>{`${examiner.firstName} ${examiner.lastName}`}</Text> | ||
</Link> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{translateCommon(`examLanguage.${examEvent.language}`)}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{translateMunicipality(examEvent.municipality.code)}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{DateTimeUtils.renderDate(examEvent.date)}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text> | ||
{examEvent.isHidden | ||
? translateCommon('no') | ||
: translateCommon('yes')} | ||
</Text> | ||
</TableCell> | ||
<TableCell> | ||
<CustomButtonLink | ||
sx={{ padding: 0 }} | ||
variant={Variant.Text} | ||
color={Color.Secondary} | ||
endIcon={<ChevronRight />} | ||
to={examEventUrl} | ||
> | ||
{t('more')} | ||
</CustomButtonLink> | ||
</TableCell> | ||
</TableRow> | ||
</> | ||
); | ||
}; |
45 changes: 45 additions & 0 deletions
45
frontend/packages/vkt/src/components/clerkExaminer/ClerkExaminerExamEventToggleFilters.tsx
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,45 @@ | ||
import { ToggleFilterGroup } from 'shared/components'; | ||
|
||
import { useClerkTranslation } from 'configs/i18n'; | ||
import { useAppDispatch, useAppSelector } from 'configs/redux'; | ||
import { ExamEventToggleFilter } from 'enums/app'; | ||
import { setClerkListExaminerExamEventFilters } from 'redux/reducers/clerkListExaminer'; | ||
import { clerkListExaminerSelector } from 'redux/selectors/clerkListExaminer'; | ||
import { ExamEventUtils } from 'utils/examEvent'; | ||
|
||
export const ClerkExaminerExamEventToggleFilters = () => { | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkExamEventListing.toggleFilters', | ||
}); | ||
|
||
const { examiners, filters } = useAppSelector(clerkListExaminerSelector); | ||
const examEvents = examiners.flatMap(({ examEvents }) => examEvents); | ||
const dispatch = useAppDispatch(); | ||
|
||
const setToggleFilter = (status: ExamEventToggleFilter) => { | ||
dispatch(setClerkListExaminerExamEventFilters({ toggleFilters: status })); | ||
}; | ||
|
||
const filterData = [ | ||
{ | ||
status: ExamEventToggleFilter.Upcoming, | ||
label: t(ExamEventToggleFilter.Upcoming), | ||
count: ExamEventUtils.getUpcomingExamEvents(examEvents).length, | ||
testId: `clerk-exam-event-toggle-filters__${ExamEventToggleFilter.Upcoming}-btn`, | ||
}, | ||
{ | ||
status: ExamEventToggleFilter.Passed, | ||
label: t(ExamEventToggleFilter.Passed), | ||
count: ExamEventUtils.getPassedExamEvents(examEvents).length, | ||
testId: `clerk-exam-event-toggle-filters__${ExamEventToggleFilter.Passed}-btn`, | ||
}, | ||
]; | ||
|
||
return ( | ||
<ToggleFilterGroup | ||
filters={filterData} | ||
activeStatus={filters.examEvents.toggleFilters} | ||
onButtonClick={setToggleFilter} | ||
/> | ||
); | ||
}; |
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,14 +1,29 @@ | ||
import { APIResponseStatus } from 'shared/enums'; | ||
import { WithId } from 'shared/interfaces'; | ||
|
||
import { ExamLanguage } from 'enums/app'; | ||
import { ExamEventToggleFilter, ExamLanguage } from 'enums/app'; | ||
import { ExaminerDetails } from 'interfaces/examinerDetails'; | ||
import { ExaminerExamEvent } from 'interfaces/examinerExamEvent'; | ||
|
||
export interface ClerkListExaminerFilters { | ||
examLanguage: ExamLanguage; | ||
} | ||
|
||
export interface ClerkListExaminerExamEventFilters { | ||
examLanguage: ExamLanguage; | ||
toggleFilters: ExamEventToggleFilter; | ||
} | ||
|
||
export interface ClerkListExaminerState { | ||
status: APIResponseStatus; | ||
examiners: Array<ExaminerDetails>; | ||
filters: ClerkListExaminerFilters; | ||
filters: { | ||
examiners: ClerkListExaminerFilters | ||
examEvents: ClerkListExaminerExamEventFilters; | ||
} | ||
} | ||
|
||
export interface ClerkExaminerExamEventListingEntry extends WithId { | ||
examiner: Omit<ExaminerDetails, 'examEvents' | 'contactRequests'>; | ||
examEvent: ExaminerExamEvent; | ||
} |
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
Oops, something went wrong.