(frontend) allow customization of error title and description

Enhanced the error screen to support customizable titles and descriptions.

Allows for more detailed and informative error messages for users.
By default, the error screen displays a standard heading. You can
now pass custom title and body content to provide additional context
and clarity.
This commit is contained in:
lebaudantoine
2024-08-04 21:21:53 +02:00
committed by aleb_the_flash
parent df1eca7c34
commit 01390b12fb
5 changed files with 42 additions and 3 deletions

View File

@@ -1,12 +1,25 @@
import { CenteredContent } from '@/layout/CenteredContent'
import { Screen } from '@/layout/Screen'
import { useTranslation } from 'react-i18next'
import { Center } from '@/styled-system/jsx'
import { Text } from '@/primitives'
export const ErrorScreen = () => {
export const ErrorScreen = ({ title, body }: {
title?: string
body?: string
}) => {
const { t } = useTranslation()
return (
<Screen layout="centered">
<CenteredContent title={t('error.heading')} withBackButton />
<CenteredContent title={title || t('error.heading')} withBackButton>
{!!body && (
<Center>
<Text as="p" variant="h3">
{body}
</Text>
</Center>
)}
</CenteredContent>
</Screen>
)
}