added create category support
This commit is contained in:
parent
a8548ce2f4
commit
248ded53c0
5 changed files with 11 additions and 10 deletions
|
|
@ -47,6 +47,7 @@ export class ExpenseComponent {
|
||||||
const snackId = this.snackBar.staticBar('Tracking new expense...');
|
const snackId = this.snackBar.staticBar('Tracking new expense...');
|
||||||
try {
|
try {
|
||||||
await this.expenseService.postExpense(postExpense);
|
await this.expenseService.postExpense(postExpense);
|
||||||
|
await this.expenseService.fetchExpenses();
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
this.snackBar.dismiss(snackId);
|
this.snackBar.dismiss(snackId);
|
||||||
this.snackBar.autoBar('Expense tracked!');
|
this.snackBar.autoBar('Expense tracked!');
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ export class CategoriesComponent {
|
||||||
public constructor(private readonly categoryService: CategoryService) { }
|
public constructor(private readonly categoryService: CategoryService) { }
|
||||||
|
|
||||||
public async createCategory(name: string): Promise<void> {
|
public async createCategory(name: string): Promise<void> {
|
||||||
console.log('Creating new category', name);
|
await this.categoryService.createCategory({ name });
|
||||||
|
await this.categoryService.fetchCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateCategory(category: Category): Promise<void> {
|
public async updateCategory(category: Category): Promise<void> {
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,9 @@
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div class="metadata-edit-buttons">
|
<div class="metadata-edit-buttons">
|
||||||
@if (metadata()) {
|
<button matIconButton (click)="reset()">
|
||||||
<button matIconButton (click)="reset()">
|
<mat-icon>undo</mat-icon>
|
||||||
<mat-icon>undo</mat-icon>
|
</button>
|
||||||
</button>
|
|
||||||
}
|
|
||||||
|
|
||||||
<button matIconButton (click)="saveMetaData()" [disabled]="!nameValid()">
|
<button matIconButton (click)="saveMetaData()" [disabled]="!nameValid()">
|
||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ export class CategoryService {
|
||||||
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async createCategory(category: CreateCategory): Promise<Category> {
|
||||||
|
return await this.http.post<Category>(this.categoryPath, category);
|
||||||
|
}
|
||||||
|
|
||||||
public async updateCategory(category: Category): Promise<Category> {
|
public async updateCategory(category: Category): Promise<Category> {
|
||||||
return await this.http.put<Category>(this.categoryPath, category);
|
return await this.http.put<Category>(this.categoryPath, category);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ export class ExpenseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async postExpense(createExpense: CreateExpense): Promise<Expense> {
|
public async postExpense(createExpense: CreateExpense): Promise<Expense> {
|
||||||
const createdExpense = await this.http.post<Expense>(this.expensePath, createExpense);
|
return await this.http.post<Expense>(this.expensePath, createExpense);
|
||||||
await this.fetchExpenses();
|
|
||||||
|
|
||||||
return createdExpense;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateExpense(updateExpense: UpdateExpense): Promise<Expense> {
|
public async updateExpense(updateExpense: UpdateExpense): Promise<Expense> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue