[WEB-3065] refactor: replace admin services with service packages (#6342)

* [WEB-3065] refactor: replace admin services with service packages

* chore: minor updates

* chore: error handling
This commit is contained in:
Prateek Shourya 2025-01-07 19:07:47 +05:30 committed by GitHub
parent ae657af958
commit 200be0ac7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 240 additions and 284 deletions

View file

@ -1,6 +1,6 @@
import { API_BASE_URL } from "@plane/constants";
import type { IFavorite } from "@plane/types";
import { APIService } from "@/api.service";
import { APIService } from "../api.service";
/**
* Service class for managing user favorites

View file

@ -1 +1,2 @@
export * from "./favorite.service";
export * from "./user.service";

View file

@ -0,0 +1,33 @@
// plane imports
import { API_BASE_URL } from "@plane/constants";
import type { IUser } from "@plane/types";
// api service
import { APIService } from "../api.service";
/**
* Service class for managing user operations
* Handles operations for retrieving the current user's details and perform CRUD operations
* @extends {APIService}
*/
export class UserService extends APIService {
/**
* Constructor for UserService
* @param BASE_URL - Base URL for API requests
*/
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves the current instance admin details
* @returns {Promise<IUser>} Promise resolving to the current instance admin details
* @throws {Error} If the API request fails
*/
async adminDetails(): Promise<IUser> {
return this.get("/api/instances/admins/me/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}