SignIn: Update redirect on reroute (#18360)

* Connect SignIn with redux and get url

* Update test snapshot
This commit is contained in:
Tobias Skarhed 2019-08-03 16:21:17 +02:00 committed by Torkel Ödegaard
parent 09e7938499
commit b62ab25c41
3 changed files with 12 additions and 6 deletions

View File

@ -1,10 +1,10 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import SignIn from './SignIn'; import { SignIn } from './SignIn';
describe('Render', () => { describe('Render', () => {
it('should render component', () => { it('should render component', () => {
const wrapper = shallow(<SignIn />); const wrapper = shallow(<SignIn url="/" />);
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
}); });

View File

@ -1,7 +1,9 @@
import React, { FC } from 'react'; import React, { FC } from 'react';
import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
import { StoreState } from 'app/types';
const SignIn: FC<any> = () => { export const SignIn: FC<any> = ({ url }) => {
const loginUrl = `login?redirect=${encodeURIComponent(window.location.pathname)}`; const loginUrl = `login?redirect=${encodeURIComponent(url)}`;
return ( return (
<div className="sidemenu-item"> <div className="sidemenu-item">
<a href={loginUrl} className="sidemenu-link" target="_self"> <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);

View File

@ -4,7 +4,7 @@ exports[`Render should render component 1`] = `
<div <div
className="sidemenu__bottom" className="sidemenu__bottom"
> >
<SignIn /> <Component />
<BottomNavLinks <BottomNavLinks
key="undefined-0" key="undefined-0"
link={ link={