Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9413d46
add firebase ^3.6.10 as a dependency in package.json file
Aug 12, 2017
91c37ff
create a firebase file to import firebase SDK, initialize app with ne…
Aug 12, 2017
b6b38e1
import the SDK itself, add web setup from firebase with API key
Aug 12, 2017
9f34441
export the configured version of firebase in firebase.js.
Aug 12, 2017
7651b08
export an instance of the database using a const
Aug 12, 2017
b6bd716
import firebase in App.js, create a constructor in App.js.
Aug 12, 2017
636dbd7
add a code snippet to help reader run this app locally.
Aug 12, 2017
337b63c
add some additional info on README --App url must be set up in config…
Aug 12, 2017
c93aca3
export firebase auth
Aug 12, 2017
48ea406
export Google Auth providers
Aug 12, 2017
4eda25e
rearragne code for clarity
Aug 12, 2017
e765b0c
create a new file for code that pertains to the current user
Aug 12, 2017
6e69a0b
add proptypes for current user
Aug 12, 2017
a6db775
export instance of github auth
Aug 12, 2017
cdb399c
fix capitolization error in Github const.
Aug 12, 2017
bfef202
add file for signin component
Aug 12, 2017
2dafb88
import react into Signin component.
Aug 12, 2017
164180c
import google auth from firebase to signin
Aug 12, 2017
193720b
create button for signins
Aug 12, 2017
f2189d1
render sigin component on main page
Aug 12, 2017
df8a1ae
Conditionally show signin/signout button based on component state.
Aug 12, 2017
3e51eb1
Add a display name to be shown. Also add a signout button for current…
Aug 12, 2017
eb0721b
add anonymous auth provider in firebase and export
Aug 12, 2017
e04ba67
update readme to notify users and developers that this repo is still …
Aug 12, 2017
90e8384
support anonymous logins
Aug 12, 2017
a081934
support google logins
Aug 12, 2017
f3a1c3c
add static sign in with email button.
Aug 12, 2017
383434e
remove email requirement for guest users
Aug 12, 2017
7166132
clean up code
Aug 12, 2017
ee01119
fix spelling error
Aug 12, 2017
db2bf29
remove email login
Aug 12, 2017
902617c
remove static button
Aug 12, 2017
5631600
Change HTML to personalize the expereince
Aug 12, 2017
006b12f
create a newShoppingList Component. Connect it to firebase and push d…
Aug 12, 2017
c76aab0
remove the importation of databse into App.js
Aug 12, 2017
d6312e7
Add a file for NewShoppingList component. Implement a handle submit f…
Aug 13, 2017
c2e4887
import map from lodash
Aug 13, 2017
c353b52
a user can now view all of their shopping lists.
Aug 13, 2017
efa0db3
add file for ShoppingList component. Import shoppingList component in…
Aug 13, 2017
45b4167
pass locals into shoppingLists component.
Aug 13, 2017
950778c
create a ShoppingList component/ file to display specific actions and…
Aug 13, 2017
c63bfe6
users can now delete a list from their account
Aug 13, 2017
2e10ebd
update readme with info about cool new feature + add cute emojis to e…
Aug 13, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
# Bag-It-Up!

#### Stage: Development

## Overview/ Summary
This is a web-based application. It's main functionality is to help users track their shopping needs.
This is a web-based application. It's main functionality is to help users track their shopping needs.

# Features
* *Oauth*: Github, Gmail/ Google, Email, Anonymous/ Guest user login is supported by this app.
* *Create a list* to help you track your shopping needs!
* *Add items* to your list
* *Remove items* from your list
* See the *price* (USD)
* View the *grand total* of all your items combined
* *Buy your items in bulk!* (Want more than one? ⏤we got you 🍫🍪🍰🍟🍦🍕🍮🎂🍭🌮)
* **Oauth**: Github, Gmail/ Google, Anonymous/ Guest user login is supported by this app.
* **Create a list** to help you track your shopping needs!
* **Remove a list from your account**
* **Add items** to your list
* **Remove items** from your list
* See the **prices listed** (USD)
* View the **grand total** of all your items combined
* **Buy your items in bulk!** (Want more than one? ⏤we got you 🍫🍪🍰🍟🍦🍕🍮🎂🍭🌮)


