Updated employee login
This commit is contained in:
@@ -5,34 +5,40 @@ import { Button, TextInput } from "react-native-paper";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { signInEmployeeStart } from "../../redux/employee/employee.actions";
|
||||
import { employeeSignInStart } from "../../redux/employee/employee.actions";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
selectCurrentEmployee, selectSigningIn
|
||||
selectCurrentEmployee,
|
||||
selectSigningIn,
|
||||
selectSignInError
|
||||
} from "../../redux/employee/employee.selectors";
|
||||
//TODO JF add props
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
// import Timer from "../../util/timer";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
signingIn: selectSigningIn,
|
||||
signingError: selectSignInError,
|
||||
});
|
||||
|
||||
//TODO JF add prop functions to call dispatch with actions
|
||||
// JF add prop functions to call dispatch with actions
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
signInEmployeeStart: (employeeId, pin) =>
|
||||
dispatch(signInEmployeeStart({ employeeId, pin })),
|
||||
employeeSignInStart: (employeeId, pin) => dispatch(employeeSignInStart({ employeeId, pin })),
|
||||
});
|
||||
|
||||
export function EmployeeSignIn({ signInEmployeeStart, employeeSigningIn }) {
|
||||
export function EmployeeSignIn({currentEmployee,signingError, signingIn, employeeSignInStart }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
//TODO add call to dispatch action
|
||||
//TODO add call to dispatch action
|
||||
const formSubmit = (values) => {
|
||||
const { employeeId, pin } = values;
|
||||
signInEmployeeStart(employeeId, pin);
|
||||
employeeSignInStart(employeeId, pin);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={localStyles.content}>
|
||||
{/* {currentEmployee ? <Redirect to={`/timeticketbrowser/landing`} /> : null} */}
|
||||
<View style={localStyles.signInContainer}>
|
||||
<Formik
|
||||
initialValues={{ employeeId: "", pin: "" }}
|
||||
@@ -59,9 +65,12 @@ export function EmployeeSignIn({ signInEmployeeStart, employeeSigningIn }) {
|
||||
value={values.pin}
|
||||
style={[localStyles.input]}
|
||||
/>
|
||||
{signingError && (
|
||||
<ErrorDisplay errorMessage={signingError} />
|
||||
)}
|
||||
<Button
|
||||
mode="outlined"
|
||||
loading={employeeSigningIn}
|
||||
loading={signingIn}
|
||||
onPress={handleSubmit}
|
||||
>
|
||||
<Text>{t("employeesignin.actions.employeesignin")}</Text>
|
||||
|
||||
Reference in New Issue
Block a user