diff --git a/app/[locale]/(authenticated)/translate/[code]/TranslationToolbar.tsx b/app/[locale]/(authenticated)/translate/[code]/TranslationToolbar.tsx index cecfd9b..125287f 100644 --- a/app/[locale]/(authenticated)/translate/[code]/TranslationToolbar.tsx +++ b/app/[locale]/(authenticated)/translate/[code]/TranslationToolbar.tsx @@ -16,7 +16,7 @@ import { useSWRConfig } from "swr"; export interface TranslationToolbarProps { languages: { name: string; code: string }[]; - currentLanguage: { roles: string [] }; + currentLanguage?: { roles: string [] }; } export default function TranslationToolbar({ @@ -28,8 +28,8 @@ export default function TranslationToolbar({ const router = useRouter() const { mutate } = useSWRConfig() - const isTranslator = currentLanguage.roles.includes('TRANSLATOR'); - const isAdmin = currentLanguage.roles.includes('ADMIN'); + const isTranslator = !!currentLanguage?.roles.includes('TRANSLATOR'); + const isAdmin = !!currentLanguage?.roles.includes('ADMIN'); const { selectedWords, focusedPhrase, clearSelectedWords } = useTranslationClientState() const canLinkWords = selectedWords.length > 1; diff --git a/app/[locale]/(authenticated)/translate/[code]/layout.tsx b/app/[locale]/(authenticated)/translate/[code]/layout.tsx index 012d5e0..e75c41a 100644 --- a/app/[locale]/(authenticated)/translate/[code]/layout.tsx +++ b/app/[locale]/(authenticated)/translate/[code]/layout.tsx @@ -19,15 +19,11 @@ export default async function InterlinearLayout({ children, params }: Props) { if (!session) { notFound() } - const isAdmin = session.user.roles.includes('ADMIN') const [languages, currentLanguage] = await Promise.all([ fetchLanguages(), fetchCurrentLanguage(params.code, session?.user.id) ]) - if (!currentLanguage || (!isAdmin && currentLanguage.roles.length === 0)) { - notFound() - } return