2018-09-12 23:09:34 +03:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
class CategoryService {
|
|
|
|
async getCategoryList(): Promise<ICategory[]> {
|
|
|
|
const { data } = await axios.get("api/categories", {})
|
|
|
|
return data
|
|
|
|
}
|
2018-09-16 21:02:30 +03:00
|
|
|
|
2018-10-29 21:17:13 +03:00
|
|
|
async createCategory({ title, group }: ICategory): Promise<ICategory['uid']> {
|
2018-09-16 21:02:30 +03:00
|
|
|
const { data } = await axios.post('api/category', null, {
|
|
|
|
params: {
|
2018-09-22 22:12:21 +03:00
|
|
|
title,
|
|
|
|
group
|
2018-09-16 21:02:30 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return data
|
|
|
|
}
|
2018-09-12 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
2018-09-16 16:32:35 +03:00
|
|
|
export enum CategoryStatus {
|
|
|
|
finished = 'CategoryFinished',
|
|
|
|
inProgress = 'CategoryWIP',
|
|
|
|
toBeWritten = 'CategoryStub'
|
|
|
|
|
|
|
|
}
|
2018-09-12 23:09:34 +03:00
|
|
|
export interface ICategory {
|
2018-09-16 21:02:30 +03:00
|
|
|
created?: string
|
|
|
|
group?: string
|
|
|
|
status?: CategoryStatus
|
|
|
|
title?: string
|
2018-09-20 10:26:36 +03:00
|
|
|
uid?: string,
|
2018-10-29 21:17:13 +03:00
|
|
|
items?: any[]
|
2018-09-12 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
2018-09-16 16:32:35 +03:00
|
|
|
|
2018-09-12 23:09:34 +03:00
|
|
|
const categoryServiceInstance = new CategoryService()
|
|
|
|
|
|
|
|
|
|
|
|
export { categoryServiceInstance as CategoryService }
|