Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 24526a7

Browse files
keep on upgrade
1 parent 3e45d1e commit 24526a7

File tree

13 files changed

+57
-46
lines changed

13 files changed

+57
-46
lines changed

‎front/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
<body>
1616
<section id="root"></section>
17-
<script type="text/javascript" src="app.js"></script>
18-
<script type="text/javascript" src="vendors.js"></script>
17+
<!-- <script type="text/javascript" src="/assets/app.js"></script>
18+
<script type="text/javascript" src="/assets/vendors.js"></script> -->
1919
</body>
2020

2121
</html>

‎front/src/Root.tsx‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,32 @@ class Root extends Component<Props, State> {
3636

3737
render() {
3838
return (
39-
<Router>
40-
<Providerstore={store}>
41-
<ThemeProvidertheme={{}}>
42-
<Fragment>
43-
<ScrollTop>
39+
<Providerstore={store}>
40+
<ThemeProvidertheme={{}}>
41+
<Router>
42+
<ScrollTop>
43+
<Fragment>
4444
<Switch>
4545
<Route exact path="/login">
4646
<Login />
4747
</Route>
4848

49-
{/* Application with main layout (could have multiple applications with different layouts) */}
50-
<MainLayout>
51-
<MainRoutes />
52-
</MainLayout>
5349
{/* logout: just redirects to login (App will take care of removing the token) */}
5450
<LogoutRoute path="/logout" />
55-
</Switch>
56-
</ScrollTop>
5751

58-
<GlobalStyle />
59-
</Fragment>
60-
</ThemeProvider>
61-
</Provider>
62-
</Router>
52+
{/* Application with main layout (could have multiple applications with different layouts) */}
53+
<Route path="*">
54+
<MainLayout>
55+
<MainRoutes />
56+
</MainLayout>
57+
</Route>
58+
</Switch>
59+
</Fragment>
60+
</ScrollTop>
61+
<GlobalStyle />
62+
</Router>
63+
</ThemeProvider>
64+
</Provider>
6365
);
6466
}
6567
}

