import axios from 'axios' import { ICategoryItem } from './CategoryItem' class CategoryService { async getCategoryById (id: ICategoryInfo['id']): Promise { const { data } = await axios.get(`api/category/${id}`, {}) return data } async getCategoryList (): Promise { const { data } = await axios.get('api/categories', {}) return data } async createCategory ( { title, group }: { title: ICategoryInfo['title'], group: ICategoryInfo['group'] } ): Promise { const { data } = await axios.post('api/category', null, { params: { title, group } }) return data } } export enum CategoryStatus { finished = 'CategoryFinished', inProgress = 'CategoryWIP', toBeWritten = 'CategoryStub' } export interface ICategoryInfo { id: string title: string created: string group: string status: CategoryStatus } export interface ICategoryFull { id: string title: string group: string status: CategoryStatus description: object items: ICategoryItem[] } const categoryServiceInstance = new CategoryService() export { categoryServiceInstance as CategoryService }