-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathOops.tsx
More file actions
49 lines (40 loc) · 1.1 KB
/
Oops.tsx
File metadata and controls
49 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { type FC, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { Button } from '@primer/react';
import { EmojiSplash } from './layout/EmojiSplash';
import type { GitifyError } from '../types';
import { Errors } from '../utils/core/errors';
import { randomElement } from '../utils/core/random';
interface OopsProps {
error: GitifyError;
fullHeight?: boolean;
}
export const Oops: FC<OopsProps> = ({
error,
fullHeight = true,
}: OopsProps) => {
const err = error ?? Errors.UNKNOWN;
const navigate = useNavigate();
const emoji = useMemo(() => randomElement(err.emojis), [err]);
const actions = err.actions?.length
? err.actions.map((action) => (
<Button
key={action.route}
leadingVisual={action.icon}
onClick={() => navigate(action.route)}
variant={action.variant}
>
{action.label}
</Button>
))
: null;
return (
<EmojiSplash
actions={actions}
emoji={emoji}
fullHeight={fullHeight}
heading={err.title}
subHeadings={err.descriptions}
/>
);
};