1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 22:02:58 +03:00
guide/front/client/service/Category.ts

39 lines
762 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
async createCategory({ title }: ICategory): Promise<ICategory[]> {
const { data } = await axios.post('api/category', null, {
params: {
title
}
})
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,
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 }