client: updates

* work on groups ui
* move settings to its own page
* other fixes and refactoring
This commit is contained in:
Philipinho
2024-04-04 22:19:15 +01:00
parent cab5e67055
commit 1412f1d982
64 changed files with 1770 additions and 474 deletions

View File

@ -3,10 +3,11 @@ import Cookies from "js-cookie";
import Routes from "@/lib/routes";
const api: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_BACKEND_API_URL + '/api'
baseURL: import.meta.env.VITE_BACKEND_API_URL + "/api",
});
api.interceptors.request.use(config => {
api.interceptors.request.use(
(config) => {
const tokenData = Cookies.get("authTokens");
const accessToken = tokenData && JSON.parse(tokenData)?.accessToken;
@ -15,23 +16,23 @@ api.interceptors.request.use(config => {
}
return config;
},
error => {
(error) => {
return Promise.reject(error);
},
);
api.interceptors.response.use(
response => {
(response) => {
return response.data;
},
error => {
(error) => {
if (error.response) {
switch (error.response.status) {
case 401:
// Handle unauthorized error
if (window.location.pathname != Routes.AUTH.LOGIN){
if (window.location.pathname != Routes.AUTH.LOGIN) {
window.location.href = Routes.AUTH.LOGIN;
}
}
break;
case 403:
// Handle forbidden error