From 7c29a0082bccb7be7ab92f5e6ab6bf0192f899f3 Mon Sep 17 00:00:00 2001
From: Ismail <msiamil.official@gmail.com>
Date: Wed, 19 Aug 2020 14:24:05 +0500
Subject: [PATCH] auth actions created, modified dispatch for login action

---
 employeemanagement/src/App.js                       |  2 +-
 employeemanagement/src/components/auth/SignIn.js    | 10 +++++++++-
 employeemanagement/src/store/actions/authAction.js  |  5 +++++
 .../src/store/reducers/authReducer.js               | 13 +++++++++----
 4 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 employeemanagement/src/store/actions/authAction.js

diff --git a/employeemanagement/src/App.js b/employeemanagement/src/App.js
index d97e00f..9b3cf49 100644
--- a/employeemanagement/src/App.js
+++ b/employeemanagement/src/App.js
@@ -7,7 +7,7 @@ function App() {
   return (
     <BrowserRouter>
       <div className="App">
-        <Dashboard />
+        <SignIn />
       </div>
     </BrowserRouter>
   );
diff --git a/employeemanagement/src/components/auth/SignIn.js b/employeemanagement/src/components/auth/SignIn.js
index bb47fbc..400a47e 100644
--- a/employeemanagement/src/components/auth/SignIn.js
+++ b/employeemanagement/src/components/auth/SignIn.js
@@ -1,5 +1,7 @@
 import React, { Component } from 'react';
 import Logo from '../images/header-logo.png';
+import { connect } from 'react-redux';
+import { signIn } from '../../store/actions/authAction';
 
 class Signin extends Component {
     state = {
@@ -15,6 +17,7 @@ class Signin extends Component {
 
     handleSubmit = (e) => {
         e.preventDefault();
+        this.props.signIn(this.state);
     }
     render(){
         return(
@@ -39,5 +42,10 @@ class Signin extends Component {
         )
     }
 }
+const mapDisToProps = (dispatch) => {
+    return {
+        signIn: (credentials) => dispatch(signIn(credentials)) 
+    }
+}
 
-export default Signin;
\ No newline at end of file
+export default connect(null, mapDisToProps)(Signin);
\ No newline at end of file
diff --git a/employeemanagement/src/store/actions/authAction.js b/employeemanagement/src/store/actions/authAction.js
new file mode 100644
index 0000000..04195f3
--- /dev/null
+++ b/employeemanagement/src/store/actions/authAction.js
@@ -0,0 +1,5 @@
+export const signIn = (credentials) => {
+    return (dispatch, getState) => {
+        dispatch({ type: 'LOGIN', credentials})
+    }
+}
\ No newline at end of file
diff --git a/employeemanagement/src/store/reducers/authReducer.js b/employeemanagement/src/store/reducers/authReducer.js
index 9248803..6b88a43 100644
--- a/employeemanagement/src/store/reducers/authReducer.js
+++ b/employeemanagement/src/store/reducers/authReducer.js
@@ -1,7 +1,12 @@
 const initialState = {}
 
-const authRed = (state = initialState, action) => {
-    return state
+const authReducer = (state = initialState, action) => {
+    switch (action.type) {
+        case 'LOGIN':
+            console.log('Login check', action.credentials);
+        default:
+            return state;
+    }
+    return state;
 }
-
-export default authRed;
\ No newline at end of file
+export default authReducer
\ No newline at end of file
-- 
GitLab