Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1c2c868

Browse files
author
Ivan Franchin
committed
Small adjustments in the Javascript code
1 parent 2cbe678 commit 1c2c868

File tree

7 files changed

+154
-154
lines changed

7 files changed

+154
-154
lines changed

‎book-ui/src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function App() {
1818
<Route path='/' element={<Home />} />
1919
<Route path='/login' element={<Login />} />
2020
<Route path='/signup' element={<Signup />} />
21-
<Route path="/adminpage" element={<PrivateRoute><AdminPage /></PrivateRoute>}/>
22-
<Route path="/userpage" element={<PrivateRoute><UserPage /></PrivateRoute>}/>
23-
<Route path="*" element={<Navigate to="/" />}/>
21+
<Route path="/adminpage" element={<PrivateRoute><AdminPage /></PrivateRoute>}/>
22+
<Route path="/userpage" element={<PrivateRoute><UserPage /></PrivateRoute>}/>
23+
<Route path="*" element={<Navigate to="/" />}/>
2424
</Routes>
2525
</Router>
2626
</AuthProvider>

‎book-ui/src/components/admin/AdminPage.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,29 @@ class AdminPage extends Component {
160160
render() {
161161
if (!this.state.isAdmin) {
162162
return <Navigate to='/' />
163-
} else {
164-
const { isUsersLoading, users, userUsernameSearch, isBooksLoading, books, bookIsbn, bookTitle, bookTextSearch } = this.state
165-
return (
166-
<Container>
167-
<AdminTab
168-
isUsersLoading={isUsersLoading}
169-
users={users}
170-
userUsernameSearch={userUsernameSearch}
171-
handleDeleteUser={this.handleDeleteUser}
172-
handleSearchUser={this.handleSearchUser}
173-
isBooksLoading={isBooksLoading}
174-
books={books}
175-
bookIsbn={bookIsbn}
176-
bookTitle={bookTitle}
177-
bookTextSearch={bookTextSearch}
178-
handleAddBook={this.handleAddBook}
179-
handleDeleteBook={this.handleDeleteBook}
180-
handleSearchBook={this.handleSearchBook}
181-
handleInputChange={this.handleInputChange}
182-
/>
183-
</Container>
184-
)
185163
}
164+
165+
const { isUsersLoading, users, userUsernameSearch, isBooksLoading, books, bookIsbn, bookTitle, bookTextSearch } = this.state
166+
return (
167+
<Container>
168+
<AdminTab
169+
isUsersLoading={isUsersLoading}
170+
users={users}
171+
userUsernameSearch={userUsernameSearch}
172+
handleDeleteUser={this.handleDeleteUser}
173+
handleSearchUser={this.handleSearchUser}
174+
isBooksLoading={isBooksLoading}
175+
books={books}
176+
bookIsbn={bookIsbn}
177+
bookTitle={bookTitle}
178+
bookTextSearch={bookTextSearch}
179+
handleAddBook={this.handleAddBook}
180+
handleDeleteBook={this.handleDeleteBook}
181+
handleSearchBook={this.handleSearchBook}
182+
handleInputChange={this.handleInputChange}
183+
/>
184+
</Container>
185+
)
186186
}
187187
}
188188

‎book-ui/src/components/home/Home.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,36 @@ class Home extends Component {
3737
</Dimmer>
3838
</Segment>
3939
)
40-
} else {
41-
const { numberOfUsers, numberOfBooks } = this.state
42-
return (
43-
<Container text>
44-
<Grid stackable columns={2}>
45-
<Grid.Row>
46-
<Grid.Column textAlign='center'>
47-
<Segment color='blue'>
48-
<Statistic>
49-
<Statistic.Value><Icon name='user' color='grey' />{numberOfUsers}</Statistic.Value>
50-
<Statistic.Label>Users</Statistic.Label>
51-
</Statistic>
52-
</Segment>
53-
</Grid.Column>
54-
<Grid.Column textAlign='center'>
55-
<Segment color='blue'>
56-
<Statistic>
57-
<Statistic.Value><Icon name='book' color='grey' />{numberOfBooks}</Statistic.Value>
58-
<Statistic.Label>Books</Statistic.Label>
59-
</Statistic>
60-
</Segment>
61-
</Grid.Column>
62-
</Grid.Row>
63-
</Grid>
64-
65-
<Image src='https://react.semantic-ui.com/images/wireframe/media-paragraph.png' style={{ marginTop: '2em' }} />
66-
<Image src='https://react.semantic-ui.com/images/wireframe/paragraph.png' style={{ marginTop: '2em' }} />
67-
</Container>
68-
)
6940
}
41+
42+
const { numberOfUsers, numberOfBooks } = this.state
43+
return (
44+
<Container text>
45+
<Grid stackable columns={2}>
46+
<Grid.Row>
47+
<Grid.Column textAlign='center'>
48+
<Segment color='blue'>
49+
<Statistic>
50+
<Statistic.Value><Icon name='user' color='grey' />{numberOfUsers}</Statistic.Value>
51+
<Statistic.Label>Users</Statistic.Label>
52+
</Statistic>
53+
</Segment>
54+
</Grid.Column>
55+
<Grid.Column textAlign='center'>
56+
<Segment color='blue'>
57+
<Statistic>
58+
<Statistic.Value><Icon name='book' color='grey' />{numberOfBooks}</Statistic.Value>
59+
<Statistic.Label>Books</Statistic.Label>
60+
</Statistic>
61+
</Segment>
62+
</Grid.Column>
63+
</Grid.Row>
64+
</Grid>
65+
66+
<Image src='https://react.semantic-ui.com/images/wireframe/media-paragraph.png' style={{ marginTop: '2em' }} />
67+
<Image src='https://react.semantic-ui.com/images/wireframe/paragraph.png' style={{ marginTop: '2em' }} />
68+
</Container>
69+
)
7070
}
7171
}
7272

