Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 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
c9f5f76
Merge pull request #3 from gbenavid/oauth
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
fa2ecc7
Merge pull request #5 from gbenavid/create-shoping-list
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
fee68bb
Merge pull request #6 from gbenavid/create-shoping-list
Aug 13, 2017
2d08913
only set shoppingListRef if there is a user to avoid null data. Pass …
Aug 14, 2017
98c1a2e
change ref from main root to users uid so users and hold a collection…
Aug 14, 2017
52fb7c4
is this bold? a little experimentation with markdown
Aug 14, 2017
ae86581
add an onClick attr to select button in ShoppingList component
Aug 14, 2017
f714e3f
clean up code in src/NewShoppingList.js
Aug 14, 2017
c2805c5
clean up code in src/App.js
Aug 14, 2017
60960a2
clean up code in src/ShoppingLists.js
Aug 14, 2017
c0bd17b
link src/ShoppingList.js with new function from src/ShoppingLists.js,…
Aug 14, 2017
c29a4a9
create state in src/ShoppingLists.js and add placeholder html in src/…
Aug 14, 2017
57e4211
create a parent element for the show/hide functionality of list items
Aug 14, 2017
c7a8e51
create a component to display all items in list. Bind this to the par…
Aug 14, 2017
69a5792
create a component to create toggle functionality for select button i…
Aug 14, 2017
1d78ff0
clean up code in src/ShoppingLists.js
Aug 14, 2017
c1a6a4d
clean up code and reorganize components
Aug 14, 2017
17791f3
Handle submit is now passing an event through and appending it to the…
Aug 14, 2017
3030bbc
refactor code to follow best practices for passing along props:
Aug 14, 2017
3c8eb40
remove name as a prop
Aug 14, 2017
b8e0c8b
src/ShoppingList.js
Aug 14, 2017
1f4a3d7
implement a attr disbaled on submit button to conditionally allow sub…
Aug 15, 2017
4ba6314
pass down props from ShoppingList to ShowItms to add items to list in…
Aug 15, 2017
89404e4
add loopThroughItemsOnList component for items on a specific list
Aug 15, 2017
4d62fdc
create state in src/ShowItems.js to continuiosly check for the count …
Aug 15, 2017
6d3ef66
remove state from ShowItems
Aug 15, 2017
61f1ff5
import database and add props
Aug 15, 2017
cd6d9cd
add forward slash on database ref
Aug 18, 2017
311b118
Scale back component
Aug 18, 2017
d28e025
tidy up code and add content as prop
Aug 18, 2017
9d9a6bf
create state to continiously check for new items in list
Aug 18, 2017
dfe6da4
tidy code and pass content as props
Aug 18, 2017
bbcbb5c
src/LoopThroughItemsOnList.js
Aug 18, 2017
c957a18
Merge pull request #10 from gbenavid/render-ui-for-list-items
Aug 18, 2017
462220e
add comments to identify bugs
Sep 4, 2017
5a22ec7
why did you comment out the set state in the conditional within toggl…
Sep 5, 2017
d3f27b9
fiddling with code to better understand why it's working
Sep 5, 2017
d4a7d98
was going to add a conditional here but removed it to place it inside…
Sep 5, 2017
37570bd
put items in a li tag & also put a limit on the map to stop looping o…
Sep 5, 2017
7906507
attempting to remove loopThroughListItems by taking a cleaner approac…
Sep 5, 2017
efcad70
add comment to clarify an error/ an attempted solutions
Sep 5, 2017
c3efb16
last attempt to remove the last item in the this.props.content arr
Sep 5, 2017
d7d1afd
i'm now calling toggleItems() with the proper parameters
Sep 5, 2017
22347ac
changed ClickedOn() to be called clicked() instead.
Sep 5, 2017
7bd4c3b
no longer adding an undefined element to properties array in toggleIt…
Sep 5, 2017
ed99476
console logging/ debugging
Sep 5, 2017
8a48368
remove console logs --still debugging
Sep 5, 2017
5644013
dont need to take that approach anymore
Sep 5, 2017
ba23e87
no longer need LoopThroughItemsOnList as a component
Sep 5, 2017
b24384f
removing broken solutiuons
Sep 5, 2017
c95079c
removed LoopThroughItemsOnList
Sep 5, 2017
24ab976
removing loopThroughItemsOnList importation
Sep 5, 2017
d6d9a7d
trying to remove the double loop in toggleItems() function found in S…
Sep 5, 2017
0f02fdf
dont need this comment anymore
Sep 5, 2017
fc2a7ad
brute force solution for not showing dupplicates/ doubling up the lis…
Sep 5, 2017
e44e716
working on a cleaner solution in shoppingList component to hopfully r…
Sep 5, 2017
59be094
clean up some of the redundant comments"
Sep 5, 2017
a711fe1
no longer importing the database because I'm not using it-- no unused…
Sep 5, 2017
720bd86
remove a few of the un-used vars and warnings in react console
Sep 5, 2017
41a4244
only add item to DB if item doesn't exist
Sep 5, 2017
a17c03e
attempting to set the state in display(). Error free so far
Sep 5, 2017
18a4865
reformat code for clarifty
Sep 5, 2017
2d529b2
passing down content so NewItem > handleSubmit() can use it
Sep 5, 2017
9fe4212
attempt to set state in display()
Sep 5, 2017
53a3ef3
in the process of conditional render of listName & content
Sep 5, 2017
421bdf8
remove temp itemsRef prop
Sep 5, 2017
c42b7c8
attempting to render the proper list
Sep 6, 2017
f490cbc
testing the workflow on a new branch added a newline in random file
Sep 6, 2017
51f2b7c
🏡 house cleaning! 🎉 Removing comments that I no longer need
Sep 6, 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
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.wordWrap": "on",
"files.autoSave" : "onWindowChange",
"editor.fontSize": "15"
}
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
55 changes: 46 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
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 });
if (user) {
this.shoppingListsRef = database.ref('/shopping_list').child(user.uid);
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} user={user}
placeholderAttribute={"List name"}
/>
{
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;
16 changes: 16 additions & 0 deletions src/Item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Component, PropTypes } from 'react';

