diff --git a/src/components/profile/Profile.tsx b/src/components/profile/Profile.tsx index 8c724ab71..c4b1eff46 100644 --- a/src/components/profile/Profile.tsx +++ b/src/components/profile/Profile.tsx @@ -61,7 +61,9 @@ export const Profile = () => { const legalLinks = useContext(LegalLinksContext); const { userData } = useContext(UserDataContext); - const { specificAgency } = useContext(AgencySpecificContext); + const { specificAgency, setSpecificAgency } = useContext( + AgencySpecificContext + ); const { consultingTypes } = useContext(ConsultingTypesContext); const [mobileMenu, setMobileMenu] = useState< @@ -85,6 +87,18 @@ export const Profile = () => { scrollContainer.current.scrollTo(0, 0); }, [location]); + useEffect(() => { + // First agency can be set as only one session per asker is possible + // isSubsequentRegistrationAllowed false on consultingType + if (!hasUserAuthority(AUTHORITIES.CONSULTANT_DEFAULT, userData)) { + const specAgency = Object.values(userData.consultingTypes)?.filter( + (resort: any) => + resort.isRegistered && resort.agency ? resort : null + ); + setSpecificAgency(specAgency[0].agency); + } + }, [setSpecificAgency, userData]); + useEffect(() => { setMobileMenu( profileRoutes(settings, tenant, selectableLocales, isFirstVisit)