1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-27 15:41:18 +03:00
guide/front/client/service/Category.ts

40 lines
790 B
TypeScript
Raw Normal View History

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: {
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 }