‎front/src/components/privateRoute/PrivateRoute.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function PrivateRoute(props: Props) {
1414
return (
1515
<Route
1616
{...rest}
17-
render={(innerComponentProps) =>
17+
render={() =>
1818
isAuthenticated ? (
19-
<InnerComponent{...innerComponentProps}/>
19+
InnerComponent
2020
) : (
2121
<Redirect to={{ pathname: '/login', state: { from: location } }} />
2222
)

‎front/src/pages/about/About.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { RouteComponentProps } from 'react-router';
2+
import { RouteComponentProps,withRouter } from 'react-router';
33
import FadeInEntrance from '../../components/fadeInEntrance';
44
import { OwnProps, ReduxConnectedProps } from './index';
55

@@ -17,4 +17,4 @@ function About() {
1717

1818
About.displayName = 'About';
1919

20-
export default About;
20+
export default withRouter(About);

‎front/src/pages/home/Home.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { RouteComponentProps } from 'react-router';
2+
import { RouteComponentProps,withRouter } from 'react-router';
33
import { Link } from 'react-router-dom';
44
import Jumbotron from 'reactstrap/lib/Jumbotron';
55
import FadeInEntrance from '../../components/fadeInEntrance';
@@ -38,4 +38,4 @@ function Home() {
3838

3939
Home.displayName = 'Home';
4040

41-
export default Home;
41+
export default withRouter(Home);

‎front/src/pages/login/Login.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useCallback } from 'react';
2-
import { RouteComponentProps } from 'react-router';
2+
import { RouteComponentProps,withRouter } from 'react-router';
33
import Button from 'reactstrap/lib/Button';
44
import Row from 'reactstrap/lib/Row';
55
import Col from 'reactstrap/lib/Col';
@@ -64,7 +64,9 @@ function Login({
6464
auth.setToken(token);
6565
auth.setUserInfo(stringifiedUserInfo);
6666

67-
const { from } = (location.state as any) || { from: { pathname: '/' } };
67+
const { from } = (location?.state as any) || {
68+
from: { pathname: '/' },
69+
};
6870

6971
history.replace(from); // back to Home
7072
} catch (error) {
@@ -179,4 +181,4 @@ Login.defaultProps = {
179181

180182
Login.displayName = 'Login';
181183

182-
export default Login;
184+
export default withRouter(Login);

‎front/src/pages/pageNotFound/PageNotFound.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { RouteComponentProps } from 'react-router';
2+
import { RouteComponentProps,withRouter } from 'react-router';
33
import Jumbotron from 'reactstrap/lib/Jumbotron';
44
import FadeInEntrance from '../../components/fadeInEntrance';
55
import { OwnProps, ReduxConnectedProps } from './index';
@@ -20,4 +20,4 @@ function PageNotFound() {
2020

2121
PageNotFound.displayName = 'PageNotFound';
2222

23-
export default PageNotFound;
23+
export default withRouter(PageNotFound);

‎front/src/pages/protected/Protected.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { RouteComponentProps } from 'react-router';
2+
import { RouteComponentProps,withRouter } from 'react-router';
33
import FadeInEntrance from '../../components/fadeInEntrance';
44
import { OwnProps, ReduxConnectedProps } from './index';
55

@@ -18,4 +18,4 @@ function Protected() {
1818

1919
Protected.displayName = 'Protected';
2020

21-
export default Protected;
21+
export default withRouter(Protected);

‎front/src/redux/modules/userAuth/index.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function (
9090
firstname = '',
9191
lastname = '',
9292
},
93-
} = action.payload;
93+
} = action;
9494

9595
return {
9696
...state,
@@ -203,7 +203,7 @@ function logUser(
203203
return async (dispatch) => {
204204
try {
205205
let actionTime = format(new Date(), 'dd/MM/yyyy HH:MM');
206-
dispatch({ type: REQUEST_LOG_USER, actionTime });
206+
dispatch({ type: REQUEST_LOG_USER, actionTime, login, password });
207207

208208
// #region mocked request case:
209209
actionTime = format(new Date(), 'dd/MM/yyyy HH:MM');
@@ -212,7 +212,7 @@ function logUser(
212212
dispatch({
213213
type: RECEIVED_LOG_USER,
214214
actionTime,
215-
payload: user,
215+
data: user,
216216
});
217217

218218
return user;
@@ -239,13 +239,17 @@ function logUser(
239239
dispatch({
240240
type: RECEIVED_LOG_USER,
241241
actionTime,
242-
payload: data,
242+
data,
243243
});
244244
return data;
245245
// #endregion
246-
} catch (error) {
246+
} catch (error: any) {
247247
const actionTime = format(new Date(), 'dd/MM/yyyy HH:MM');
248-
dispatch({ type: ERROR_LOG_USER, actionTime });
248+
dispatch({
249+
type: ERROR_LOG_USER,
250+
actionTime,
251+
error: error?.message ?? 'undefined error, no luck bro',
252+
});
249253
}
250254
};
251255
}
@@ -273,7 +277,7 @@ export function logUserIfNeeded(
273277
function shouldLogUser(state: RootState, userEmail: string): boolean {
274278
const { isLogging, login: currentUserEmail } = state.userAuth;
275279

276-
if (currentUserEmail !== userEmail) {
280+
if (!currentUserEmail||currentUserEmail !== userEmail) {
277281
return true;
278282
}
279283

‎front/webpack.hot.reload.config.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const config = {
1919
path: path.join(__dirname, 'docs'),
2020
filename: '[name].[contenthash].js',
2121
chunkFilename: '[name].[chunkhash].js',
22-
assetModuleFilename: 'assets/[contenthash][ext][query]',
22+
// assetModuleFilename: 'assets/[contenthash][ext][query]',
2323
},
2424
resolve: {
2525
modules: ['node_modules'],
@@ -64,12 +64,13 @@ const config = {
6464
host: 'localhost',
6565
port: 3001,
6666
hot: true,
67-
static: path.join(__dirname, '/../docs/assets'),
68-
headers: {'Access-Control-Allow-Origin': '*'},
67+
static: path.join(__dirname, 'docs'),
68+
historyApiFallback: true,// browser refresh will fail otherwise
6969
},
7070
plugins: [
7171
new HtmlWebpackPlugin({
7272
template: 'index.html',
73+
// filename: '../index.html', // hack since outPut path would place in '/dist/assets/' in place of '/dist/'
7374
}),
7475
new webpack.DefinePlugin({
7576
'process.env.NODE_ENV': JSON.stringify('development'),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /