|
1 | 1 | import React, { Component } from "react";
|
2 | 2 |
|
| 3 | +import { Form, Button } from "react-bootstrap"; |
| 4 | +import Navbar from "../../Navbar"; |
| 5 | + |
3 | 6 | 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 | + |
4 | 42 | render() {
|
5 | 43 | return (
|
6 | 44 | <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> |
14 | 81 | </div>
|
15 | 82 | );
|
16 | 83 | }
|
|
0 commit comments