Skip to content

Commit 3d3f437

Browse files
fagundesjgluccas-spechtMatheusDubingiggiofelipee-monteiro
authored
merge: develop -> master (#91)
* refact: created shelter list view component in home page * Fix: mobile UI has broken for mobile devices (#22) *Fix: mobile UI has broken for mobile devices * fix: remove chip as fixed as no wrap property * chore: add shelter card clickable * chore: remove Fragment component * build: add set sm as max mobile dimension sm: 425px * style: add responsive layout * refactor: filter page * fix: priority * fix: filter parameters * fix: fixed volunteer supply that had been fulfilled displaying on shelter page * fix: improve readability * feat: hidden filter button if filter is empty * feat: cache in axios request * fix: cache search params * feat: cache clean on searchs * fix: donation tags * fix: clean search params * fix: donation tags / componentized the urgent supplies section * fix: removed empty shelter tags empty row * feat: full edit shelter and improved interface of pet friendly in shelter page * Fix/develop bugs (#90) * fix: cache bug (invalite cache on create/update operation) * feat: added update many shelter supplies and admin rule * Add license (#81) Closes #65. * fix: app port (#80) --------- Co-authored-by: Luccas Specht <[email protected]> Co-authored-by: MatheusDubin <[email protected]> Co-authored-by: Giovanni Bassi <[email protected]> Co-authored-by: Felipe Monteiro <[email protected]>
1 parent 4f9a757 commit 3d3f437

File tree

57 files changed

+1481
-753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1481
-753
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

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 SOS-RS
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Para executar o frontend do aplicativo em seu ambiente local, siga os passos aba
4545
```
4646
npm run dev
4747
```
48-
O app estará disponível em `http://localhost:3000`.
48+
O app estará disponível em `http://localhost:5173`.
4949

5050
## Contribuindo
5151

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: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
1-
import axios, { AxiosRequestHeaders } from 'axios';
1+
import axios, { AxiosRequestHeaders, InternalAxiosRequestConfig } from 'axios';
2+
import { clearCache, 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) => {
1933
if (error.response && error.response.status === 401) {
34+
clearCache(false);
2035
localStorage.removeItem('token');
2136
}
2237
return Promise.reject(error);

0 commit comments

Comments
 (0)