Commit b62ab25c by Tobias Skarhed Committed by Torkel Ödegaard

SignIn: Update redirect on reroute (#18360)

* Connect SignIn with redux and get url

* Update test snapshot
parent 09e79384
import React from 'react';
import { shallow } from 'enzyme';
import SignIn from './SignIn';
import { SignIn } from './SignIn';
describe('Render', () => {
it('should render component', () => {
const wrapper = shallow(<SignIn />);
const wrapper = shallow(<SignIn url="/" />);
expect(wrapper).toMatchSnapshot();
});
......
import React, { FC } from 'react';
import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
import { StoreState } from 'app/types';
const SignIn: FC<any> = () => {
const loginUrl = `login?redirect=${encodeURIComponent(window.location.pathname)}`;
export const SignIn: FC<any> = ({ url }) => {
const loginUrl = `login?redirect=${encodeURIComponent(url)}`;
return (
<div className="sidemenu-item">
<a href={loginUrl} className="sidemenu-link" target="_self">
......@@ -20,4 +22,8 @@ const SignIn: FC<any> = () => {
);
};
export default SignIn;
const mapStateToProps = (state: StoreState) => ({
url: state.location.url,
});
export default connectWithStore(SignIn, mapStateToProps);
......@@ -4,7 +4,7 @@ exports[`Render should render component 1`] = `
<div
className="sidemenu__bottom"
>
<SignIn />
<Component />
<BottomNavLinks
key="undefined-0"
link={
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment