diff --git a/apps/web/core/services/dashboard.service.ts b/apps/web/core/services/dashboard.service.ts deleted file mode 100644 index a6ebc46292..0000000000 --- a/apps/web/core/services/dashboard.service.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2023-present Plane Software, Inc. and contributors - * SPDX-License-Identifier: AGPL-3.0-only - * See the LICENSE file for details. - */ - -import { API_BASE_URL } from "@plane/constants"; -import type { THomeDashboardResponse, TWidget, TWidgetStatsResponse, TWidgetStatsRequestParams } from "@plane/types"; -import { APIService } from "@/services/api.service"; -// helpers -// types - -export class DashboardService extends APIService { - constructor() { - super(API_BASE_URL); - } - - async getHomeDashboardWidgets(workspaceSlug: string): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/dashboard/`, { - params: { - dashboard_type: "home", - }, - }) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getWidgetStats( - workspaceSlug: string, - dashboardId: string, - params: TWidgetStatsRequestParams - ): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/dashboard/${dashboardId}/`, { - params, - }) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getDashboardDetails(dashboardId: string): Promise { - return this.get(`/api/dashboard/${dashboardId}/`) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async updateDashboardWidget(dashboardId: string, widgetId: string, data: Partial): Promise { - return this.patch(`/api/dashboard/${dashboardId}/widgets/${widgetId}/`, data) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } -} diff --git a/apps/web/core/store/dashboard.store.ts b/apps/web/core/store/dashboard.store.ts index a8a8186d7b..125cc24ecf 100644 --- a/apps/web/core/store/dashboard.store.ts +++ b/apps/web/core/store/dashboard.store.ts @@ -17,7 +17,7 @@ import type { TWidgetStatsRequestParams, } from "@plane/types"; // services -import { DashboardService } from "@/services/dashboard.service"; +import { DashboardService } from "@plane/services"; // plane web store import type { CoreRootStore } from "./root.store"; @@ -156,7 +156,7 @@ export class DashboardStore implements IDashboardStore { */ fetchHomeDashboardWidgets = async (workspaceSlug: string): Promise => { try { - const response = await this.dashboardService.getHomeDashboardWidgets(workspaceSlug); + const response = await this.dashboardService.getHomeWidgets(workspaceSlug); runInAction(() => { this.homeDashboardId = response.dashboard.id; @@ -228,7 +228,7 @@ export class DashboardStore implements IDashboardStore { ...data, }; }); - const response = await this.dashboardService.updateDashboardWidget(dashboardId, widgetId, data); + const response = await this.dashboardService.updateWidget(dashboardId, widgetId, data); return response; } catch (error) { // revert changes diff --git a/packages/services/src/dashboard/dashboard.service.ts b/packages/services/src/dashboard/dashboard.service.ts index 9b987e93a7..862ca9b297 100644 --- a/packages/services/src/dashboard/dashboard.service.ts +++ b/packages/services/src/dashboard/dashboard.service.ts @@ -8,7 +8,7 @@ import { API_BASE_URL } from "@plane/constants"; import type { THomeDashboardResponse, TWidget, TWidgetStatsResponse, TWidgetStatsRequestParams } from "@plane/types"; import { APIService } from "../api.service"; -export default class DashboardService extends APIService { +export class DashboardService extends APIService { constructor(BASE_URL?: string) { super(BASE_URL || API_BASE_URL); } @@ -83,5 +83,3 @@ export default class DashboardService extends APIService { }); } } - -export { DashboardService };