add spaces
This commit is contained in:
@@ -1,36 +1,42 @@
|
||||
// src/services/categoryService.ts
|
||||
import apiClient from '@/services/axiosSetup';
|
||||
import {Category} from "@/models/Category"; // Импортируете настроенный экземпляр axios
|
||||
import {Category} from "@/models/Category";
|
||||
import {useSpaceStore} from "@/stores/spaceStore"; // Импортируете настроенный экземпляр axios
|
||||
|
||||
export const getCategories = async (type = null) => {
|
||||
|
||||
const spaceStore = await useSpaceStore();
|
||||
|
||||
const params = {};
|
||||
if (type) {
|
||||
params.type = type;
|
||||
}
|
||||
return await apiClient.get('/categories', {
|
||||
return await apiClient.get(`/spaces/${spaceStore.space?.id}/categories`, {
|
||||
params: params
|
||||
});
|
||||
};
|
||||
|
||||
export const getCategoryTypes = async () => {
|
||||
return await apiClient.get('/categories/types');
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.get(`/spaces/${spaceStore.space?.id}/categories/types`);
|
||||
}
|
||||
|
||||
export const createCategory = async (category: Category) => {
|
||||
return await apiClient.post('/categories', category);
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.post(`/spaces/${spaceStore.space?.id}/categories`, category);
|
||||
};
|
||||
|
||||
export const updateCategory = async (id: number, category: any) => {
|
||||
return await apiClient.put(`/categories/${id}`, category);
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.put(`/spaces/${spaceStore.space?.id}/categories/${id}`, category);
|
||||
};
|
||||
|
||||
export const deleteCategory = async (id: number) => {
|
||||
return await apiClient.delete(`/categories/${id}`);
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.delete(`/spaces/${spaceStore.space?.id}/categories/${id}`);
|
||||
};
|
||||
|
||||
export const getCategoriesSumsRequest = async () => {
|
||||
return await apiClient.get('/categories/by-month2');
|
||||
export const getCategoriesSumsRequest = async (spaceId: string) => {
|
||||
const spaceStore = useSpaceStore();
|
||||
return await apiClient.get(`/spaces/${spaceStore.space?.id}/analytics/by-month`)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user