diff --git a/frontend/packages/otr/package.json b/frontend/packages/otr/package.json index 17013064a9..fe37d6a464 100644 --- a/frontend/packages/otr/package.json +++ b/frontend/packages/otr/package.json @@ -25,6 +25,6 @@ "otr:tslint": "yarn g:tsc --pretty --noEmit" }, "dependencies": { - "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.9.28" + "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.10.0" } } diff --git a/frontend/packages/otr/src/components/clerkInterpreter/filters/ClerkInterpreterAutocompleteFilters.tsx b/frontend/packages/otr/src/components/clerkInterpreter/filters/ClerkInterpreterAutocompleteFilters.tsx index 30f4717618..e5a1d1755c 100644 --- a/frontend/packages/otr/src/components/clerkInterpreter/filters/ClerkInterpreterAutocompleteFilters.tsx +++ b/frontend/packages/otr/src/components/clerkInterpreter/filters/ClerkInterpreterAutocompleteFilters.tsx @@ -65,11 +65,16 @@ export const ClerkInterpreterAutocompleteFilters = ({ }; const handleFilterChange = - (filter: keyof ClerkInterpreterFilters) => + (filter: keyof Omit) => ({}, value: AutocompleteValue) => { setPage(0); dispatch(addClerkInterpreterFilter({ [filter]: value?.value })); }; + const handleLanguageFilterChange = + (filter: 'fromLang' | 'toLang') => (language?: string) => { + setPage(0); + dispatch(addClerkInterpreterFilter({ [filter]: language })); + }; const getPermissionToPublishSelectValues = () => Object.values(PermissionToPublish).map((v) => ({ @@ -97,7 +102,7 @@ export const ClerkInterpreterAutocompleteFilters = ({ value={getLanguageSelectValue(filters.fromLang)} disabled={true} variant={TextFieldVariant.Outlined} - onChange={handleFilterChange('fromLang')} + onLanguageChange={handleLanguageFilterChange('fromLang')} languages={QualificationUtils.selectableFromLangs} excludedLanguage={filters.toLang} translateLanguage={translateLanguage} @@ -108,7 +113,7 @@ export const ClerkInterpreterAutocompleteFilters = ({ label={t('languagePair.toPlaceholder')} value={getLanguageSelectValue(filters.toLang)} variant={TextFieldVariant.Outlined} - onChange={handleFilterChange('toLang')} + onLanguageChange={handleLanguageFilterChange('toLang')} languages={distinctToLangs} excludedLanguage={filters.fromLang} translateLanguage={translateLanguage} diff --git a/frontend/packages/otr/src/components/clerkInterpreter/qualification/QualificationFields.tsx b/frontend/packages/otr/src/components/clerkInterpreter/qualification/QualificationFields.tsx index c29008f7da..2bcad91465 100644 --- a/frontend/packages/otr/src/components/clerkInterpreter/qualification/QualificationFields.tsx +++ b/frontend/packages/otr/src/components/clerkInterpreter/qualification/QualificationFields.tsx @@ -78,11 +78,10 @@ export const QualificationFields = ({ : null; const handleLanguageSelectChange = - (fieldName: string) => - ({}, value: AutocompleteValue) => { + (fieldName: 'fromLang' | 'toLang') => (language?: string) => { setQualification({ ...qualification, - [fieldName]: value?.value ?? '', + [fieldName]: language, }); setIsQualificationDataChanged(true); }; @@ -161,7 +160,7 @@ export const QualificationFields = ({ label={t('fieldPlaceholders.from')} variant={TextFieldVariant.Outlined} value={getLanguageSelectValue(qualification.fromLang)} - onChange={handleLanguageSelectChange('fromLang')} + onLanguageChange={handleLanguageSelectChange('fromLang')} languages={QualificationUtils.selectableFromLangs} excludedLanguage={qualification.toLang} translateLanguage={translateLanguage} @@ -176,7 +175,7 @@ export const QualificationFields = ({ label={t('fieldPlaceholders.to')} variant={TextFieldVariant.Outlined} value={getLanguageSelectValue(qualification.toLang)} - onChange={handleLanguageSelectChange('toLang')} + onLanguageChange={handleLanguageSelectChange('toLang')} languages={QualificationUtils.getKoodistoLangKeys()} excludedLanguage={qualification.fromLang} translateLanguage={translateLanguage} diff --git a/frontend/packages/otr/src/components/publicInterpreter/filters/PublicInterpreterFilters.tsx b/frontend/packages/otr/src/components/publicInterpreter/filters/PublicInterpreterFilters.tsx index ba7b7b4a1a..b22cc4e23a 100644 --- a/frontend/packages/otr/src/components/publicInterpreter/filters/PublicInterpreterFilters.tsx +++ b/frontend/packages/otr/src/components/publicInterpreter/filters/PublicInterpreterFilters.tsx @@ -68,11 +68,8 @@ export const PublicInterpreterFilters = ({ }; const defaultValuesState: PublicInterpreterFilterValues = { - fromLang: languageToComboBoxOption( - translateLanguage, - QualificationUtils.defaultFromLang - ), - toLang: null, + fromLang: '', + toLang: '', name: '', region: null, }; @@ -161,6 +158,20 @@ export const PublicInterpreterFilters = ({ setSearchButtonDisabled(false); }; + const handleLanguageChange = + (languageField: SearchFilter.FromLang | SearchFilter.ToLang) => + (language?: string) => { + setFilters((prevState) => ({ + ...prevState, + [languageField]: language || '', + })); + setValues((prevState) => ({ + ...prevState, + [languageField]: language || '', + })); + setSearchButtonDisabled(false); + }; + const handleTextFieldFilterChange = (filterName: SearchFilter) => (event: React.ChangeEvent) => { @@ -178,10 +189,8 @@ export const PublicInterpreterFilters = ({ const getComboBoxAttributes = (fieldName: SearchFilter) => ({ onInputChange: handleComboboxInputChange(fieldName), inputValue: inputValues[fieldName], - value: values[fieldName] as AutocompleteValue, autoHighlight: true, variant: TextFieldVariant.Outlined, - onChange: handleComboboxFilterChange(fieldName), }); const handleKeyUp = (event: KeyboardEvent) => { @@ -223,6 +232,12 @@ export const PublicInterpreterFilters = ({