‎book-ui/src/components/home/Login.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,41 @@ class Login extends Component {
6060
const { isLoggedIn, isError } = this.state
6161
if (isLoggedIn) {
6262
return <Navigate to={'/'} />
63-
} else {
64-
return (
65-
<Grid textAlign='center'>
66-
<Grid.Column style={{ maxWidth: 450 }}>
67-
<Form size='large' onSubmit={this.handleSubmit}>
68-
<Segment>
69-
<Form.Input
70-
fluid
71-
autoFocus
72-
name='username'
73-
icon='user'
74-
iconPosition='left'
75-
placeholder='Username'
76-
onChange={this.handleInputChange}
77-
/>
78-
<Form.Input
79-
fluid
80-
name='password'
81-
icon='lock'
82-
iconPosition='left'
83-
placeholder='Password'
84-
type='password'
85-
onChange={this.handleInputChange}
86-
/>
87-
<Button color='blue' fluid size='large'>Login</Button>
88-
</Segment>
89-
</Form>
90-
<Message>{`Don't have already an account? `}
91-
<a href='/signup' color='teal' as={NavLink} to="/signup">Sign Up</a>
92-
</Message>
93-
{isError && <Message negative>The username or password provided are incorrect!</Message>}
94-
</Grid.Column>
95-
</Grid>
96-
)
9763
}
64+
65+
return (
66+
<Grid textAlign='center'>
67+
<Grid.Column style={{ maxWidth: 450 }}>
68+
<Form size='large' onSubmit={this.handleSubmit}>
69+
<Segment>
70+
<Form.Input
71+
fluid
72+
autoFocus
73+
name='username'
74+
icon='user'
75+
iconPosition='left'
76+
placeholder='Username'
77+
onChange={this.handleInputChange}
78+
/>
79+
<Form.Input
80+
fluid
81+
name='password'
82+
icon='lock'
83+
iconPosition='left'
84+
placeholder='Password'
85+
type='password'
86+
onChange={this.handleInputChange}
87+
/>
88+
<Button color='blue' fluid size='large'>Login</Button>
89+
</Segment>
90+
</Form>
91+
<Message>{`Don't have already an account? `}
92+
<a href='/signup' color='teal' as={NavLink} to="/signup">Sign Up</a>
93+
</Message>
94+
{isError && <Message negative>The username or password provided are incorrect!</Message>}
95+
</Grid.Column>
96+
</Grid>
97+
)
9898
}
9999
}
100100

