Skip to content

Commit 4c30271

Browse files
adding statusbox and converting to class to get local state
2 parents 0378d4a + cbffaf4 commit 4c30271

File tree

6 files changed

+94
-80
lines changed

6 files changed

+94
-80
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
31
# dependencies
42
/node_modules
53
/.pnp
@@ -26,3 +24,5 @@ yarn-error.log*
2624
*.swp
2725
*.swo
2826
*.swn
27+
=======
28+
/node_modules

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "server"]
2+
path = server
3+
url = https://github.com/WordsofDefiance/react-notes-server
4+
[submodule "client"]
5+
path = client
6+
url = https://github.com/WordsofDefiance/react-notes-client

README.md

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,27 @@
1-
# Getting Started with Create React App
1+
# React Notes App
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
## Installation
44

5-
## Available Scripts
5+
Pretty straightforward -- clone, initialize the submodules, install the node modules, start the servers.
66

7-
In the project directory, you can run:
7+
```
8+
git clone https://github.com/WordsofDefiance/react-notes.git
9+
git submodule init && git submodule update
10+
cd client && npm install && cd ../
11+
cd server && npm install && cd ../
12+
```
813

9-
### `npm start`
14+
Next, you will need to start the front-end and back-end servers.
1015

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
16+
To start the back-end server:
17+
```
18+
cd server
19+
npx nodemon server.js
20+
```
1321

14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `npm test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `npm run build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `npm run eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
47-
48-
### Code Splitting
49-
50-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51-
52-
### Analyzing the Bundle Size
53-
54-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55-
56-
### Making a Progressive Web App
57-
58-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59-
60-
### Advanced Configuration
61-
62-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63-
64-
### Deployment
65-
66-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67-
68-
### `npm run build` fails to minify
69-
70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
22+
To start the front-end server:
23+
```
24+
cd client
25+
npm start
26+
```
27+
Once the front-end and the back-end servers are up, you should be able to access the app at http://localhost:3000.

client

Submodule client added at 4ede837

server

Submodule server added at 0a407ec
Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,67 @@
11
import React from 'react'
22
import { Link } from 'react-router-dom'
3+
import { StatusBox } from '../status-box/status-box.component'
34
import './add-note.styles.css'
45

5-
export const AddNote = () => {
6-
return (
7-
<>
8-
<h1>Add Note (To Do)</h1>
9-
<form id="add-note" action='/'>
10-
<input id="title" type='text' placeholder='Enter a Title'></input>
11-
<textarea id="body" placeholder='Enter the note'></textarea>
12-
<button onClick={e => e.preventDefault()} type="submit">ADDING NOTES COMING SOON!</button>
13-
</form>
14-
<Link to='/'>Go Back</Link>
15-
</>
16-
)
17-
18-
}
6+
7+
export class AddNote extends React.Component {
8+
constructor(props) {
9+
super(props);
10+
this.state = {
11+
title: '',
12+
body: '',
13+
status: ''
14+
}
15+
16+
this.handleTitleChange = this.handleTitleChange.bind(this)
17+
this.handleBodyChange = this.handleBodyChange.bind(this)
18+
this.handleSubmit = this.handleSubmit.bind(this)
19+
}
20+
21+
handleTitleChange(event) {
22+
this.setState({title: event.target.value})
23+
}
24+
25+
handleBodyChange(event) {
26+
this.setState({body: event.target.value})
27+
}
28+
29+
handleSubmit(event) {
30+
event.preventDefault()
31+
// Check to see if both title and body are present.
32+
if (this.state.title === '' || this.state.body === '') {
33+
this.setState({status: 'You must fill out both title and body.'})
34+
} else {
35+
this.setState({status: ''})
36+
}
37+
}
38+
39+
render() {
40+
return (
41+
<>
42+
<h1>Add Note (To Do)</h1>
43+
<form id="add-note" onSubmit={this.handleSubmit}>
44+
<input id="title" value={this.state.title} type='text' placeholder='Enter a Title' onChange={this.handleTitleChange}></input>
45+
<textarea onChange={this.handleBodyChange} id="body" placeholder='Enter the note'></textarea>
46+
<button type="submit">ADDING NOTES COMING SOON!</button>
47+
</form>
48+
<StatusBox status={this.state.status}></StatusBox>
49+
{/* <div className="status-box">{this.state.status}</div> */}
50+
<Link to='/'>Go Back</Link>
51+
</>
52+
)
53+
}
54+
}
55+
// export const AddNote = () => {
56+
// return (
57+
// <> // <h1>Add Note (To Do)</h1>
58+
// <form id="add-note" action='/'>
59+
// <input id="title" type='text' placeholder='Enter a Title'></input>
60+
// <textarea id="body" placeholder='Enter the note'></textarea>
61+
// <button onClick={e => e.preventDefault()} type="submit">ADDING NOTES COMING SOON!</button>
62+
// </form>
63+
// <Link to='/'>Go Back</Link>
64+
// </>
65+
// )
66+
67+
// }

0 commit comments

Comments
 (0)