Skip to content

Commit 7311dd5

Browse files
committed
migration
1 parent 82b3755 commit 7311dd5

File tree

7 files changed

+51
-81
lines changed

7 files changed

+51
-81
lines changed

front/src/components/logoutRoute/LogoutRoute.js

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { useEffect } from 'react';
3+
import { Route, Redirect } from 'react-router-dom';
4+
import { RouteComponentProps } from 'react-router';
5+
import { MappedDispatchToProps, MappedStateToProps, OwnProps } from './index';
6+
7+
// #region types
8+
type Props = {} & RouteComponentProps &
9+
MappedDispatchToProps &
10+
MappedStateToProps &
11+
OwnProps;
12+
// #endregion
13+
14+
function LogoutRoute(props: Props) {
15+
const { disconnectUser } = props;
16+
useEffect(() => disconnectUser());
17+
18+
return (
19+
<Route {...props}>
20+
<Redirect to={{ pathname: '/login' }} />
21+
</Route>
22+
);
23+
}
24+
25+
LogoutRoute.displayName = 'LogoutRoute';
26+
27+
export default LogoutRoute;

front/src/components/logoutRoute/__tests__/LogoutRoute.test.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { MemoryRouter } from 'react-router';
4+
import LogoutRoute from '../index';
5+
6+
describe('LogoutRoute component', () => {
7+
it('renders as expected', () => {
8+
const props = {
9+
disconnectUser: jest.fn(),
10+
};
11+
12+
const component = shallow(
13+
<MemoryRouter initialEntries={['/']}>
14+
<LogoutRoute {...props} />
15+
</MemoryRouter>,
16+
);
17+
expect(component).toMatchSnapshot();
18+
});
19+
});

front/src/components/logoutRoute/__tests__/__snapshots__/LogoutRoute.test.js.snap

Lines changed: 0 additions & 3 deletions
This file was deleted.

front/src/components/logoutRoute/index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { compose } from 'redux';
2+
import LogoutRoute from './LogoutRoute';
3+
import withAuth from '../../contexts/auth/consumerHOC';
4+
5+
export default compose(withAuth())(LogoutRoute);

0 commit comments

Comments
 (0)