mirror of
https://github.com/makeplane/plane.git
synced 2026-07-13 14:01:45 +02:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
|
|
/* eslint-disable no-useless-catch */
|
||
|
|
|
||
|
|
// helpers
|
||
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
||
|
|
// plane web types
|
||
|
|
import { TWorkspaceFeature, TWorkspaceFeatures } from "@/plane-web/types/workspace-feature";
|
||
|
|
// services
|
||
|
|
import { APIService } from "@/services/api.service";
|
||
|
|
|
||
|
|
export class WorkspaceFeatureService extends APIService {
|
||
|
|
constructor() {
|
||
|
|
super(API_BASE_URL);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @description fetching workspace features
|
||
|
|
* @param { string } workspaceSlug
|
||
|
|
* @returns { TWorkspaceFeatures | undefined }
|
||
|
|
*/
|
||
|
|
async fetchWorkspaceFeatures(workspaceSlug: string): Promise<TWorkspaceFeatures | undefined> {
|
||
|
|
try {
|
||
|
|
const { data } = await this.get(`/api/workspaces/${workspaceSlug}/features/`);
|
||
|
|
return data || undefined;
|
||
|
|
} catch (error) {
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @description update workspace feature
|
||
|
|
* @param { string } workspaceSlug
|
||
|
|
* @param { Partial<TWorkspaceFeature> } payload
|
||
|
|
* @returns { TWorkspaceFeatures | undefined }
|
||
|
|
*/
|
||
|
|
async updateWorkspaceFeature(
|
||
|
|
workspaceSlug: string,
|
||
|
|
payload: Partial<TWorkspaceFeature>
|
||
|
|
): Promise<TWorkspaceFeatures | undefined> {
|
||
|
|
try {
|
||
|
|
const { data } = await this.patch(`/api/workspaces/${workspaceSlug}/features/`, payload);
|
||
|
|
return data || undefined;
|
||
|
|
} catch (error) {
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const workspaceFeatureService = new WorkspaceFeatureService();
|
||
|
|
|
||
|
|
export default workspaceFeatureService;
|