diff --git a/CHANGELOG.md b/CHANGELOG.md index 060a0af06..102c6b602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to - 🐛(frontend) abort check media status unmount #2194 - ✨(backend) order pinned documents by last updated at #2028 +### Changed + + - ♿️(frontend) structure correctly 5xx error alerts #2128 + ## [v4.8.6] - 2026-04-08 ### Added diff --git a/src/frontend/apps/impress/src/components/TextErrors.tsx b/src/frontend/apps/impress/src/components/TextErrors.tsx index d5c635e27..996cf0f6f 100644 --- a/src/frontend/apps/impress/src/components/TextErrors.tsx +++ b/src/frontend/apps/impress/src/components/TextErrors.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import styled from 'styled-components'; import { Box, Text, TextType } from '@/components'; +import { useHttpErrorMessages } from '@/hooks'; const AlertStyled = styled(Alert)` & .c__button--tertiary:hover { @@ -16,6 +17,7 @@ interface TextErrorsProps extends TextType { defaultMessage?: string; icon?: ReactNode; canClose?: boolean; + status?: number; } export const TextErrors = ({ @@ -23,6 +25,7 @@ export const TextErrors = ({ defaultMessage, icon, canClose = false, + status, ...textProps }: TextErrorsProps) => { return ( @@ -35,6 +38,7 @@ export const TextErrors = ({ @@ -44,9 +48,39 @@ export const TextErrors = ({ export const TextOnlyErrors = ({ causes, defaultMessage, + status, ...textProps }: TextErrorsProps) => { const { t } = useTranslation(); + const httpError = useHttpErrorMessages(status); + + if (httpError) { + return ( + + + {httpError.title} + + + {httpError.detail} + + + ); + } return ( diff --git a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/DocVersionEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/DocVersionEditor.tsx index f903e70ec..50c79eb0c 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/DocVersionEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/DocVersionEditor.tsx @@ -58,6 +58,7 @@ export const DocVersionEditor = ({ diff --git a/src/frontend/apps/impress/src/hooks/index.ts b/src/frontend/apps/impress/src/hooks/index.ts index 340eaa5d6..cd2439939 100644 --- a/src/frontend/apps/impress/src/hooks/index.ts +++ b/src/frontend/apps/impress/src/hooks/index.ts @@ -1,4 +1,5 @@ export * from './useClipboard'; export * from './useCmdK'; export * from './useDate'; +export * from './useHttpErrorMessages'; export * from './useKeyboardAction'; diff --git a/src/frontend/apps/impress/src/hooks/useHttpErrorMessages.tsx b/src/frontend/apps/impress/src/hooks/useHttpErrorMessages.tsx new file mode 100644 index 000000000..4d488a90d --- /dev/null +++ b/src/frontend/apps/impress/src/hooks/useHttpErrorMessages.tsx @@ -0,0 +1,26 @@ +import { useTranslation } from 'react-i18next'; + +export const useHttpErrorMessages = (status?: number) => { + const { t } = useTranslation(); + + const messages: Record = { + 500: { + title: t('500 - Internal Server Error'), + detail: t('The server met an unexpected condition.'), + }, + 502: { + title: t('502 - Bad Gateway'), + detail: t( + 'The server received an invalid response. Please check your connection and try again.', + ), + }, + 503: { + title: t('503 - Service Unavailable'), + detail: t( + 'The service is temporarily unavailable. Please try again later.', + ), + }, + }; + + return status ? messages[status] : undefined; +}; diff --git a/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx b/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx index cc5b4ad00..9a81fc3b1 100644 --- a/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx +++ b/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx @@ -220,6 +220,7 @@ const DocPage = ({ id }: DocProps) => {