# Prerequisites
You must have [node installed](https://nodejs.org/en/) in your machine.

To begin [fork the repository](https://help.github.com/articles/fork-a-repo/#platform-linux).

Next navigate into the folder and run npm install. This will install all the dependencies that you will need for this project.
```
cd bag-it-up
npm install
```
# Languages/ Stack
* Javascript
* React.js
* Firebase
* ☕️ Javascript ☕️
* 💥 React.js 💥
* 🔥 Firebase 🔥


This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-scripts": "1.0.11"
"react-scripts": "1.0.11",
"firebase": "^3.6.10"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>BagItUp</title>
</head>
<body>
<noscript>
Expand Down
54 changes: 45 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { auth, database } from './firebase';
import CurrentUser from './CurrentUser';
import SignIn from './Signin';
import NewShoppingList from './NewShoppingList';
import ShoppingLists from './ShoppingLists'

class App extends Component {
constructor(props){
super(props);
this.shoppingListsRef = null;
this.state = {
user: null
};

}

componentDidMount() {
auth.onAuthStateChanged((user) => {
this.setState({ user });

this.shoppingListsRef = database.ref('shopping_list');
this.shoppingListsRef.on('value', (snapshot) => {
this.setState({ shoppingLists: snapshot.val() })
});
})
}

render() {
const { user, shoppingLists } = this.state;
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
<div>
<div>
<h2>Bag It Up!</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<div>
{ user
? <div>
<NewShoppingList
shoppingListsRef={this.shoppingListsRef}
/>
{
shoppingLists &&
<ShoppingLists shoppingLists={shoppingLists} user={user} shoppingListsRef={this.shoppingListsRef}/>
}
<CurrentUser user={user} />
</div>
: <SignIn />
}

</div>
</div>
);
}
Expand Down
24 changes: 24 additions & 0 deletions src/CurrentUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { PropTypes } from 'react';
import { auth } from './firebase';

const CurrentUser = ({ user }) => {
return (
<div>
{ user.displayName } <br/>
<button onClick={ () => auth.signOut() }>
Sign Out
</button>
</div>
);
}

CurrentUser.propTypes = {
user: PropTypes.shape({
displayName: PropTypes.string,
email: PropTypes.string,
photoURL: PropTypes.string,
uid: PropTypes.string.isRequired
})
}

export default CurrentUser;
45 changes: 45 additions & 0 deletions src/NewShoppingList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { Component, PropTypes } from 'react';
import { database } from './firebase';

class NewShoppingList extends Component {
constructor() {
super();
this.state = {
name: ''
};
this.shoppingListRef = database.ref('/shopping_list');
this.handleSubmit = this.handleSubmit.bind(this);
}

handleSubmit(event) {
event.preventDefault();
this.shoppingListRef.push({name: this.state.name });
}

render() {
const { name } = this.state;

return (
<form>
<input
type="text"
value={ name }
placeholder="Name of List"
onChange={(event) => this.setState({ name: event.target.value })}
/>
<button
onClick={this.handleSubmit}
disabled={!name}
>
Submit
</button>
</form>
);
}
}

NewShoppingList.propTypes = {
restaurantsRef: PropTypes.object
};

export default NewShoppingList;
22 changes: 22 additions & 0 deletions src/ShoppingList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Component, PropTypes } from 'react';

class ShoppingList extends Component {
render () {
const { name, user, handleDelete } = this.props;
return (
<article>
<h3>{ name }</h3>
<button onClick={handleDelete} >Delete</button>
<button>Select</button>
</article>
);
}
}

ShoppingList.propTypes = {
name: PropTypes.string.isRequired,
user: PropTypes.object,
handleDelete: PropTypes.func.isRequired
};

export default ShoppingList;
40 changes: 40 additions & 0 deletions src/ShoppingLists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { Component, PropTypes } from 'react';
import { database } from './firebase';
import ShoppingList from './ShoppingList';
import map from 'lodash/map';

class ShoppingLists extends Component {
constructor(props) {
super(props);

this.handleDelete = this.handleDelete.bind(this);
}


handleDelete(key) {
const { shoppingListsRef, user } = this.props;

shoppingListsRef.child(key).remove();
}

render () {
const { shoppingLists, user } = this.props;
return (
<section>
{ map(shoppingLists, (shoppingList, key) => (
<ShoppingList key={key} user={user} {...shoppingList}
handleDelete={ () => this.handleDelete(key)}
/>
)) }
</section>
);
}
}

ShoppingLists.propTypes = {
user: PropTypes.object,
shoppingListsRef: PropTypes.object.isRequired,
shoppingLists: PropTypes.object
};

export default ShoppingLists;
22 changes: 22 additions & 0 deletions src/Signin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Component } from 'react';
import { auth, googleAuthProvider, githubAuthProvider} from './firebase';

class SignIn extends Component {
render() {
return (
<div className="SignIn">
<button onClick={()=> auth.signInWithRedirect(githubAuthProvider)}>
Sign In with Github
</button>
<button onClick={()=> auth.signInAnonymously() }>
Sign In as a guest
</button>
<button onClick={()=> auth.signInWithRedirect(googleAuthProvider)}>
Sign In with Google
</button>
</div>
)
}
}

export default SignIn;
19 changes: 19 additions & 0 deletions src/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import firebase from 'firebase';

const config = {
apiKey: "AIzaSyAJDuGvzzynalAwH23Lxh8F9tYBZnFjXu0",
authDomain: "bag-it-up-49697.firebaseapp.com",
databaseURL: "https://bag-it-up-49697.firebaseio.com",
projectId: "bag-it-up-49697",
storageBucket: "",
messagingSenderId: "484536466087"
};
firebase.initializeApp(config);

export default firebase;

export const database = firebase.database();
export const auth = firebase.auth();
export const googleAuthProvider = new firebase.auth.GoogleAuthProvider();
export const githubAuthProvider = new firebase.auth.GithubAuthProvider();