@@ -2,25 +2,55 @@ import React from 'react';
22import PageContentBlock from '@/components/elements/PageContentBlock' ;
33import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
44import { faArrowLeft } from '@fortawesome/free-solid-svg-icons/faArrowLeft' ;
5+ import { faSyncAlt } from '@fortawesome/free-solid-svg-icons/faSyncAlt' ;
6+ import classNames from 'classnames' ;
7+ import styled from 'styled-components' ;
58
6- interface Props {
9+ interface BaseProps {
710 title ?: string ;
811 message : string ;
12+ onRetry ?: ( ) => void ;
913 onBack ?: ( ) => void ;
1014}
1115
12- export default ( { title, message, onBack } : Props ) => (
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+ export default ( { title, message, onBack, onRetry } : Props ) => (
1343 < PageContentBlock >
1444 < div className = { 'flex justify-center' } >
1545 < 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' } >
16- { typeof onBack === 'function' &&
46+ { ( typeof onBack === 'function' || typeof onRetry === 'function' ) &&
1747 < div className = { 'absolute pin-l pin-t ml-4 mt-4' } >
18- < button
19- onClick = { ( ) => onBack ( ) }
20- className = { 'rounded-full btn btn-primary w-8 h-8 flex items-center justify-center' }
48+ < ActionButton
49+ onClick = { ( ) => onRetry ? onRetry ( ) : ( onBack ? onBack ( ) : null ) }
50+ className = { classNames ( ' btn btn-primary' , { 'hover:spin' : ! ! onRetry } ) }
2151 >
22- < FontAwesomeIcon icon = { faArrowLeft } />
23- </ button >
52+ < FontAwesomeIcon icon = { onRetry ? faSyncAlt : faArrowLeft } />
53+ </ ActionButton >
2454 </ div >
2555 }
2656 < img src = { '/assets/svgs/server_error.svg' } className = { 'w-2/3 h-auto select-none' } />
0 commit comments