Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

1.2 KB
Raw Blame
import TvApiBase from "./base";
import type { AppResponse } from "./base.types";
import type { GoalArgItemAdd, GoalArgItemUpdate, GoalResponseAdd, GoalResponseFetch, GoalResponseUpdate } from "./goals.types";

export default class TvGoalApi extends TvApiBase {
    protected moduleUrl = '/module/goals';

    public async createGoal(goal: GoalArgItemAdd) {
        return this.request(
            this.$axios.post<AppResponse<GoalResponseAdd>>(
                `${this.moduleUrl}`, goal
            )
        );
    }

    public async updateGoal(goal: GoalArgItemUpdate) {
        return this.request(
            this.$axios.patch<AppResponse<GoalResponseUpdate>>(
                `${this.moduleUrl}`, goal
            )
        );
    }

    public async deleteGoal(goalId: number) {
        return this.request(
            this.$axios.delete<AppResponse<boolean>>(
                `${this.moduleUrl}`, { data: { goalId } }
            )
        );
    }

    public async fetchGoals(organizationId?: number) {
        return this.request(
            this.$axios.get<AppResponse<GoalResponseFetch>>(
                `${this.moduleUrl}`, organizationId ? { params: { organizationId } } : undefined
            )
        );
    }
}