support for editing category
This commit is contained in:
parent
5c48a6f4e7
commit
dbb4c1ed38
2 changed files with 10 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ export class CategoriesComponent {
|
||||||
public constructor(private readonly categoryService: CategoryService) { }
|
public constructor(private readonly categoryService: CategoryService) { }
|
||||||
|
|
||||||
public async updateCategory(category: Category): Promise<void> {
|
public async updateCategory(category: Category): Promise<void> {
|
||||||
console.log('updated category', category); // TODO: Remove
|
await this.categoryService.updateCategory(category);
|
||||||
|
await this.categoryService.fetchCategories();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,17 @@ export class CategoryService {
|
||||||
public async fetchCategories(): Promise<void> {
|
public async fetchCategories(): Promise<void> {
|
||||||
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateCategory(category: Category): Promise<Category> {
|
||||||
|
return await this.http.put<Category>(this.categoryPath, category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Category {
|
export interface Category {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CreateCategory {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue