refactor: Admin App with better layouts and Meta Information (#7200)

* fix: layout structure in admin

* fix: layout structure in admin

* fix: delete layout files

* chore: updated form related info

* fix: admin import statements

* fix: general page unauthorized flickering issue

* chore: logs related

* chore: lock file updates

* fix: build errors

* fix: coderabbit suggestions
This commit is contained in:
sriram veeraghanta 2025-07-02 19:43:44 +05:30 committed by GitHub
parent 7153064ebb
commit 8cc23bc4a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
70 changed files with 554 additions and 518 deletions

View file

@ -52,7 +52,7 @@ module.exports = {
},
],
"import/order": [
"error",
"warn",
{
groups: ["builtin", "external", "internal", "parent", "sibling"],
pathGroups: [
@ -80,6 +80,11 @@ module.exports = {
pattern: "@/**",
group: "internal",
},
{
pattern: "public/**",
group: "internal",
position: "after",
},
],
pathGroupsExcludedImportTypes: ["builtin", "internal", "react"],
alphabetize: {

View file

@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
import { IndexedDBService } from "./indexedDB.service";
/**
* Abstract base class for making HTTP requests using axios
@ -20,38 +18,6 @@ export abstract class APIService {
baseURL,
withCredentials: true,
});
this.setupInterceptors();
}
/**
* Sets up axios interceptors for handling responses
* Currently handles 401 unauthorized responses by redirecting to login
* @private
*/
private setupInterceptors() {
this.axiosInstance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
const currentPath = window.location.pathname;
let prefix = "/";
let updatedPath = currentPath;
// Check for special path prefixes
if (currentPath.startsWith("/god-mode")) {
prefix = "/god-mode";
updatedPath = currentPath.replace("/god-mode", "");
} else if (currentPath.startsWith("/spaces")) {
prefix = "/spaces";
updatedPath = currentPath.replace("/spaces", "");
}
window.location.replace(`${prefix}${updatedPath ? `?next_path=${updatedPath}` : ""}`);
}
return Promise.reject(error);
}
);
}
/**

View file

@ -20,11 +20,10 @@ export class UserService extends APIService {
/**
* Retrieves the current user details
* @returns {Promise<IUser>} Promise resolving to the current user details\
* @remarks This method uses the validateStatus: null option to bypass interceptors for unauthorized errors.
* @returns {Promise<IUser>} Promise resolving to the current user details
*/
async me(): Promise<IUser> {
return this.get("/api/users/me/", { validateStatus: null })
return this.get("/api/users/me/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
@ -76,10 +75,9 @@ export class UserService extends APIService {
* Retrieves the current instance admin details
* @returns {Promise<IUser>} Promise resolving to the current instance admin details
* @throws {Error} If the API request fails
* @remarks This method uses the validateStatus: null option to bypass interceptors for unauthorized errors.
*/
async adminDetails(): Promise<IUser> {
return this.get("/api/instances/admins/me/", { validateStatus: null })
return this.get("/api/instances/admins/me/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;