diff --git a/frontend/src/pages/profile/profile.groupChange.page.tsx b/frontend/src/pages/profile/profile.groupChange.page.tsx index d503ec66..59050156 100644 --- a/frontend/src/pages/profile/profile.groupChange.page.tsx +++ b/frontend/src/pages/profile/profile.groupChange.page.tsx @@ -1,6 +1,9 @@ +import { useConfigContext } from '@/api/contexts/config/ConfigContext.tsx' +import type { Profile } from '@/api/contexts/config/types.ts' import { useServiceContext } from '@/api/contexts/service/ServiceContext' import { useGroupChangeMutation } from '@/api/hooks/group-change/useGroupChangeMutation' import { useProfileQuery } from '@/api/hooks/profile/useProfileQuery.ts' +import { ComponentUnavailable } from '@/common-components/ComponentUnavailable.tsx' import { CmschPage } from '@/common-components/layout/CmschPage' import { LinkButton } from '@/common-components/LinkButton' import { PageStatus } from '@/common-components/PageStatus.tsx' @@ -16,13 +19,25 @@ import { Navigate, useNavigate } from 'react-router' export function ProfileGroupChangePage() { const { isLoading, isError, data: profile, refetch } = useProfileQuery() + const config = useConfigContext()?.components + const component = config?.profile + + if (!component) return if (isError || isLoading || !profile) return if (!profile || !profile.groupSelectionAllowed) return - return + return } -function ProfileGroupChangeBody({ profile, refetch }: { profile: ProfileView; refetch: () => void }) { +function ProfileGroupChangeBody({ + profile, + profileComponent, + refetch +}: { + profile: ProfileView + profileComponent: Profile + refetch: () => void +}) { const availableGroups = profile.availableGroups ? Object.entries(profile.availableGroups).toSorted((a, b) => a[1].localeCompare(b[1])) : [] @@ -40,7 +55,7 @@ function ProfileGroupChangeBody({ profile, refetch }: { profile: ProfileView; re navigate(AbsolutePaths.PROFILE) break case GroupChangeStatus.INVALID_GROUP: - setError('Érvénytelen tankör!') + setError(`Érvénytelen ${profileComponent.groupTitle}!`) break case GroupChangeStatus.LEAVE_DENIED: setError('Nem engedélyezett a módosítás!') @@ -60,14 +75,16 @@ function ProfileGroupChangeBody({ profile, refetch }: { profile: ProfileView; re const onSubmit = () => { if (value) mutate(value) - else setError('Válassz tankört!') + else setError(`Válassz ${profileComponent.groupTitle}-t!`) } return ( - -

Tankör beállítása

-

Állítsd be a tankörödet, hogy részt vehess a feladatokban!

-

Csak helyesen beállított tankörrel fog érvényesülni a tanköri jelenlét!

+ +

{`${profileComponent.groupTitle} beállítása`}

+

Állíts be saját {profileComponent.groupTitle}-t, hogy részt vehess a feladatokban!

+ {profileComponent.showMinimumTokenMessage && ( +

Csak helyesen beállított tankör esetén fog érvényesülni a tanköri jelenlét!

+ )} {availableGroups.length ? (
{ @@ -77,10 +94,10 @@ function ProfileGroupChangeBody({ profile, refetch }: { profile: ProfileView; re >
- +