tags and new analytics new in budget
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// src/services/categoryService.ts
|
||||
import apiClient from '@/services/axiosSetup';
|
||||
import {Category} from "@/models/Category";
|
||||
import {Category, CategoryTag} from "@/models/Category";
|
||||
import {useSpaceStore} from "@/stores/spaceStore"; // Импортируете настроенный экземпляр axios
|
||||
|
||||
export const getCategories = async (type = null) => {
|
||||
@@ -22,12 +22,20 @@ export const getCategoryTypes = async () => {
|
||||
|
||||
export const createCategory = async (category: Category) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.post(`/spaces/${spaceStore.space?.id}/categories`, category);
|
||||
return await apiClient.post(`/spaces/${spaceStore.space?.id}/categories`, category)
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
throw err
|
||||
})
|
||||
};
|
||||
|
||||
export const updateCategory = async (id: number, category: any) => {
|
||||
export const editCategoryRequest = async (category: any) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.put(`/spaces/${spaceStore.space?.id}/categories/${id}`, category);
|
||||
return await apiClient.put(`/spaces/${spaceStore.space?.id}/categories/${category.id}`, category)
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
throw err
|
||||
})
|
||||
};
|
||||
|
||||
export const deleteCategory = async (id: number) => {
|
||||
@@ -38,5 +46,32 @@ export const deleteCategory = async (id: number) => {
|
||||
export const getCategoriesSumsRequest = async (spaceId: string) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.get(`/spaces/${spaceStore.space?.id}/analytics/by-month`)
|
||||
}
|
||||
|
||||
export const getTagsRequest = async () => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.get(`/spaces/${spaceStore.space?.id}/categories/tags`)
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
export const createTagRequest = async (tag: CategoryTag) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.post(`/spaces/${spaceStore.space?.id}/categories/tags`, tag)
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteTagRequest = async (tag: CategoryTag) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.delete(`/spaces/${spaceStore.space?.id}/categories/tags/${tag.code}`)
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
throw err
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user