class Item extends Component {
constructor(props) {
super(props);
}
render () {
return (
<section>
"Hello, World".
</section>
);
}
}

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

class NewListItem extends Component {
constructor(props) {
super(props);
this.state = {
itemName: this.props.itemName
};
this.listItemRef = database.ref('/shopping_list').child(this.props.user.uid).child(this.props.appendTo);

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

handleSubmit(event) {
event.preventDefault();
if (!this.props.content.includes(this.state.itemName)) {
this.listItemRef.push({ itemName: this.state.itemName });
}
}

render() {
const { itemName } = this.state;
return (
<form>
<input
type="text"
onChange={ (event)=> this.setState({ itemName: event.target.value })}
/>
<button
onClick={(e) => this.handleSubmit(e)} disabled={!itemName}
>
Submit
</button>
</form>
);
}
}

NewListItem.propTypes = {
shoppingListRef: PropTypes.object
};

export default NewListItem;
44 changes: 44 additions & 0 deletions src/NewShoppingList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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.child(this.props.user.uid).push({name: this.state.name });
}

render() {
const { name } = this.state;
return (
<form>
<input
type="text"
value={ name }
placeholder={this.props.placeholderAttribute}
onChange={(event) => this.setState({ name: event.target.value })}
/>
<button
onClick={this.handleSubmit}
disabled={!name}
>
Submit
</button>
</form>
);
}
}

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

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

class ShoppingList extends Component {
constructor(props){
super(props);
this.state = {
childVisible: false,
newlyAppendedListItems: [],
currentListName: ""
}
this.clicked = this.clicked.bind(this);
}
display(storeItemsArray, ref){
var itemsToBeAdded = [];
ref.on("value", function(snapshot){
for(var i=0; i<snapshot.length-1;i+=1){
var childData = snapshot[i].val().itemName;
console.log(snapshot);
itemsToBeAdded.push(childData);
}
})
}

clicked(key, marketName){
this.setState({childVisible: !this.state.childVisible});
this.setState({currentListName: marketName});
this.props.toggleItems(key, marketName); // sets state of this.props.content
var listRef = database.ref('/shopping_list').child(this.props.user.uid).child(key);
this.display(this.props.content, listRef);
}

render () {
const { name, user, handleDelete, appendTo } = this.props;
const { ref } = database.ref('/shopping_list').child(user.uid).child(appendTo);
return (
<article>
<h3>{ name }</h3>
<button onClick={ handleDelete }> Delete </button>
<button onClick={()=> this.clicked(appendTo, name)}> Select </button>
{
this.state.childVisible ?
<ShowItems user={user}
appendTo={appendTo}
content={this.props.content}
listName={name}
/>
: <span></span>
}
</article>
);
}
}

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

export default ShoppingList;
Loading