2020-12-19 03:38:04 +02:00
|
|
|
export function reducer(state, action) {
|
|
|
|
switch (action.type) {
|
2020-12-19 04:22:38 +02:00
|
|
|
case "onCredentialsChange": {
|
|
|
|
const { prop, value } = action.payload;
|
2020-12-19 03:38:04 +02:00
|
|
|
return {
|
|
|
|
...state,
|
2020-12-19 04:22:38 +02:00
|
|
|
credentials: {
|
|
|
|
...state.credentials,
|
|
|
|
[prop]: value
|
2020-12-19 03:38:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2020-12-23 01:51:23 +02:00
|
|
|
case "onNetworkChange": {
|
|
|
|
const { prop, value } = action.payload;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
network: {
|
|
|
|
...state.network,
|
|
|
|
[prop]: value
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2020-12-24 05:32:35 +02:00
|
|
|
case "onAuthorizationTokenChange": {
|
|
|
|
const { token } = action.payload;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
security: {
|
|
|
|
...state.security,
|
|
|
|
authorization: {
|
|
|
|
...state.security.authorization,
|
|
|
|
token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2020-12-19 03:38:04 +02:00
|
|
|
default: {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const dispatchActions = dispatch => ({
|
2020-12-19 04:22:38 +02:00
|
|
|
onCredentialsChange: (prop, value) =>
|
2020-12-23 01:51:23 +02:00
|
|
|
dispatch({ type: "onCredentialsChange", payload: { prop, value } }),
|
|
|
|
onNetworkChange: (prop, value) =>
|
2020-12-24 05:32:35 +02:00
|
|
|
dispatch({ type: "onNetworkChange", payload: { prop, value } }),
|
|
|
|
onAuthorizationTokenChange: token =>
|
|
|
|
dispatch({ type: "onAuthorizationTokenChange", payload: { token } })
|
2020-12-19 03:38:04 +02:00
|
|
|
});
|