Skip to content

Commit

Permalink
VKT(Frontend): Upgrade to use new ComboBox implementation [deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Oct 25, 2023
1 parent cc1fb03 commit 0e85d14
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion frontend/packages/vkt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
},
"dependencies": {
"reduxjs-toolkit-persist": "^7.2.1",
"shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.9.29"
"shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.10.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Variant,
} from 'shared/enums';
import { useToast } from 'shared/hooks';
import { AutocompleteValue, ComboBoxOption } from 'shared/interfaces';
import { ComboBoxOption } from 'shared/interfaces';
import { DateUtils } from 'shared/utils';

import { useClerkTranslation, useCommonTranslation } from 'configs/i18n';
Expand Down Expand Up @@ -104,8 +104,15 @@ export const MoveModal: FC<MoveModalProps> = ({ enrollment, onCancel }) => {
.reverse()
.map(getComboBoxOption);

const handleExamEventOptionChange = ({}, value: AutocompleteValue) => {
setSelectedExamEventOption(value as ComboBoxOption);
const handleExamEventOptionChange = (value?: string) => {
if (value) {
const selected = selectableExamEventOptions.filter(
(v: ComboBoxOption) => v.value === value
);
setSelectedExamEventOption(selected);
} else {
setSelectedExamEventOption(null);
}
};

const handleMoveButtonClick = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState } from 'react';
import { ComboBox, H3 } from 'shared/components';
import { TextFieldVariant } from 'shared/enums';
import { AutocompleteValue } from 'shared/interfaces';

import { useClerkTranslation, useCommonTranslation } from 'configs/i18n';
import { useAppDispatch } from 'configs/redux';
Expand Down Expand Up @@ -29,8 +28,8 @@ export const ClerkExamLanguageLevel = ({
const translateCommon = useCommonTranslation();
const dispatch = useAppDispatch();

const onLangLevelChange = ({}, value: AutocompleteValue) => {
const [language, level] = (value?.value.split('-') as [
const onLangLevelChange = (languageAndLevel?: string) => {
const [language, level] = (languageAndLevel?.split('-') as [
Exclude<ExamLanguage, ExamLanguage.ALL>,
ExamLevel
]) || [undefined, undefined];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import DownloadIcon from '@mui/icons-material/DownloadOutlined';
import { Alert } from '@mui/material';
import { Dayjs } from 'dayjs';
import { ChangeEvent, FC, useCallback, useEffect, useState } from 'react';
import {
AutocompleteValue,
DropDownMenuButton,
ExtLink,
H2,
Text,
} from 'shared/components';
import { DropDownMenuButton, ExtLink, H2, Text } from 'shared/components';
import { APIResponseStatus, Color, Severity, Variant } from 'shared/enums';
import { useDialog, useToast } from 'shared/hooks';

Expand Down Expand Up @@ -195,9 +189,8 @@ export const ClerkExamEventDetails = () => {
];

const handleComboBoxChange =
(field: keyof ClerkExamEventBasicInformation) =>
({}, autocompleteValue?: AutocompleteValue) => {
handleFieldChange(field, autocompleteValue?.value);
(field: keyof ClerkExamEventBasicInformation) => (value?: string) => {
handleFieldChange(field, value);
};

const handleCheckBoxChange =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import dayjs, { Dayjs } from 'dayjs';
import { ChangeEvent } from 'react';
import {
AutocompleteValue,
ComboBox,
CustomDatePicker,
CustomSwitch,
Expand Down Expand Up @@ -30,7 +29,7 @@ export const ClerkExamEventDetailsFields = ({
editDisabled: boolean;
onComboBoxChange: (
field: keyof ClerkExamEventBasicInformation
) => ({}, autocompleteValue?: AutocompleteValue) => void;
) => (value?: string) => void;
onDateChange: (
field: keyof Pick<
ClerkExamEventBasicInformation,
Expand Down Expand Up @@ -79,7 +78,11 @@ export const ClerkExamEventDetailsFields = ({
values={Object.keys(ExamLanguage)
.filter((l) => l !== ExamLanguage.ALL)
.map(languageCodeToLabel)}
value={languageCodeToLabel(examEvent.language)}
value={
examEvent.language
? languageCodeToLabel(examEvent.language)
: null
}
onChange={onComboBoxChange('language')}
/>
</div>
Expand All @@ -91,7 +94,7 @@ export const ClerkExamEventDetailsFields = ({
disabled={editDisabled}
variant={TextFieldVariant.Outlined}
values={Object.keys(ExamLevel).map(examLevelToLabel)}
value={examLevelToLabel(examEvent.level)}
value={examEvent.level ? examLevelToLabel(examEvent.level) : null}
onChange={onComboBoxChange('level')}
/>
</div>
Expand Down
9 changes: 1 addition & 8 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3001,7 +3001,7 @@ __metadata:
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.vkt@workspace:packages/vkt"
dependencies:
reduxjs-toolkit-persist: ^7.2.1
shared: "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.9.29"
shared: "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.10.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -12606,13 +12606,6 @@ __metadata:
languageName: node
linkType: hard

"shared@npm:@opetushallitus/[email protected]":
version: 1.9.29
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@npm:1.9.29::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40Opetushallitus%2Fkieli-ja-kaantajatutkinnot.shared%2F1.9.29%2Fbae7e4637da7470c2d65ef5969d5bdc015618fc6"
checksum: 78851915b3556ca5bc459ddf5ade477c5f62876e6a267f1bb174f4a5e0add4d957ae35882f358e748ef58bb2dea00db913aa8cf2937340199037b7ff23757a40
languageName: node
linkType: hard

"shebang-command@npm:^2.0.0":
version: 2.0.0
resolution: "shebang-command@npm:2.0.0"
Expand Down

0 comments on commit 0e85d14

Please sign in to comment.