‎book-ui/src/components/home/Signup.js

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -80,57 +80,57 @@ class Signup extends Component {
8080
const { isLoggedIn, isError, errorMessage } = this.state
8181
if (isLoggedIn) {
8282
return <Navigate to='/' />
83-
} else {
84-
return (
85-
<Grid textAlign='center'>
86-
<Grid.Column style={{ maxWidth: 450 }}>
87-
<Form size='large' onSubmit={this.handleSubmit}>
88-
<Segment>
89-
<Form.Input
90-
fluid
91-
autoFocus
92-
name='username'
93-
icon='user'
94-
iconPosition='left'
95-
placeholder='Username'
96-
onChange={this.handleInputChange}
97-
/>
98-
<Form.Input
99-
fluid
100-
name='password'
101-
icon='lock'
102-
iconPosition='left'
103-
placeholder='Password'
104-
type='password'
105-
onChange={this.handleInputChange}
106-
/>
107-
<Form.Input
108-
fluid
109-
name='name'
110-
icon='address card'
111-
iconPosition='left'
112-
placeholder='Name'
113-
onChange={this.handleInputChange}
114-
/>
115-
<Form.Input
116-
fluid
117-
name='email'
118-
icon='at'
119-
iconPosition='left'
120-
placeholder='Email'
121-
onChange={this.handleInputChange}
122-
/>
123-
<Button color='blue' fluid size='large'>Signup</Button>
124-
</Segment>
125-
</Form>
126-
<Message>{`Already have an account? `}
127-
<a href='/login' color='teal' as={NavLink} to="/login">Login</a>
128-
</Message>
129-
{isError && <Message negative>{errorMessage}</Message>}
130-
</Grid.Column>
131-
</Grid>
132-
)
13383
}
84+
85+
return (
86+
<Grid textAlign='center'>
87+
<Grid.Column style={{ maxWidth: 450 }}>
88+
<Form size='large' onSubmit={this.handleSubmit}>
89+
<Segment>
90+
<Form.Input
91+
fluid
92+
autoFocus
93+
name='username'
94+
icon='user'
95+
iconPosition='left'
96+
placeholder='Username'
97+
onChange={this.handleInputChange}
98+
/>
99+
<Form.Input
100+
fluid
101+
name='password'
102+
icon='lock'
103+
iconPosition='left'
104+
placeholder='Password'
105+
type='password'
106+
onChange={this.handleInputChange}
107+
/>
108+
<Form.Input
109+
fluid
110+
name='name'
111+
icon='address card'
112+
iconPosition='left'
113+
placeholder='Name'
114+
onChange={this.handleInputChange}
115+
/>
116+
<Form.Input
117+
fluid
118+
name='email'
119+
icon='at'
120+
iconPosition='left'
121+
placeholder='Email'
122+
onChange={this.handleInputChange}
123+
/>
124+
<Button color='blue' fluid size='large'>Signup</Button>
125+
</Segment>
126+
</Form>
127+
<Message>{`Already have an account? `}
128+
<a href='/login' color='teal' as={NavLink} to="/login">Login</a>
129+
</Message>
130+
{isError && <Message negative>{errorMessage}</Message>}
131+
</Grid.Column>
132+
</Grid>
133+
)
134134
}
135135
}
136136

‎book-ui/src/components/misc/Helpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const handleLogError = (error) => {
22
if (error.response) {
3-
console.log(error.response.data);
3+
console.log(error.response.data)
44
} else if (error.request) {
5-
console.log(error.request);
5+
console.log(error.request)
66
} else {
7-
console.log(error.message);
7+
console.log(error.message)
88
}
99
}

‎book-ui/src/components/user/UserPage.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ class UserPage extends Component {
6565
render() {
6666
if (!this.state.isUser) {
6767
return <Navigate to='/' />
68-
} else {
69-
const { isBooksLoading, books, bookTextSearch } = this.state
70-
return (
71-
<Container>
72-
<BookList
73-
isBooksLoading={isBooksLoading}
74-
bookTextSearch={bookTextSearch}
75-
books={books}
76-
handleInputChange={this.handleInputChange}
77-
handleSearchBook={this.handleSearchBook}
78-
/>
79-
</Container>
80-
)
8168
}
69+
70+
const { isBooksLoading, books, bookTextSearch } = this.state
71+
return (
72+
<Container>
73+
<BookList
74+
isBooksLoading={isBooksLoading}
75+
bookTextSearch={bookTextSearch}
76+
books={books}
77+
handleInputChange={this.handleInputChange}
78+
handleSearchBook={this.handleSearchBook}
79+
/>
80+
</Container>
81+
)
8282
}
8383
}
8484

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /