Skip to content

Commit c3d3158

Browse files
committed
Merge branch 'fix/filter-loading-z-index' into develop
2 parents 3e85c4c + 9af5a55 commit c3d3158

File tree

28 files changed

+881
-550
lines changed

28 files changed

+881
-550
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_URL=http://localhost:4000

package-lock.json

Lines changed: 178 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"date-fns": "^3.6.0",
2828
"formik": "^2.4.6",
2929
"lucide-react": "^0.378.0",
30+
"qs": "^6.12.1",
3031
"react": "^18.2.0",
3132
"react-dom": "^18.2.0",
3233
"react-hook-form": "^7.51.4",
@@ -40,6 +41,7 @@
4041
},
4142
"devDependencies": {
4243
"@types/node": "^20.12.8",
44+
"@types/qs": "^6.9.15",
4345
"@types/react": "^18.2.66",
4446
"@types/react-dom": "^18.2.22",
4547
"@types/react-input-mask": "^3.0.5",

src/api/api.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
import axios, { AxiosRequestHeaders } from 'axios';
1+
import axios, { AxiosRequestHeaders, InternalAxiosRequestConfig } from 'axios';
2+
import { getCacheRequestData, handleCacheResponse } from './cache';
23

34
const api = axios.create({
45
baseURL: import.meta.env.VITE_API_URL ?? 'http://localhost:4000/',
56
});
67

7-
api.interceptors.request.use((config) => {
8-
if (!config.headers) config.headers = {} as AxiosRequestHeaders;
8+
function handleRequestAuthToken(config: InternalAxiosRequestConfig<any>) {
99
const token = localStorage.getItem('token');
1010
if (token) config.headers.Authorization = `Bearer ${token}`;
11+
}
12+
13+
api.interceptors.request.use((config) => {
14+
if (!config.headers) config.headers = {} as AxiosRequestHeaders;
15+
handleRequestAuthToken(config);
16+
const response = getCacheRequestData(config);
17+
if (response) {
18+
config.adapter = () => {
19+
return new Promise((resolve) => {
20+
resolve({ ...response, config });
21+
});
22+
};
23+
}
1124
return config;
1225
});
1326

1427
api.interceptors.response.use(
1528
(config) => {
29+
handleCacheResponse(config);
1630
return config;
1731
},
1832
(error) => {

0 commit comments

Comments
 (0)