[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:
parent
ae657af958
commit
200be0ac7f
37 changed files with 240 additions and 284 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
export * from "./favorite.service";
|
||||
export * from "./user.service";
|
||||
|
|
|
|||
33
packages/services/src/user/user.service.ts
Normal file
33
packages/services/src/user/user.service.ts
Normal 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue