Added login and logout

This commit is contained in:
jfrye122
2023-04-20 22:38:22 -04:00
parent b7b6877478
commit f3384d4e36
11 changed files with 133 additions and 37 deletions

View File

@@ -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}