removed unused code
parent
30510d9a73
commit
0adbf9af72
|
@ -2,19 +2,14 @@ import React, { useContext } from "react";
|
||||||
import LoginComponent from "./LoginComponent";
|
import LoginComponent from "./LoginComponent";
|
||||||
import Button from "@material-ui/core/Button";
|
import Button from "@material-ui/core/Button";
|
||||||
import { authenticate } from "../../../utils/identity";
|
import { authenticate } from "../../../utils/identity";
|
||||||
import {
|
import { ApplicationStateContext } from "../../../state/ApplicationContexts";
|
||||||
ApplicationStateContext,
|
|
||||||
ApplicationDispatchContext
|
|
||||||
} from "../../../state/ApplicationContexts";
|
|
||||||
|
|
||||||
const LoginContainer = () => {
|
const LoginContainer = () => {
|
||||||
const state = useContext(ApplicationStateContext);
|
const state = useContext(ApplicationStateContext);
|
||||||
const dispatchActions = useContext(ApplicationDispatchContext);
|
|
||||||
|
|
||||||
const handleLogin = async () => {
|
const handleLogin = async () => {
|
||||||
const { userName, password } = state.credentials;
|
const { userName, password } = state.credentials;
|
||||||
const token = await authenticate(userName, password);
|
await authenticate(userName, password);
|
||||||
dispatchActions.onAuthorizationTokenChange(token);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -3,11 +3,6 @@ export const initialState = {
|
||||||
userName: "",
|
userName: "",
|
||||||
password: ""
|
password: ""
|
||||||
},
|
},
|
||||||
security: {
|
|
||||||
authorization: {
|
|
||||||
token: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
network: {
|
network: {
|
||||||
test: ""
|
test: ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,20 +10,6 @@ export function reducer(state, action) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case "onAuthorizationTokenChange": {
|
|
||||||
const { token } = action.payload;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
security: {
|
|
||||||
...state.security,
|
|
||||||
authorization: {
|
|
||||||
...state.security.authorization,
|
|
||||||
token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case "onNetworkChange": {
|
case "onNetworkChange": {
|
||||||
const { prop, value } = action.payload;
|
const { prop, value } = action.payload;
|
||||||
return {
|
return {
|
||||||
|
@ -44,7 +30,5 @@ export const dispatchActions = dispatch => ({
|
||||||
onCredentialsChange: (prop, value) =>
|
onCredentialsChange: (prop, value) =>
|
||||||
dispatch({ type: "onCredentialsChange", payload: { prop, value } }),
|
dispatch({ type: "onCredentialsChange", payload: { prop, value } }),
|
||||||
onNetworkChange: (prop, value) =>
|
onNetworkChange: (prop, value) =>
|
||||||
dispatch({ type: "onNetworkChange", payload: { prop, value } }),
|
dispatch({ type: "onNetworkChange", payload: { prop, value } })
|
||||||
onAuthorizationTokenChange: token =>
|
|
||||||
dispatch({ type: "onAuthorizationTokenChange", payload: { token } })
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue