|
1 | 1 | import React from 'react'; |
2 | | -import PageContentBlock from '@/components/elements/PageContentBlock'; |
3 | | -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
4 | | -import { faArrowLeft } from '@fortawesome/free-solid-svg-icons/faArrowLeft'; |
5 | | -import { faSyncAlt } from '@fortawesome/free-solid-svg-icons/faSyncAlt'; |
6 | | -import classNames from 'classnames'; |
7 | 2 | import styled from 'styled-components'; |
| 3 | +import ScreenBlock from '@/components/screens/ScreenBlock'; |
8 | 4 |
|
9 | | -interface BaseProps { |
| 5 | +interface Props { |
10 | 6 | title?: string; |
11 | 7 | message: string; |
12 | 8 | onRetry?: () => void; |
13 | 9 | onBack?: () => void; |
14 | 10 | } |
15 | 11 |
|
16 | | -interface PropsWithRetry extends BaseProps { |
17 | | - onRetry?: () => void; |
18 | | - onBack?: never | undefined; |
19 | | -} |
20 | | - |
21 | | -interface PropsWithBack extends BaseProps { |
22 | | - onBack?: () => void; |
23 | | - onRetry?: never | undefined; |
24 | | -} |
25 | | - |
26 | | -type Props = PropsWithBack | PropsWithRetry; |
27 | | - |
28 | | -const ActionButton = styled.button` |
29 | | - ${tw`rounded-full w-8 h-8 flex items-center justify-center`}; |
30 | | -
|
31 | | - &.hover\\:spin:hover { |
32 | | - animation: spin 2s linear infinite; |
33 | | - } |
34 | | -
|
35 | | - @keyframes spin { |
36 | | - to { |
37 | | - transform: rotate(360deg); |
38 | | - } |
39 | | - } |
40 | | -`; |
41 | | - |
42 | 12 | export default ({ title, message, onBack, onRetry }: Props) => ( |
43 | | - <PageContentBlock> |
44 | | - <div className={'flex justify-center'}> |
45 | | - <div className={'w-full sm:w-3/4 md:w-1/2 p-12 md:p-20 bg-neutral-100 rounded-lg shadow-lg text-center relative'}> |
46 | | - {(typeof onBack === 'function' || typeof onRetry === 'function') && |
47 | | - <div className={'absolute pin-l pin-t ml-4 mt-4'}> |
48 | | - <ActionButton |
49 | | - onClick={() => onRetry ? onRetry() : (onBack ? onBack() : null)} |
50 | | - className={classNames('btn btn-primary', { 'hover:spin': !!onRetry })} |
51 | | - > |
52 | | - <FontAwesomeIcon icon={onRetry ? faSyncAlt : faArrowLeft}/> |
53 | | - </ActionButton> |
54 | | - </div> |
55 | | - } |
56 | | - <img src={'/assets/svgs/server_error.svg'} className={'w-2/3 h-auto select-none'}/> |
57 | | - <h2 className={'mt-6 text-neutral-900 font-bold'}>{title || 'Something went wrong!'}</h2> |
58 | | - <p className={'text-sm text-neutral-700 mt-2'}> |
59 | | - {message} |
60 | | - </p> |
61 | | - </div> |
62 | | - </div> |
63 | | - </PageContentBlock> |
| 13 | + // @ts-ignore |
| 14 | + <ScreenBlock |
| 15 | + title={title || 'Something went wrong'} |
| 16 | + image={'/assets/svgs/server_error.svg'} |
| 17 | + message={message} |
| 18 | + onBack={onBack} |
| 19 | + onRetry={onRetry} |
| 20 | + /> |
64 | 21 | ); |
0 commit comments