1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-26 14:23:14 +03:00
guide/front/client/service/Category.ts
Artyom Kazak ffca86a9ff Add categories to the right groups (#218)
* Add categories to the right groups
2018-09-22 22:12:21 +03:00

40 lines
784 B
TypeScript

import axios from "axios";
class CategoryService {
async getCategoryList(): Promise<ICategory[]> {
const { data } = await axios.get("api/categories", {})
return data
}
async createCategory({ title, group }: ICategory): Promise<ICategory[]> {
const { data } = await axios.post('api/category', null, {
params: {
title,
group
}
})
return data
}
}
export enum CategoryStatus {
finished = 'CategoryFinished',
inProgress = 'CategoryWIP',
toBeWritten = 'CategoryStub'
}
export interface ICategory {
created?: string
group?: string
status?: CategoryStatus
title?: string
uid?: string,
items: any[]
}
const categoryServiceInstance = new CategoryService()
export { categoryServiceInstance as CategoryService }