-
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
b1f5bae
commit 45038b1
Showing
15 changed files
with
232 additions
and
182 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
# 參與人員 | ||
|
||
* [Polo](https://github.com/polo13999) | ||
* [Tomas](https://github.com/horsekitlin) | ||
* [Polo](https://github.com/polo13999) | ||
* [Tomas](https://github.com/horsekitlin) | ||
|
||
# config schema | ||
|
||
```json | ||
export config = { | ||
"firebaseConfig": { | ||
"apiKey": "string", | ||
"authDomain": "string", | ||
"databaseURL": "string", | ||
"storageBucket": "string", | ||
"messagingSenderId": "string", | ||
"projectId": "string" | ||
} | ||
configs/initialConfig.js | ||
|
||
```javascript | ||
export const initialAdmin = { | ||
logo: | ||
"http://play.nownews.com/wp-content/uploads/2017/08/5995a97ec6113d46af747352_201708172234-768x640.jpg", | ||
email: "[email protected]", | ||
password: "yourpassword", | ||
name: "admin", | ||
company: "哈囉世界股份有限公司", | ||
isAdmin: true | ||
}; | ||
|
||
export const firebaseConfig = { | ||
apiKey: "string", | ||
authDomain: "string", | ||
databaseURL: "string", | ||
storageBucket: "string", | ||
messagingSenderId: "string", | ||
projectId: "string" | ||
}; | ||
|
||
export const storeKeys = { | ||
auth: "_authoration" | ||
}; | ||
``` | ||
``` |
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 |
---|---|---|
@@ -1,72 +1,38 @@ | ||
import React, { PureComponent } from "react"; | ||
import propTypes from "prop-types"; | ||
import React from "react"; | ||
import AppBar from "material-ui/AppBar"; | ||
import { Grid, Row } from "react-flexbox-grid"; | ||
import FirebaseManager from "../../utils/FirebaseManager"; | ||
import RightIconButton from "./RightIconButton"; | ||
import IconButton from "material-ui/IconButton"; | ||
import LoginScene from "../../containers/Login"; | ||
import Sidebar from "../utils/Sidebar"; | ||
|
||
class AuthWrapper extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
sidebar: false | ||
}; | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
const { auth, match } = this.props; | ||
const isAuth = auth.get("isAuth"); | ||
const nextAuth = nextProps.auth.get("isAuth"); | ||
|
||
if (nextAuth !== isAuth && isAuth === false) { | ||
this.props.goTo("/"); | ||
} | ||
} | ||
componentDidMount() { | ||
const { auth, match } = this.props; | ||
const isAuth = auth.get("isAuth"); | ||
if (isAuth === false) { | ||
this.props.goTo("/"); | ||
} | ||
} | ||
render() { | ||
const { auth } = this.props; | ||
|
||
return ( | ||
<Grid fluid> | ||
<AppBar | ||
title="訂便當" | ||
onLeftIconButtonClick={() => { | ||
if (FirebaseManager.user) { | ||
this.setState({ sidebar: true }); | ||
} | ||
}} | ||
iconElementLeft={ | ||
<IconButton | ||
tooltipPosition="bottom-left" | ||
iconClassName="fa fa-bars" | ||
/> | ||
} | ||
iconElementRight={ | ||
<RightIconButton | ||
logout={this.logout} | ||
setLoginModal={() => this.setState({ LoginModal: true })} | ||
isAuth={auth.get("isAuth")} | ||
LOGON={auth.get("LOGON")} | ||
user={auth.get("user")} | ||
/> | ||
} | ||
/> | ||
<Row>{this.props.children}</Row> | ||
<Sidebar | ||
openSidebar={() => this.setState({ sidebar: false })} | ||
isOpen={this.state.sidebar} | ||
/> | ||
</Grid> | ||
); | ||
} | ||
} | ||
const AuthWrapper = props => { | ||
const { auth } = props; | ||
console.log(auth.toObject()); | ||
return !auth.get("isAuth") ? ( | ||
<LoginScene auth={auth} /> | ||
) : ( | ||
<Grid fluid> | ||
<AppBar | ||
title="訂便當" | ||
iconElementLeft={ | ||
<IconButton | ||
tooltipPosition="bottom-left" | ||
iconClassName="fa fa-bars" | ||
/> | ||
} | ||
iconElementRight={ | ||
<RightIconButton | ||
Logout={props.Logout} | ||
isAuth={auth.get("isAuth")} | ||
LOGON={auth.get("LOGON")} | ||
user={auth.get("user")} | ||
/> | ||
} | ||
/> | ||
<Sidebar openSidebar={() => false} isOpen={false} /> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default AuthWrapper; |
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 |
---|---|---|
@@ -1,8 +1,22 @@ | ||
export const initialAdmin = { | ||
logo: "http://play.nownews.com/wp-content/uploads/2017/08/5995a97ec6113d46af747352_201708172234-768x640.jpg", | ||
logo: | ||
"http://play.nownews.com/wp-content/uploads/2017/08/5995a97ec6113d46af747352_201708172234-768x640.jpg", | ||
email: "[email protected]", | ||
password: "abc123", | ||
name: "admin", | ||
company: "哈囉世界股份有限公司", | ||
isAdmin: true, | ||
isAdmin: true | ||
}; | ||
|
||
export const firebaseConfig = { | ||
apiKey: "AIzaSyCJshSB2O3ZG84vRqT9hOMJPDtQXQqOY7U", | ||
authDomain: "dinbandan-46e8c.firebaseapp.com", | ||
databaseURL: "https://dinbandan-46e8c.firebaseio.com", | ||
storageBucket: "dinbandan-46e8c.appspot.com", | ||
messagingSenderId: "544525397793", | ||
projectId: "dinbandan-46e8c" | ||
}; | ||
|
||
export const storeKeys = { | ||
auth: "_authoration" | ||
}; |
Oops, something went wrong.