Added login and logout
This commit is contained in:
@@ -10,11 +10,10 @@ import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
selectCurrentEmployee,
|
||||
selectSigningIn,
|
||||
selectSignInError
|
||||
selectSignInError,
|
||||
} from "../../redux/employee/employee.selectors";
|
||||
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
// import Timer from "../../util/timer";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
@@ -22,15 +21,18 @@ const mapStateToProps = createStructuredSelector({
|
||||
signingError: selectSignInError,
|
||||
});
|
||||
|
||||
// JF add prop functions to call dispatch with actions
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
employeeSignInStart: (employeeId, pin) => dispatch(employeeSignInStart({ employeeId, pin })),
|
||||
employeeSignInStart: (employeeId, pin) =>
|
||||
dispatch(employeeSignInStart({ employeeId, pin })),
|
||||
});
|
||||
|
||||
export function EmployeeSignIn({currentEmployee,signingError, signingIn, employeeSignInStart }) {
|
||||
export function EmployeeSignIn({
|
||||
signingError,
|
||||
signingIn,
|
||||
employeeSignInStart,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
//TODO add call to dispatch action
|
||||
const formSubmit = (values) => {
|
||||
const { employeeId, pin } = values;
|
||||
employeeSignInStart(employeeId, pin);
|
||||
@@ -38,7 +40,6 @@ export function EmployeeSignIn({currentEmployee,signingError, signingIn, employe
|
||||
|
||||
return (
|
||||
<View style={localStyles.content}>
|
||||
{/* {currentEmployee ? <Redirect to={`/timeticketbrowser/landing`} /> : null} */}
|
||||
<View style={localStyles.signInContainer}>
|
||||
<Formik
|
||||
initialValues={{ employeeId: "", pin: "" }}
|
||||
@@ -65,9 +66,7 @@ export function EmployeeSignIn({currentEmployee,signingError, signingIn, employe
|
||||
value={values.pin}
|
||||
style={[localStyles.input]}
|
||||
/>
|
||||
{signingError && (
|
||||
<ErrorDisplay errorMessage={signingError} />
|
||||
)}
|
||||
{signingError && <ErrorDisplay errorMessage={signingError} />}
|
||||
<Button
|
||||
mode="outlined"
|
||||
loading={signingIn}
|
||||
|
||||
Reference in New Issue
Block a user