small tweak to add expense
This commit is contained in:
parent
0e2e2f9e84
commit
8bf9875e8e
3 changed files with 63 additions and 10 deletions
|
|
@ -1,14 +1,41 @@
|
|||
import { Component } from '@angular/core';
|
||||
import {CardComponent} from '../card/card.component';
|
||||
import {Component, computed, signal} from '@angular/core';
|
||||
import { CardComponent } from '../card/card.component';
|
||||
import {Category, CategoryService} from '../../services/category.service';
|
||||
import {Merchant, MerchantService} from '../../services/merchant.service';
|
||||
import { Tag } from '../../services/tag.service';
|
||||
import {form, FormField} from '@angular/forms/signals';
|
||||
|
||||
interface AddExpenseForm {
|
||||
date: Date,
|
||||
amount: number | string,
|
||||
categoryId: string,
|
||||
merchantId: string,
|
||||
note: string,
|
||||
tags: Tag[]
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-expense',
|
||||
imports: [
|
||||
CardComponent
|
||||
CardComponent,
|
||||
FormField
|
||||
],
|
||||
templateUrl: './add-expense.component.html',
|
||||
styleUrl: './add-expense.component.scss',
|
||||
})
|
||||
export class AddExpenseComponent {
|
||||
protected categories = computed(() => this.categoryService.categories());
|
||||
protected merchants = computed(() => this.merchantService.merchants());
|
||||
private addExpenseModel = signal<AddExpenseForm>({
|
||||
date: new Date(),
|
||||
amount: '',
|
||||
categoryId: '',
|
||||
merchantId: '',
|
||||
note: '',
|
||||
tags: []
|
||||
});
|
||||
public expenseForm = form(this.addExpenseModel);
|
||||
|
||||
public constructor(private readonly categoryService: CategoryService,
|
||||
private readonly merchantService: MerchantService) { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue