import React from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useQuery } from '@tanstack/react-query'; import { ChevronRight } from 'lucide-react'; import { YStack } from '@tamagui/stacks'; import { SizableText as Text } from '@tamagui/text'; import { YGroup } from '@tamagui/group'; import { ListItem } from '@tamagui/list-item'; import { MobileShell } from './components/MobileShell'; import { MobileCard, CTAButton, SkeletonCard } from './components/Primitives'; import { useAdminTheme } from './theme'; import { useBackNavigation } from './hooks/useBackNavigation'; import { adminPath, ADMIN_FAQ_PATH } from '../constants'; import { fetchHelpCenterArticle, type HelpCenterArticle } from '../api'; export default function MobileHelpArticlePage() { const { slug } = useParams<{ slug: string }>(); const { t, i18n } = useTranslation(['management', 'dashboard']); const theme = useAdminTheme(); const back = useBackNavigation(ADMIN_FAQ_PATH); const navigate = useNavigate(); const locale = i18n.language; const { data, isLoading, isError, refetch } = useQuery({ queryKey: ['mobile', 'help-article', slug, locale], enabled: Boolean(slug), queryFn: () => fetchHelpCenterArticle(slug ?? '', locale), }); const article: HelpCenterArticle | null = data ?? null; return ( {isLoading ? ( ) : null} {isError ? ( {t('dashboard:help.error', 'Help could not be loaded.')} refetch()} fullWidth={false} /> ) : null} {!isLoading && article ? ( {article.title} {article.updated_at ? ( {t('help.article.updated', 'Aktualisiert')}:{' '} {new Date(article.updated_at).toLocaleDateString(locale, { day: '2-digit', month: 'short', year: 'numeric', })} ) : null}
{article.related && article.related.length > 0 ? ( {t('help.article.relatedTitle', 'Weitere Artikel')} {article.related.map((rel) => ( navigate(adminPath(`/mobile/help/${encodeURIComponent(rel.slug)}`))} title={ {rel.title ?? rel.slug} } iconAfter={} /> ))} ) : null} ) : null} ); }