component gemaakt van nieuwe klant toevoegen + correcte validatie email
This commit is contained in:
@@ -13,16 +13,12 @@ import {
|
||||
import {Appointment} from '../../models/appointment';
|
||||
import {TuiDay, TuiTime, TuiValidationError} from '@taiga-ui/cdk';
|
||||
import {AppointmentService} from '../../services/appointment.service';
|
||||
import {
|
||||
TuiButtonLoading,
|
||||
TuiDataListWrapperComponent,
|
||||
TuiFilterByInputPipe,
|
||||
TuiStringifyContentPipe
|
||||
} from '@taiga-ui/kit';
|
||||
import {TuiDataListWrapperComponent, TuiFilterByInputPipe, TuiStringifyContentPipe} from '@taiga-ui/kit';
|
||||
import {Customer} from '../../models/customer';
|
||||
import {CustomerService} from '../../services/customer.service';
|
||||
import {ModalComponent} from '../modal/modal.component';
|
||||
import {timeAfterStartValidator} from '../../models/validators/time-after-start-validator';
|
||||
import {NewCustomerComponent} from '../new-customer/new-customer.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-item',
|
||||
@@ -43,8 +39,8 @@ import {timeAfterStartValidator} from '../../models/validators/time-after-start-
|
||||
TuiFilterByInputPipe,
|
||||
ModalComponent,
|
||||
TuiIcon,
|
||||
TuiButtonLoading,
|
||||
TuiError
|
||||
TuiError,
|
||||
NewCustomerComponent
|
||||
],
|
||||
templateUrl: './new-item.component.html',
|
||||
styleUrl: './new-item.component.scss'
|
||||
@@ -72,7 +68,7 @@ export class NewItemComponent implements OnInit {
|
||||
this.customerForm = new FormGroup({
|
||||
firstName: new FormControl('', Validators.required),
|
||||
lastName: new FormControl('', Validators.required),
|
||||
email: new FormControl('', Validators.required),
|
||||
email: new FormControl('', [Validators.required, Validators.email]),
|
||||
})
|
||||
this.appointmentForm.get('startTime').setValue(new TuiTime(this.today.getHours(), this.today.getMinutes()), Validators.required)
|
||||
this.appointmentForm.get('endTime').setValue(new TuiTime(this.getEndTime().getHours(), this.getEndTime().getMinutes()), [Validators.required, timeAfterStartValidator('startTime')])
|
||||
@@ -133,15 +129,8 @@ export class NewItemComponent implements OnInit {
|
||||
`${item.firstName} ${item.lastName}`;
|
||||
|
||||
saveCustomer() {
|
||||
const firstName = this.customerForm.get('firstName').value
|
||||
const lastName = this.customerForm.get('lastName').value
|
||||
const email = this.customerForm.get('email').value
|
||||
const customer = new Customer(firstName, lastName, email);
|
||||
|
||||
this.customerService.addCustomer(customer).subscribe(() => {
|
||||
this.showNewCustomer = false;
|
||||
this.getCustomers()
|
||||
})
|
||||
this.showNewCustomer = false;
|
||||
this.getCustomers()
|
||||
}
|
||||
|
||||
getCustomers() {
|
||||
|
||||
Reference in New Issue
Block a user