import axios from "../../../../config/axios";
import {
  CreateWorkspaceType,
  UpdateWorkspaceType,
} from "../types/WorkspaceTypes";

export const getWorkspacesByUser = async () => {
  const { data } = await axios.get(`/task-manager/workspaces/byuser`);
  return data;
};

export const getWorkspaceDetail = async (id: string) => {
  const { data } = await axios.get(`/task-manager/workspaces/${id}`);
  return data;
};

export const createWorkspace = async (params: CreateWorkspaceType) => {
  const { data } = await axios.post(`/task-manager/workspaces`, params);
  return data;
};

export const updateWorkspace = async (id: string, params: UpdateWorkspaceType) => {
  const { data } = await axios.patch(`/task-manager/workspaces/${id}`, params);
  return data;
};

export const deleteWorkspace = async (id: string) => {
  const { data } = await axios.delete(`/task-manager/workspaces/${id}`);
  return data;
};
