diff --git a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx index e79d652f6b..c5884dbd9c 100644 --- a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx +++ b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx @@ -32,6 +32,7 @@ export type DomainInfo = { name: string ssoEnabled?: boolean ssoBeta?: boolean + departments?: string[] } } diff --git a/services/web/frontend/js/features/settings/components/emails/add-email/institution-fields.tsx b/services/web/frontend/js/features/settings/components/emails/add-email/institution-fields.tsx index 49b7de61e7..bb491f4713 100644 --- a/services/web/frontend/js/features/settings/components/emails/add-email/institution-fields.tsx +++ b/services/web/frontend/js/features/settings/components/emails/add-email/institution-fields.tsx @@ -75,16 +75,21 @@ function InstitutionFields({ }, [newEmailMatchedDomain, setRole, setDepartment]) useEffect(() => { + if (newEmailMatchedDomain?.university?.departments?.length) { + setDepartments(newEmailMatchedDomain.university.departments) + return + } + + // fallback if not matched on domain const selectedKnownUniversity = countryCode ? universities[countryCode]?.find(({ name }) => name === universityName) : undefined - if (selectedKnownUniversity && selectedKnownUniversity.departments.length) { setDepartments(selectedKnownUniversity.departments) } else { setDepartments([...defaultDepartments]) } - }, [countryCode, universities, universityName]) + }, [countryCode, universities, universityName, newEmailMatchedDomain]) // Fetch country institution useEffect(() => {