-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,043 additions
and
324 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
// These are your firebase security rules - put them in the "Security & Rules" tab of your database | ||
{ | ||
"rules": { | ||
// won't let people delete an existing room | ||
".write": "!data.exists()", | ||
".read": true, | ||
"$room" : { | ||
// only the store owner can edit the data | ||
".write" : "auth != null && (!data.exists() || data.child('owner').val() === auth.uid)", | ||
".read" : true | ||
} | ||
"rules": { | ||
// won't let people delete an existing room | ||
".write": "!data.exists()", | ||
".read": true, | ||
"$room": { | ||
// only the store owner can edit the data | ||
".write": | ||
"auth != null && (!data.exists() || data.child('owner').val() === auth.uid)", | ||
".read": true | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Rebase from "re-base"; | ||
import firebase from "firebase"; | ||
|
||
const firebaseApp = firebase.initializeApp({ | ||
apiKey: "AIzaSyDXUCNSpi5u07F76httlCTXAA4mPVQlEHs", | ||
authDomain: "catch-of-the-day-wes-bos-2.firebaseapp.com", | ||
databaseURL: "https://catch-of-the-day-wes-bos-2.firebaseio.com" | ||
}); | ||
|
||
const base = Rebase.createClass(firebaseApp.database()); | ||
|
||
// This is a named export | ||
export { firebaseApp }; | ||
|
||
// this is a default export | ||
export default base; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
class AddFishForm extends React.Component { | ||
nameRef = React.createRef(); | ||
priceRef = React.createRef(); | ||
statusRef = React.createRef(); | ||
descRef = React.createRef(); | ||
imageRef = React.createRef(); | ||
|
||
static propTypes = { | ||
addFish: PropTypes.func | ||
}; | ||
|
||
createFish = event => { | ||
// 1. stop the form from submitting | ||
event.preventDefault(); | ||
const fish = { | ||
name: this.nameRef.value.value, | ||
price: parseFloat(this.priceRef.value.value), | ||
status: this.statusRef.value.value, | ||
desc: this.descRef.value.value, | ||
image: this.imageRef.value.value | ||
}; | ||
this.props.addFish(fish); | ||
// refresh the form | ||
event.currentTarget.reset(); | ||
}; | ||
render() { | ||
return ( | ||
<form className="fish-edit" onSubmit={this.createFish}> | ||
<input name="name" ref={this.nameRef} type="text" placeholder="Name" /> | ||
<input | ||
name="price" | ||
ref={this.priceRef} | ||
type="text" | ||
placeholder="Price" | ||
/> | ||
<select name="status" ref={this.statusRef}> | ||
<option value="available">Fresh!</option> | ||
<option value="unavailable">Sold Out!</option> | ||
</select> | ||
|
||
<textarea name="desc" ref={this.descRef} placeholder="Desc" /> | ||
<input | ||
name="image" | ||
ref={this.imageRef} | ||
type="text" | ||
placeholder="Image" | ||
/> | ||
<button type="submit">+ Add Fish</button> | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
export default AddFishForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
class EditFishForm extends React.Component { | ||
static propTypes = { | ||
fish: PropTypes.shape({ | ||
image: PropTypes.string, | ||
name: PropTypes.string, | ||
desc: PropTypes.string, | ||
status: PropTypes.string, | ||
price: PropTypes.number | ||
}), | ||
index: PropTypes.string, | ||
updateFish: PropTypes.func | ||
}; | ||
handleChange = event => { | ||
console.log(event.currentTarget.value); | ||
// update that fish | ||
// 1. Take a copy of the curernt fish | ||
const updatedFish = { | ||
...this.props.fish, | ||
[event.currentTarget.name]: event.currentTarget.value | ||
}; | ||
this.props.updateFish(this.props.index, updatedFish); | ||
}; | ||
render() { | ||
return ( | ||
<div className="fish-edit"> | ||
<input | ||
type="text" | ||
name="name" | ||
onChange={this.handleChange} | ||
value={this.props.fish.name} | ||
/> | ||
<input | ||
type="text" | ||
name="price" | ||
onChange={this.handleChange} | ||
value={this.props.fish.price} | ||
/> | ||
<select | ||
type="text" | ||
name="status" | ||
onChange={this.handleChange} | ||
value={this.props.fish.status} | ||
> | ||
<option value="available">Fresh!</option> | ||
<option value="unavailable">Sold Out!</option> | ||
</select> | ||
<textarea | ||
name="desc" | ||
onChange={this.handleChange} | ||
value={this.props.fish.desc} | ||
/> | ||
<input | ||
type="text" | ||
name="image" | ||
onChange={this.handleChange} | ||
value={this.props.fish.image} | ||
/> | ||
<button onClick={() => this.props.deleteFish(this.props.index)}> | ||
Remove Fish | ||
</button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default EditFishForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { formatPrice } from "../helpers"; | ||
|
||
class Fish extends React.Component { | ||
static propTypes = { | ||
details: PropTypes.shape({ | ||
image: PropTypes.string, | ||
name: PropTypes.string, | ||
desc: PropTypes.string, | ||
status: PropTypes.string, | ||
price: PropTypes.number | ||
}), | ||
addToOrder: PropTypes.func | ||
}; | ||
render() { | ||
const { image, name, price, desc, status } = this.props.details; | ||
const isAvailable = status === "available"; | ||
return ( | ||
<li className="menu-fish"> | ||
<img src={image} alt={name} /> | ||
<h3 className="fish-name"> | ||
{name} | ||
<span className="price">{formatPrice(price)}</span> | ||
</h3> | ||
<p>{desc}</p> | ||
<button | ||
disabled={!isAvailable} | ||
onClick={() => this.props.addToOrder(this.props.index)} | ||
> | ||
{isAvailable ? "Add To Order" : "Sold Out!"} | ||
</button> | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
export default Fish; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.