File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default class Main extends Component {
9
9
state = {
10
10
repositoryInput : '' ,
11
11
repositories : [ ] ,
12
+ repositoryError : false ,
12
13
} ;
13
14
14
15
handleAddRepository = async ( e ) => {
@@ -20,11 +21,12 @@ export default class Main extends Component {
20
21
repository . lastCommit = moment ( repository . pushed_at ) . fromNow ( ) ;
21
22
22
23
this . setState ( state => ( {
24
+ repositoryError : false ,
23
25
repositoryInput : '' ,
24
26
repositories : [ ...state . repositories , repository ] ,
25
27
} ) ) ;
26
28
} catch ( error ) {
27
- console . log ( error ) ;
29
+ this . setState ( { repositoryError : true } ) ;
28
30
}
29
31
} ;
30
32
@@ -33,7 +35,7 @@ export default class Main extends Component {
33
35
< Container >
34
36
< img src = { Logo } alt = "Github Compare" />
35
37
36
- < Form onSubmit = { this . handleAddRepository } >
38
+ < Form withError = { this . state . repositoryError } onSubmit = { this . handleAddRepository } >
37
39
< input
38
40
type = "text"
39
41
placeholder = "usuário/repositório"
Original file line number Diff line number Diff line change @@ -18,10 +18,11 @@ export const Form = styled.form`
18
18
height: 55px;
19
19
padding: 0 20px;
20
20
background: #fff;
21
- border: 0;
22
21
font-size: 18px;
23
22
color: #444;
24
23
border-radius: 3px;
24
+
25
+ border: ${ props => ( props . withError ? '2px solid #f00' : 0 ) } ;
25
26
}
26
27
27
28
button {
You can’t perform that action at this time.
0 commit comments