import type { PondView } from '@dorfteich/shared'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; import { useAuth } from '../auth/auth-context'; import { FormError } from '../components/forms'; import { LabelManager } from '../labels/LabelManager'; import { PhantomPagesView } from '../links/PhantomPagesView'; import { AccessRulesManager } from '../access/AccessRulesManager'; import { EffectivePermissionsInspector } from '../access/EffectivePermissionsInspector'; import { PondFileManager } from '../files/PondFileManager'; import { apiGet } from '../lib/api'; import { MemberManager } from '../members/MemberManager'; /** * Pond settings (issues #44/#54). Hosts the 'Members' and 'Labels' sections; * future pond-level configuration (fonts, etc.) joins it here. Member * management is Pond-Admin-gated in the api (the MemberManager shows the list * to any member and hides the controls otherwise); label management needs * modify rights. The sidebar links here for the pond owner (Site Admins and * other members can still navigate directly). */ export function PondSettingsPage(): React.JSX.Element { const { t } = useTranslation('labels'); const { t: tLinks } = useTranslation('links'); const { t: tMembers } = useTranslation('members'); const { t: tErrors } = useTranslation('errors'); const { t: tFiles } = useTranslation('files'); const { t: tExport } = useTranslation('export'); const { pondSlug = '' } = useParams<{ pondSlug: string }>(); const { user } = useAuth(); const pond = useQuery({ queryKey: ['pond', pondSlug], queryFn: () => apiGet(`/ponds/${pondSlug}`), }); if (pond.error) return ; if (!pond.data) return <>; const canModify = Boolean(user && (user.isSiteAdmin || user.id === pond.data.ownerId)); return (

{pond.data.name}

{tMembers('title')}

{t('settings.title')}

{canModify ? ( ) : (

{tErrors('forbidden')}

)}
{canModify && (

{tLinks('missing.title')}

)} {canModify && (

{tFiles('manager.title')}

)}

{tExport('pond.heading')}

{tExport('pond.hint')}

{tExport('pond.zip')}
); }