Skip to content

Commit d8d655c

Browse files
committed
♿️(frontend) structure 5xx error alerts
Use h1/p for 500/502/503; pass status from doc and version views.
1 parent fb92a43 commit d8d655c

7 files changed

Lines changed: 65 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to
1313
### Changed
1414

1515
- 💄(frontend) improve comments highlights #1961
16+
- ♿️(frontend) structure correctly 5xx error alerts #2128
1617

1718
## [v4.8.3] - 2026-03-23
1819

src/frontend/apps/impress/src/components/TextErrors.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
44
import styled from 'styled-components';
55

66
import { Box, Text, TextType } from '@/components';
7+
import { useHttpErrorMessages } from '@/hooks';
78

89
const AlertStyled = styled(Alert)`
910
& .c__button--tertiary:hover {
@@ -16,13 +17,15 @@ interface TextErrorsProps extends TextType {
1617
defaultMessage?: string;
1718
icon?: ReactNode;
1819
canClose?: boolean;
20+
status?: number;
1921
}
2022

2123
export const TextErrors = ({
2224
causes,
2325
defaultMessage,
2426
icon,
2527
canClose = false,
28+
status,
2629
...textProps
2730
}: TextErrorsProps) => {
2831
return (
@@ -35,6 +38,7 @@ export const TextErrors = ({
3538
<TextOnlyErrors
3639
causes={causes}
3740
defaultMessage={defaultMessage}
41+
status={status}
3842
{...textProps}
3943
/>
4044
</AlertStyled>
@@ -44,9 +48,39 @@ export const TextErrors = ({
4448
export const TextOnlyErrors = ({
4549
causes,
4650
defaultMessage,
51+
status,
4752
...textProps
4853
}: TextErrorsProps) => {
4954
const { t } = useTranslation();
55+
const httpError = useHttpErrorMessages(status);
56+
57+
if (httpError) {
58+
return (
59+
<Box $direction="column" $gap="0.2rem">
60+
<Text
61+
as="h1"
62+
$theme="error"
63+
$textAlign="center"
64+
$margin="0"
65+
$size="1rem"
66+
$weight="unset"
67+
{...textProps}
68+
>
69+
{httpError.title}
70+
</Text>
71+
<Text
72+
as="p"
73+
$theme="error"
74+
$textAlign="center"
75+
$margin="0"
76+
$size="0.875rem"
77+
{...textProps}
78+
>
79+
{httpError.detail}
80+
</Text>
81+
</Box>
82+
);
83+
}
5084

5185
return (
5286
<Box $direction="column" $gap="0.2rem">

src/frontend/apps/impress/src/features/docs/doc-versioning/components/DocVersionEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const DocVersionEditor = ({
5858
<Box $margin="large" className="--docs--doc-version-editor-error">
5959
<TextErrors
6060
causes={error.cause}
61+
status={error.status}
6162
icon={
6263
error.status === 502 ? (
6364
<Text

src/frontend/apps/impress/src/features/docs/doc-versioning/components/VersionList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const VersionListState = ({
6262
>
6363
<TextErrors
6464
causes={error.cause}
65+
status={error.status}
6566
icon={
6667
error.status === 502 ? (
6768
<Icon iconName="wifi_off" $theme="danger" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './useClipboard';
22
export * from './useCmdK';
33
export * from './useDate';
4+
export * from './useHttpErrorMessages';
45
export * from './useKeyboardAction';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useTranslation } from 'react-i18next';
2+
3+
export const useHttpErrorMessages = (status?: number) => {
4+
const { t } = useTranslation();
5+
6+
const messages: Record<number, { title: string; detail: string }> = {
7+
500: {
8+
title: t('500 - Internal Server Error'),
9+
detail: t('The server met an unexpected condition.'),
10+
},
11+
502: {
12+
title: t('502 - Bad Gateway'),
13+
detail: t(
14+
'The server received an invalid response. Please check your connection and try again.',
15+
),
16+
},
17+
503: {
18+
title: t('503 - Service Unavailable'),
19+
detail: t(
20+
'The service is temporarily unavailable. Please try again later.',
21+
),
22+
},
23+
};
24+
25+
return status ? messages[status] : undefined;
26+
};

src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ const DocPage = ({ id }: DocProps) => {
216216
<Box $margin="large">
217217
<TextErrors
218218
causes={error.cause}
219+
status={error.status}
219220
icon={
220221
error.status === 502 ? (
221222
<Icon iconName="wifi_off" $theme="danger" $withThemeInherited />

0 commit comments

Comments
 (0)