-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
f361873
commit 3c99fa1
Showing
7 changed files
with
280 additions
and
2,335 deletions.
There are no files selected for viewing
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
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,63 @@ | ||
import React from "react"; | ||
import propTypes from "prop-types"; | ||
import RaisedButton from "material-ui/RaisedButton"; | ||
import TextField from "material-ui/TextField"; | ||
import uuid from "uuid/v4"; | ||
import FirebaseManager from "../utils/FirebaseManager"; | ||
|
||
class CreateNewmenu extends React.Component { | ||
state = { | ||
name: "", | ||
price: 0, | ||
count: 0 | ||
}; | ||
submit = () => { | ||
console.log("create new cuisine"); | ||
FirebaseManager.createNewCuisine({ ...this.state }).catch(error => | ||
console.log(error) | ||
); | ||
}; | ||
render() { | ||
return ( | ||
<div> | ||
<fieldset>CreateNewmenu</fieldset> | ||
<div> | ||
<lable>菜色名稱</lable> | ||
<TextField | ||
name="name" | ||
defaultValue={this.state.name} | ||
onBlur={e => this.setState({ name: e.target.value })} | ||
/> | ||
</div> | ||
<div> | ||
<lable>價格</lable> | ||
<TextField | ||
type="tel" | ||
name="price" | ||
defaultValue={this.state.price} | ||
onBlur={e => this.setState({ price: e.target.value })} | ||
/> | ||
</div> | ||
<div> | ||
<lable>每份數量</lable> | ||
<TextField | ||
type="tel" | ||
name="count" | ||
defaultValue={this.state.count} | ||
onBlur={e => this.setState({ count: e.target.value })} | ||
/> | ||
</div> | ||
<div> | ||
<RaisedButton | ||
label="新增" | ||
labelPosition="before" | ||
containerElement="label" | ||
onClick={this.submit} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default CreateNewmenu; |
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,45 @@ | ||
import firebase from "firebase"; | ||
import uuid from "uuid/v4"; | ||
import configs from "../config"; | ||
|
||
class FirebaseManagerClass { | ||
constructor(options) { | ||
this.options = options; | ||
firebase.initializeApp(options); | ||
this.provider = new firebase.auth.FacebookAuthProvider(); | ||
this.database = firebase.database(); | ||
this.auth = firebase.auth(); | ||
} | ||
|
||
createNewCuisine(data) { | ||
// return this.database.ref(`cuisine/${uuid()}`).set({ | ||
// ...data | ||
// }); | ||
} | ||
|
||
signInWithPopup = () => { | ||
return this.auth.signInWithPopup(this.provider); | ||
}; | ||
|
||
signInWithEmailAndPassword(account, password) { | ||
return this.auth.signInWithEmailAndPassword(account, password); | ||
} | ||
|
||
createUserWithEmailAndPassword(account, password) { | ||
return this.auth.createUserWithEmailAndPassword(account, password); | ||
} | ||
|
||
signOut = () => { | ||
return this.auth.signOut(); | ||
}; | ||
|
||
createNewCuisine(data) { | ||
return this.database.ref(`cuisine/${uuid()}`).set({ | ||
...data | ||
}); | ||
} | ||
} | ||
|
||
const FirebaseManager = new FirebaseManagerClass(configs.firebaseConfig); | ||
|
||
export default FirebaseManager; |
Oops, something went wrong.