|
1 | 1 | import React, {useState, useEffect} from 'react';
|
2 | 2 | import {matchType} from '../../types';
|
3 |
| -import { |
4 |
| - Grid, |
5 |
| - Box, |
6 |
| - Button, |
7 |
| - Snackbar, |
8 |
| - Icon, |
9 |
| - IconButton, |
10 |
| -} from '@material-ui/core'; |
| 3 | +import {Grid} from '@material-ui/core'; |
11 | 4 |
|
12 | 5 | import axios from 'axios';
|
13 | 6 |
|
14 | 7 | import ArticlePlaceholder from './placeholders/ArticlePlaceholder';
|
| 8 | +import ErrorResult from './ErrorResult'; |
15 | 9 | import FloatingButton from '../../components/FloatingButton.jsx';
|
16 | 10 | import ArticleHeader from './ArticleHeader';
|
17 | 11 | import ArticleContent from './ArticleContent';
|
18 | 12 | import ArticleComments from './ArticleComments';
|
19 | 13 | import ArticleFooter from './ArticleFooter';
|
20 | 14 |
|
21 |
| -import {ArticleContainer} from './styles'; |
| 15 | +import {ArticleContainer, ArticleTextContentErrorResultContainer} from './styles'; |
22 | 16 |
|
23 | 17 | const Article = (props) => {
|
24 | 18 | const {match} = props;
|
@@ -54,104 +48,20 @@ const Article = (props) => {
|
54 | 48 | <ArticlePlaceholder />
|
55 | 49 | </ArticleContainer>
|
56 | 50 | }
|
57 |
| - { !isLoading && |
| 51 | + { !isLoading && !isError && |
58 | 52 | <Grid item xs={12} className="article-content">
|
59 | 53 | <ArticleHeader article={article}/>
|
60 | 54 | <ArticleContent article={article} />
|
61 | 55 | <ArticleFooter />
|
62 | 56 | <ArticleComments />
|
63 | 57 | </Grid>
|
64 | 58 | }
|
65 |
| - { isError && !isLoading && |
66 |
| - <ArticleContainer> |
67 |
| - <Box display="flex" flexDirection="column" justifyContent="center" alignItems="center" height="100vh"> |
68 |
| - <Box display="flex" alignItems="baseline" justifyContent="center" flexDirection="column" p={2}> |
69 |
| - <Box display="flex" alignItems="center" justifyContent="center"> |
70 |
| - <Box display="flex" justifyContent="center" alignItems="center" className="error-icon-area"> |
71 |
| - <Icon color="secondary" className="error-icon">healing</Icon> |
72 |
| - </Box> |
73 |
| - <Box display="flex" justifyContent="center" alignItems="center"> |
74 |
| - <h2 className="message-error"> |
75 |
| - {isError ? |
76 |
| - 'Artigo não encontrado, acredita que houve um problema? Clique no botão rosa para nos comunicar =D' : |
77 |
| - 'Ops, ocorreu um erro ao recuperar seu artigo. Já tentou atualizar a página?'} |
78 |
| - </h2> |
79 |
| - </Box> |
80 |
| - </Box> |
81 |
| - <Box display="flex" flexDirection="column" width="100%" mt={3}> |
82 |
| - <Button color="secondary" fullWidth variant="outlined" onClick={() => window.location.reload()}>Atualizar página</Button> |
83 |
| - </Box> |
84 |
| - <Box display="flex" flexDirection="column" width="100%" mt={3}> |
85 |
| - <Button |
86 |
| - color="secondary" |
87 |
| - fullWidth |
88 |
| - variant="contained" |
89 |
| - onClick={() => window.location.href = '/sobre#contact'} |
90 |
| - > |
91 |
| - Reportar bug |
92 |
| - </Button> |
93 |
| - </Box> |
94 |
| - </Box> |
95 |
| - </Box> |
96 |
| - </ArticleContainer> |
| 59 | + { isError && |
| 60 | + <ArticleTextContentErrorResultContainer> |
| 61 | + <ErrorResult visible={isError} message="Ops, parece que ocorreu um erro inesperado, tente atualizar a página, se persistir reporte"/> |
| 62 | + </ArticleTextContentErrorResultContainer> |
97 | 63 | }
|
98 | 64 | <FloatingButton action={() => window.scrollTo(0, 0)}/>
|
99 |
| - <Snackbar |
100 |
| - anchorOrigin={{ |
101 |
| - vertical: 'bottom', |
102 |
| - horizontal: 'left', |
103 |
| - }} |
104 |
| - open={false} |
105 |
| - autoHideDuration={6000} |
106 |
| - onClose={null} |
107 |
| - ContentProps={{ |
108 |
| - 'aria-describedby': 'message-id', |
109 |
| - }} |
110 |
| - message={<span id="message-id">Comentário enviado, em 24 horas ele estará publico para outros usuários</span>} |
111 |
| - action={[ |
112 |
| - <Button key="undo" color="secondary" size="small" onClick={null}> |
113 |
| - Fechar |
114 |
| - </Button>, |
115 |
| - <IconButton |
116 |
| - key="close" |
117 |
| - aria-label="close" |
118 |
| - color="inherit" |
119 |
| - onClick={null} |
120 |
| - > |
121 |
| - <Box ml={1}> |
122 |
| - <Icon>clear</Icon> |
123 |
| - </Box> |
124 |
| - </IconButton>, |
125 |
| - ]} |
126 |
| - /> |
127 |
| - <Snackbar |
128 |
| - anchorOrigin={{ |
129 |
| - vertical: 'bottom', |
130 |
| - horizontal: 'left', |
131 |
| - }} |
132 |
| - open={Boolean(false)} |
133 |
| - autoHideDuration={6000} |
134 |
| - onClose={null} |
135 |
| - ContentProps={{ |
136 |
| - 'aria-describedby': 'message-id', |
137 |
| - }} |
138 |
| - message={<span id="message-id">{''}</span>} |
139 |
| - action={[ |
140 |
| - <Button key="undo" color="secondary" size="small" onClick={null}> |
141 |
| - Fechar |
142 |
| - </Button>, |
143 |
| - <IconButton |
144 |
| - key="close" |
145 |
| - aria-label="close" |
146 |
| - color="inherit" |
147 |
| - onClick={null} |
148 |
| - > |
149 |
| - <Box ml={1}> |
150 |
| - <Icon>clear</Icon> |
151 |
| - </Box> |
152 |
| - </IconButton>, |
153 |
| - ]} |
154 |
| - /> |
155 | 65 | </ArticleContainer>
|
156 | 66 | );
|
157 | 67 | };
|
|
0 commit comments