Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,39 @@ For Production:
t('user.name') will be render "Name" for `en` and "Tên" for `vi`
```

- Call API with axios

```javascript
import { getUser } from '@/apis/user.ts';
import { setLoading } from '@/store/slices/appSlice';
import { errorHandler } from '@/helpers/axios';

const dispatch = useDispatch();

// Use useCallback to memorize create func (just one time)
const fetchUser = useCallback(async () => {
try {
// Star loading spinner
dispatch(setLoading(true));

// fetch user
const resp = await getUser();
console.log(resp);
} catch (error) {
// display toast when error
errorHandler(error);
} finally {
// End loading spinner
dispatch(setLoading(false));
}
}, []);

useEffect(() => {
// Trigger function
fetchUser();
}, [fetchUser]);
```

---

## Tips
Expand Down
2 changes: 2 additions & 0 deletions config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const fs = require('fs');
const path = require('path');
const paths = require('./paths');
const PACKAGE = require(paths.appPackageJson);

// Make sure that including paths.js after env.js will read .env variables.
delete require.cache[require.resolve('./paths')];
Expand Down Expand Up @@ -85,6 +86,7 @@ function getClientEnvironment(publicUrl) {
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
PUBLIC_URL: publicUrl,
VERSION: PACKAGE.version,
},
);
// Stringify all values so we can feed into webpack DefinePlugin
Expand Down
14 changes: 0 additions & 14 deletions config/jest/config.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "aldenn",
"license": "ISC",
"name": "react-webpack-typescript-starter",
"version": "1.0.0",
"version": "0.0.3",
"description": "The React-Typescript Boilerplate with Webpack config manual",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pm2/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"kill_timeout": 3000,
"restart_delay": 3000,
"script": "npm",
"args": "run prod"
"args": "run start"
}
]
}
Binary file added public/static/images/login-avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/apis/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosResponse } from 'axios';
import HttpRequest from '@/services/http-request';

export const getCurrentUser = (): Promise<AxiosResponse<unknown>> =>
export const getCurrentUser = async (): Promise<AxiosResponse> =>
HttpRequest.get('/api/login/GetInfoToken');
4 changes: 2 additions & 2 deletions src/apis/todo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AxiosResponse } from 'axios';
import HttpRequest from '@/services/http-request';

export const getTodoList = (): Promise<AxiosResponse> =>
export const getTodoList = async (): Promise<AxiosResponse> =>
HttpRequest.get('https://jsonplaceholder.typicode.com/todos');

export const getTodoDetails = (id: string): Promise<AxiosResponse> =>
export const getTodoDetails = async (id: string): Promise<AxiosResponse> =>
HttpRequest.get(`https://jsonplaceholder.typicode.com/todos/${id}`);
26 changes: 0 additions & 26 deletions src/components/empty-record/index.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/empty-record/style.scss

This file was deleted.

56 changes: 0 additions & 56 deletions src/components/icon/index.tsx

This file was deleted.

Empty file removed src/components/icon/style.scss
Empty file.
17 changes: 0 additions & 17 deletions src/components/input/index.tsx

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/input/style.scss

This file was deleted.

26 changes: 5 additions & 21 deletions src/components/not-found/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,11 @@ import { Link } from 'react-router-dom';
const NotFound: React.FC = () => {
return (
<section className="page_404">
<div className="container">
<div className="row">
<div className="col-sm-12 ">
<div className="col-sm-10 col-sm-offset-1 text-center">
<div className="four_zero_four_bg">
<h1 className="text-center ">404</h1>
</div>

<div className="contant_box_404">
<h3 className="h2">Look like you are lost</h3>

<p>the page you are looking for not avaible!</p>

<Link to="/" className="link_404">
Go to Home
</Link>
</div>
</div>
</div>
</div>
</div>
<h1>404</h1>
<p>Oops! Something is wrong.</p>
<Link className="button" to="/">
<i className="icon-home"></i> Go back in initial page, is better.
</Link>
</section>
);
};
Expand Down
Loading