Skip to content

Commit 713ce17

Browse files
committed
add new book temp added
1 parent 9283171 commit 713ce17

File tree

2 files changed

+84
-8
lines changed

2 files changed

+84
-8
lines changed

src/components/HomePage/AddBook/index.js

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,83 @@
11
import React, { Component } from "react";
22

3+
import { Form, Button } from "react-bootstrap";
4+
import Navbar from "../../Navbar";
5+
36
export default class AddBook extends Component {
7+
constructor() {
8+
super();
9+
10+
this.state = {
11+
booknameValue: "",
12+
bookpriceValue: 0,
13+
bookcoverValue: ""
14+
};
15+
}
16+
17+
onChange = e => {
18+
this.setState({
19+
[e.target.name]: e.target.value
20+
});
21+
};
22+
23+
onSubmit = e => {
24+
e.preventDefault();
25+
const { booknameValue, bookpriceValue, bookcoverValue } = this.state;
26+
const book = {
27+
booknameValue,
28+
bookpriceValue,
29+
bookcoverValue
30+
};
31+
32+
//snail adding to db here
33+
34+
this.setState({
35+
bookpublisherValue: "",
36+
booknameValue: "",
37+
bookpriceValue: 0,
38+
bookcoverValue: ""
39+
});
40+
};
41+
442
render() {
543
return (
644
<div>
7-
<div className="addbook-title">Add a new Book</div>
8-
<form>
9-
<label>Book Name</label>
10-
<input type="text" />
11-
<label>Price</label>
12-
<input type="number" />
13-
</form>
45+
<div className="nav-bar">
46+
<Navbar />
47+
</div>
48+
<div className="main-content container" style={{ paddingTop: "40px" }}>
49+
<div className="addbook-title">
50+
<h1>Add a new Book</h1>
51+
</div>
52+
<div className="addbook-form-container" style={{ marginTop: "30px" }}>
53+
<Form>
54+
<Form.Group>
55+
<Form.Label>Book Name</Form.Label>
56+
<Form.Control
57+
type="text"
58+
placeholder="Enter the name of document"
59+
onChange={this.onChange}
60+
/>
61+
</Form.Group>
62+
63+
<Form.Group>
64+
<Form.Label>Price</Form.Label>
65+
<Form.Control type="number" onChange={this.onChange} />
66+
</Form.Group>
67+
<Form.Group>
68+
<Form.Label>Book cover url</Form.Label>
69+
<Form.Control
70+
type="text"
71+
placeholder="add a url link of book cover"
72+
onChange={this.onChange}
73+
/>
74+
</Form.Group>
75+
<Button variant="dark" type="submit">
76+
Submit
77+
</Button>
78+
</Form>
79+
</div>
80+
</div>
1481
</div>
1582
);
1683
}

src/components/HomePage/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from "react";
22
import Navbar from "../Navbar";
33

44
import BookList from "./BookList";
5+
import { Button } from "react-bootstrap";
56

67
class HomePage extends Component {
78
render() {
@@ -10,8 +11,16 @@ class HomePage extends Component {
1011
<div className="nav-bar">
1112
<Navbar />
1213
</div>
14+
1315
<div className="main-content container" style={{ paddingTop: "40px" }}>
14-
<BookList />
16+
<div className="addbook-container">
17+
<Button href="/add" variant="dark">
18+
Add New Book
19+
</Button>
20+
</div>
21+
<div className="booklist-container" style={{ marginTop: "20px" }}>
22+
<BookList />
23+
</div>
1524
</div>
1625
</div>
1726
);

0 commit comments

Comments
 (0)