-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added login and register modal layouts with corresponding reducers
- Loading branch information
1 parent
96624c0
commit 84d0241
Showing
11 changed files
with
204 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from "react"; | ||
import { Form, Segment, Button } from "semantic-ui-react"; | ||
import { Field, reduxForm } from "redux-form"; | ||
import TextInput from "../../../app/common/form/TextInput"; | ||
|
||
const LoginForm = () => { | ||
return ( | ||
<Form error size="large"> | ||
<Segment> | ||
<Field | ||
name="email" | ||
component={TextInput} | ||
type="text" | ||
placeholder="Email Address" | ||
/> | ||
<Field | ||
name="password" | ||
component={TextInput} | ||
type="password" | ||
placeholder="password" | ||
/> | ||
<Button fluid size="large" color="teal"> | ||
Login | ||
</Button> | ||
</Segment> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default reduxForm({ form: "loginForm" })(LoginForm); |
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 { Form, Segment, Button } from "semantic-ui-react"; | ||
import { Field, reduxForm } from "redux-form"; | ||
import TextInput from "../../../app/common/form/TextInput"; | ||
|
||
const RegisterForm = () => { | ||
return ( | ||
<div> | ||
<Form size="large"> | ||
<Segment> | ||
<Field | ||
name="displayName" | ||
type="text" | ||
component={TextInput} | ||
placeholder="Known As" | ||
/> | ||
<Field | ||
name="email" | ||
type="text" | ||
component={TextInput} | ||
placeholder="Email" | ||
/> | ||
<Field | ||
name="password" | ||
type="password" | ||
component={TextInput} | ||
placeholder="Password" | ||
/> | ||
<Button fluid size="large" color="teal"> | ||
Register | ||
</Button> | ||
</Segment> | ||
</Form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default reduxForm({ form: "registerForm" })(RegisterForm); |
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,14 @@ | ||
export const login = creds => { | ||
return { | ||
type: "LOGIN_USER", | ||
payload: { | ||
creds | ||
} | ||
}; | ||
}; | ||
|
||
export const logout = () => { | ||
return { | ||
type: "SIGN_OUT_USER" | ||
}; | ||
}; |
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,17 @@ | ||
import { createReducer } from "../../app/common/util/ReducerUtil.js"; | ||
|
||
const initialState = { | ||
currentUser: {} | ||
}; | ||
export const loginUser = (state, payload) => { | ||
return { ...state, authenticated: true, currentUser: payload.creds.email }; | ||
}; | ||
|
||
export const signOutUser = (state, payload) => { | ||
return { ...state, authenticated: false, currentUser: {} }; | ||
}; | ||
|
||
export default createReducer(initialState, { | ||
["LOGIN_USER"]: loginUser, | ||
["SIGN_OUT_USER"]: signOutUser | ||
}); |
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,28 @@ | ||
import React, { Component } from "react"; | ||
import { Modal } from "semantic-ui-react"; | ||
import { connect } from "react-redux"; | ||
|
||
import LoginForm from "../auth/Login/LoginForm"; | ||
import { closeModal } from "./modalActions"; | ||
|
||
const actions = { closeModal }; | ||
|
||
class LoginModal extends Component { | ||
render() { | ||
return ( | ||
<Modal size="mini" open={true} onClose={this.props.closeModal}> | ||
<Modal.Header>Login to Bunch Up</Modal.Header> | ||
<Modal.Content> | ||
<Modal.Description> | ||
<LoginForm /> | ||
</Modal.Description> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
null, | ||
actions | ||
)(LoginModal); |
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,28 @@ | ||
import React, { Component } from "react"; | ||
import { Modal } from "semantic-ui-react"; | ||
import { connect } from "react-redux"; | ||
|
||
import { closeModal } from "./modalActions"; | ||
import RegisterForm from "../auth/Register/RegisterForm"; | ||
|
||
const actions = { closeModal }; | ||
|
||
class RegisterModal extends Component { | ||
render() { | ||
return ( | ||
<Modal size="mini" open={true} onClose={this.props.closeModal}> | ||
<Modal.Header>Sign Up to Bunch Up</Modal.Header> | ||
<Modal.Content> | ||
<Modal.Description> | ||
<RegisterForm /> | ||
</Modal.Description> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
null, | ||
actions | ||
)(RegisterModal); |
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,25 @@ | ||
import React from "react"; | ||
import { connect } from "react-redux"; | ||
import LoginModal from "./LoginModal"; | ||
import RegisterModal from "./RegisterModal"; | ||
|
||
const modalLookup = { | ||
LoginModal, | ||
RegisterModal | ||
}; | ||
|
||
const ModalManager = ({ currentModal }) => { | ||
let renderedModal; | ||
if (currentModal) { | ||
const { modalType, modalProps } = currentModal; | ||
const ModalComponent = modalLookup[modalType]; | ||
renderedModal = <ModalComponent {...modalProps} />; | ||
} | ||
return <span>{renderedModal}</span>; | ||
}; | ||
|
||
const mapStateToProps = state => { | ||
return { currentModal: state.modals }; | ||
}; | ||
|
||
export default connect(mapStateToProps)(ModalManager); |
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